diff --git a/bootstrapper/internal/kubernetes/kubernetes.go b/bootstrapper/internal/kubernetes/kubernetes.go index 32a0ab62b..c8d2cbc72 100644 --- a/bootstrapper/internal/kubernetes/kubernetes.go +++ b/bootstrapper/internal/kubernetes/kubernetes.go @@ -174,7 +174,7 @@ func (k *KubeWrapper) InitCluster( // Annotate Node with the hash of the installed components if err := k.client.AnnotateNode(ctx, nodeName, - constants.NodeKubernetesComponentsHashAnnotationKey, k8sComponentsConfigMap, + constants.NodeKubernetesComponentsAnnotationKey, k8sComponentsConfigMap, ); err != nil { return nil, fmt.Errorf("annotating node with Kubernetes components hash: %w", err) } diff --git a/internal/constants/constants.go b/internal/constants/constants.go index 7240e8259..cae3a72e0 100644 --- a/internal/constants/constants.go +++ b/internal/constants/constants.go @@ -118,8 +118,8 @@ const ( // ComponentsListKey is the name of the key holding the list of components in the components configMap. ComponentsListKey = "components" - // NodeKubernetesComponentsHashAnnotationKey is the name of the annotation holding the reference to the ConfigMap listing all K8s components. - NodeKubernetesComponentsHashAnnotationKey = "constellation.edgeless.systems/kubernetes-components" + // NodeKubernetesComponentsAnnotationKey is the name of the annotation holding the reference to the ConfigMap listing all K8s components. + NodeKubernetesComponentsAnnotationKey = "constellation.edgeless.systems/kubernetes-components" // JoiningNodesConfigMapName is the name of the configMap holding the joining nodes with the components hashes the node-operator should annotate the nodes with. JoiningNodesConfigMapName = "joining-nodes" diff --git a/operators/constellation-node-operator/controllers/joiningnode_controller.go b/operators/constellation-node-operator/controllers/joiningnode_controller.go index 8e0b1df4d..3417b66b4 100644 --- a/operators/constellation-node-operator/controllers/joiningnode_controller.go +++ b/operators/constellation-node-operator/controllers/joiningnode_controller.go @@ -74,7 +74,7 @@ func (r *JoiningNodesReconciler) Reconcile(ctx context.Context, req ctrl.Request if node.Annotations == nil { node.Annotations = map[string]string{} } - node.Annotations[mainconstants.NodeKubernetesComponentsHashAnnotationKey] = joiningNode.Spec.ComponentsReference + node.Annotations[mainconstants.NodeKubernetesComponentsAnnotationKey] = joiningNode.Spec.ComponentsReference return r.Update(ctx, &node) }) if err != nil { diff --git a/operators/constellation-node-operator/controllers/joiningnode_controller_env_test.go b/operators/constellation-node-operator/controllers/joiningnode_controller_env_test.go index 19a199efb..a1f241f0c 100644 --- a/operators/constellation-node-operator/controllers/joiningnode_controller_env_test.go +++ b/operators/constellation-node-operator/controllers/joiningnode_controller_env_test.go @@ -81,7 +81,7 @@ var _ = Describe("JoiningNode controller", func() { By("annotating the node") Eventually(func() string { _ = k8sClient.Get(ctx, types.NamespacedName{Name: nodeName1}, createdNode) - return createdNode.Annotations[mainconstants.NodeKubernetesComponentsHashAnnotationKey] + return createdNode.Annotations[mainconstants.NodeKubernetesComponentsAnnotationKey] }, timeout, interval).Should(Equal(ComponentsReference1)) By("deleting the joining node resource") @@ -135,7 +135,7 @@ var _ = Describe("JoiningNode controller", func() { By("annotating the node") Eventually(func() string { _ = k8sClient.Get(ctx, types.NamespacedName{Name: createdNode.Name}, createdNode) - return createdNode.Annotations[mainconstants.NodeKubernetesComponentsHashAnnotationKey] + return createdNode.Annotations[mainconstants.NodeKubernetesComponentsAnnotationKey] }, timeout, interval).Should(Equal(ComponentsReference2)) By("deleting the joining node resource") diff --git a/operators/constellation-node-operator/controllers/nodeversion_controller.go b/operators/constellation-node-operator/controllers/nodeversion_controller.go index c2d860a42..4f9c39f3b 100644 --- a/operators/constellation-node-operator/controllers/nodeversion_controller.go +++ b/operators/constellation-node-operator/controllers/nodeversion_controller.go @@ -777,7 +777,7 @@ func groupNodes(nodes []corev1.Node, pendingNodes []updatev1alpha1.PendingNode, continue } if !strings.EqualFold(node.Annotations[nodeImageAnnotation], latestImageReference) || - !strings.EqualFold(node.Annotations[mainconstants.NodeKubernetesComponentsHashAnnotationKey], latestK8sComponentsReference) { + !strings.EqualFold(node.Annotations[mainconstants.NodeKubernetesComponentsAnnotationKey], latestK8sComponentsReference) { if heir := node.Annotations[heirAnnotation]; heir != "" { groups.Donors = append(groups.Donors, node) } else { diff --git a/operators/constellation-node-operator/controllers/nodeversion_controller_test.go b/operators/constellation-node-operator/controllers/nodeversion_controller_test.go index e99e107b0..dd13485e1 100644 --- a/operators/constellation-node-operator/controllers/nodeversion_controller_test.go +++ b/operators/constellation-node-operator/controllers/nodeversion_controller_test.go @@ -609,9 +609,9 @@ func TestGroupNodes(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: "outdated", Annotations: map[string]string{ - scalingGroupAnnotation: scalingGroup, - mainconstants.NodeKubernetesComponentsHashAnnotationKey: latestK8sComponentsReference, - nodeImageAnnotation: "old-image", + scalingGroupAnnotation: scalingGroup, + mainconstants.NodeKubernetesComponentsAnnotationKey: latestK8sComponentsReference, + nodeImageAnnotation: "old-image", }, }, }, @@ -619,9 +619,9 @@ func TestGroupNodes(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: "outdated", Annotations: map[string]string{ - scalingGroupAnnotation: scalingGroup, - mainconstants.NodeKubernetesComponentsHashAnnotationKey: "old-ref", - nodeImageAnnotation: latestImageReference, + scalingGroupAnnotation: scalingGroup, + mainconstants.NodeKubernetesComponentsAnnotationKey: "old-ref", + nodeImageAnnotation: latestImageReference, }, }, }, @@ -631,9 +631,9 @@ func TestGroupNodes(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: "uptodate", Annotations: map[string]string{ - scalingGroupAnnotation: scalingGroup, - nodeImageAnnotation: latestImageReference, - mainconstants.NodeKubernetesComponentsHashAnnotationKey: latestK8sComponentsReference, + scalingGroupAnnotation: scalingGroup, + nodeImageAnnotation: latestImageReference, + mainconstants.NodeKubernetesComponentsAnnotationKey: latestK8sComponentsReference, }, }, }, @@ -643,10 +643,10 @@ func TestGroupNodes(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: "donor", Annotations: map[string]string{ - scalingGroupAnnotation: scalingGroup, - nodeImageAnnotation: "old-image", - mainconstants.NodeKubernetesComponentsHashAnnotationKey: latestK8sComponentsReference, - heirAnnotation: "heir", + scalingGroupAnnotation: scalingGroup, + nodeImageAnnotation: "old-image", + mainconstants.NodeKubernetesComponentsAnnotationKey: latestK8sComponentsReference, + heirAnnotation: "heir", }, }, }, @@ -654,10 +654,10 @@ func TestGroupNodes(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: "donor", Annotations: map[string]string{ - scalingGroupAnnotation: scalingGroup, - nodeImageAnnotation: latestImageReference, - mainconstants.NodeKubernetesComponentsHashAnnotationKey: "old-ref", - heirAnnotation: "heir", + scalingGroupAnnotation: scalingGroup, + nodeImageAnnotation: latestImageReference, + mainconstants.NodeKubernetesComponentsAnnotationKey: "old-ref", + heirAnnotation: "heir", }, }, }, @@ -667,10 +667,10 @@ func TestGroupNodes(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: "heir", Annotations: map[string]string{ - scalingGroupAnnotation: scalingGroup, - nodeImageAnnotation: latestImageReference, - mainconstants.NodeKubernetesComponentsHashAnnotationKey: latestK8sComponentsReference, - donorAnnotation: "donor", + scalingGroupAnnotation: scalingGroup, + nodeImageAnnotation: latestImageReference, + mainconstants.NodeKubernetesComponentsAnnotationKey: latestK8sComponentsReference, + donorAnnotation: "donor", }, }, }, @@ -680,10 +680,10 @@ func TestGroupNodes(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: "obsolete", Annotations: map[string]string{ - scalingGroupAnnotation: scalingGroup, - nodeImageAnnotation: latestImageReference, - mainconstants.NodeKubernetesComponentsHashAnnotationKey: latestK8sComponentsReference, - obsoleteAnnotation: "true", + scalingGroupAnnotation: scalingGroup, + nodeImageAnnotation: latestImageReference, + mainconstants.NodeKubernetesComponentsAnnotationKey: latestK8sComponentsReference, + obsoleteAnnotation: "true", }, }, }, @@ -694,9 +694,9 @@ func TestGroupNodes(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: "mint", Annotations: map[string]string{ - scalingGroupAnnotation: scalingGroup, - nodeImageAnnotation: latestImageReference, - mainconstants.NodeKubernetesComponentsHashAnnotationKey: latestK8sComponentsReference, + scalingGroupAnnotation: scalingGroup, + nodeImageAnnotation: latestImageReference, + mainconstants.NodeKubernetesComponentsAnnotationKey: latestK8sComponentsReference, }, }, },