openyurtio / yurt-app-manager

The workload controller manager from NodePool level in OpenYurt cluster
Apache License 2.0
6 stars 1 forks source link

[BUG] a node'label will be deleted if it deleted from a nodepool that has the same label #41

Open chenyufeifei opened 2 years ago

chenyufeifei commented 2 years ago

What happened: First, I create a nodePool

cat <<EOF | kubectl apply -f -
apiVersion: apps.openyurt.io/v1alpha1
kind: NodePool
metadata:
  name: test
spec:
  type: Edge
  labels:
    foo: bar
EOF

Second, I add a label in a node

kubectl label nodes kind-worker foo=bar

Third, I add the node to the nodepool

kubectl label node  kind-worker apps.openyurt.io/desired-nodepool=test

Last, I delete the node from the nodePool

kubectl label node kind-worker apps.openyurt.io/desired-nodepool-

1646841060068

What you expected to happen:

The node should have a label foo=bar

How to reproduce it (as minimally and precisely as possible):

Anything else we need to know?:

I read the source code, find it record the nodePool related attribute. https://github.com/openyurtio/yurt-app-manager/blob/5dc7d07355df12cd63ebc3cb7692f601a932b7a1/pkg/yurtappmanager/controller/nodepool/nodepool_controller.go#L236-L241 https://github.com/openyurtio/yurt-app-manager/blob/5dc7d07355df12cd63ebc3cb7692f601a932b7a1/pkg/yurtappmanager/controller/nodepool/nodepool_controller.go#L325-L327

When the node delete from the nodepool, all label will be deleted include the same label.

https://github.com/openyurtio/yurt-app-manager/blob/5dc7d07355df12cd63ebc3cb7692f601a932b7a1/pkg/yurtappmanager/controller/nodepool/nodepool_controller.go#L268-L304

Environment:

others

/kind bug

rambohe-ch commented 1 year ago

@kadisi PTAL