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-

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.
|
attrUpdated, err := conciliatePoolRelatedAttrs(&node, |
|
NodePoolRelatedAttributes{ |
|
Labels: nodePool.Spec.Labels, |
|
Annotations: nodePool.Spec.Annotations, |
|
Taints: nodePool.Spec.Taints, |
|
}) |
|
if err := cachePrevPoolAttrs(node, npra); err != nil { |
|
return attrUpdated, err |
|
} |
When the node delete from the nodepool, all label will be deleted include the same label.
|
func removePoolRelatedAttrs(node *corev1.Node) error { |
|
var npra NodePoolRelatedAttributes |
|
|
|
if _, exist := node.Annotations[appsv1alpha1.AnnotationPrevAttrs]; !exist { |
|
return nil |
|
} |
|
|
|
if err := json.Unmarshal( |
|
[]byte(node.Annotations[appsv1alpha1.AnnotationPrevAttrs]), |
|
&npra); err != nil { |
|
return err |
|
} |
|
|
|
for lk, lv := range npra.Labels { |
|
if node.Labels[lk] == lv { |
|
delete(node.Labels, lk) |
|
} |
|
} |
|
|
|
for ak, av := range npra.Annotations { |
|
if node.Annotations[ak] == av { |
|
delete(node.Annotations, ak) |
|
} |
|
} |
|
|
|
for _, t := range npra.Taints { |
|
if i, exist := containTaint(t, node.Spec.Taints); exist { |
|
node.Spec.Taints = append( |
|
node.Spec.Taints[:i], |
|
node.Spec.Taints[i+1:]...) |
|
} |
|
} |
|
delete(node.Annotations, appsv1alpha1.AnnotationPrevAttrs) |
|
delete(node.Labels, appsv1alpha1.LabelCurrentNodePool) |
|
|
|
return nil |
|
} |
Environment:
- OpenYurt version:
- Kubernetes version (use
kubectl version):
- OS (e.g:
cat /etc/os-release):
- Kernel (e.g.
uname -a):
- Install tools:
- Others:
others
/kind bug
What happened:
First, I create a nodePool
Second, I add a label in a node
Third, I add the node to the nodepool
Last, I delete the node from the nodePool
What you expected to happen:
The node should have a label
foo=barHow 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.
yurt-app-manager/pkg/yurtappmanager/controller/nodepool/nodepool_controller.go
Lines 236 to 241 in 5dc7d07
yurt-app-manager/pkg/yurtappmanager/controller/nodepool/nodepool_controller.go
Lines 325 to 327 in 5dc7d07
When the node delete from the nodepool, all label will be deleted include the same label.
yurt-app-manager/pkg/yurtappmanager/controller/nodepool/nodepool_controller.go
Lines 268 to 304 in 5dc7d07
Environment:
kubectl version):cat /etc/os-release):uname -a):others
/kind bug