constants: rename components annotation key

This commit is contained in:
Leonard Cohnen 2023-01-06 20:48:03 +01:00 committed by 3u13r
parent 703f73a761
commit 8c5e41b865
6 changed files with 35 additions and 35 deletions

View File

@ -174,7 +174,7 @@ func (k *KubeWrapper) InitCluster(
// Annotate Node with the hash of the installed components // Annotate Node with the hash of the installed components
if err := k.client.AnnotateNode(ctx, nodeName, if err := k.client.AnnotateNode(ctx, nodeName,
constants.NodeKubernetesComponentsHashAnnotationKey, k8sComponentsConfigMap, constants.NodeKubernetesComponentsAnnotationKey, k8sComponentsConfigMap,
); err != nil { ); err != nil {
return nil, fmt.Errorf("annotating node with Kubernetes components hash: %w", err) return nil, fmt.Errorf("annotating node with Kubernetes components hash: %w", err)
} }

View File

@ -118,8 +118,8 @@ const (
// ComponentsListKey is the name of the key holding the list of components in the components configMap. // ComponentsListKey is the name of the key holding the list of components in the components configMap.
ComponentsListKey = "components" ComponentsListKey = "components"
// NodeKubernetesComponentsHashAnnotationKey is the name of the annotation holding the reference to the ConfigMap listing all K8s components. // NodeKubernetesComponentsAnnotationKey is the name of the annotation holding the reference to the ConfigMap listing all K8s components.
NodeKubernetesComponentsHashAnnotationKey = "constellation.edgeless.systems/kubernetes-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 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" JoiningNodesConfigMapName = "joining-nodes"

View File

@ -74,7 +74,7 @@ func (r *JoiningNodesReconciler) Reconcile(ctx context.Context, req ctrl.Request
if node.Annotations == nil { if node.Annotations == nil {
node.Annotations = map[string]string{} node.Annotations = map[string]string{}
} }
node.Annotations[mainconstants.NodeKubernetesComponentsHashAnnotationKey] = joiningNode.Spec.ComponentsReference node.Annotations[mainconstants.NodeKubernetesComponentsAnnotationKey] = joiningNode.Spec.ComponentsReference
return r.Update(ctx, &node) return r.Update(ctx, &node)
}) })
if err != nil { if err != nil {

View File

@ -81,7 +81,7 @@ var _ = Describe("JoiningNode controller", func() {
By("annotating the node") By("annotating the node")
Eventually(func() string { Eventually(func() string {
_ = k8sClient.Get(ctx, types.NamespacedName{Name: nodeName1}, createdNode) _ = k8sClient.Get(ctx, types.NamespacedName{Name: nodeName1}, createdNode)
return createdNode.Annotations[mainconstants.NodeKubernetesComponentsHashAnnotationKey] return createdNode.Annotations[mainconstants.NodeKubernetesComponentsAnnotationKey]
}, timeout, interval).Should(Equal(ComponentsReference1)) }, timeout, interval).Should(Equal(ComponentsReference1))
By("deleting the joining node resource") By("deleting the joining node resource")
@ -135,7 +135,7 @@ var _ = Describe("JoiningNode controller", func() {
By("annotating the node") By("annotating the node")
Eventually(func() string { Eventually(func() string {
_ = k8sClient.Get(ctx, types.NamespacedName{Name: createdNode.Name}, createdNode) _ = k8sClient.Get(ctx, types.NamespacedName{Name: createdNode.Name}, createdNode)
return createdNode.Annotations[mainconstants.NodeKubernetesComponentsHashAnnotationKey] return createdNode.Annotations[mainconstants.NodeKubernetesComponentsAnnotationKey]
}, timeout, interval).Should(Equal(ComponentsReference2)) }, timeout, interval).Should(Equal(ComponentsReference2))
By("deleting the joining node resource") By("deleting the joining node resource")

View File

@ -777,7 +777,7 @@ func groupNodes(nodes []corev1.Node, pendingNodes []updatev1alpha1.PendingNode,
continue continue
} }
if !strings.EqualFold(node.Annotations[nodeImageAnnotation], latestImageReference) || 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 != "" { if heir := node.Annotations[heirAnnotation]; heir != "" {
groups.Donors = append(groups.Donors, node) groups.Donors = append(groups.Donors, node)
} else { } else {

View File

@ -609,9 +609,9 @@ func TestGroupNodes(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "outdated", Name: "outdated",
Annotations: map[string]string{ Annotations: map[string]string{
scalingGroupAnnotation: scalingGroup, scalingGroupAnnotation: scalingGroup,
mainconstants.NodeKubernetesComponentsHashAnnotationKey: latestK8sComponentsReference, mainconstants.NodeKubernetesComponentsAnnotationKey: latestK8sComponentsReference,
nodeImageAnnotation: "old-image", nodeImageAnnotation: "old-image",
}, },
}, },
}, },
@ -619,9 +619,9 @@ func TestGroupNodes(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "outdated", Name: "outdated",
Annotations: map[string]string{ Annotations: map[string]string{
scalingGroupAnnotation: scalingGroup, scalingGroupAnnotation: scalingGroup,
mainconstants.NodeKubernetesComponentsHashAnnotationKey: "old-ref", mainconstants.NodeKubernetesComponentsAnnotationKey: "old-ref",
nodeImageAnnotation: latestImageReference, nodeImageAnnotation: latestImageReference,
}, },
}, },
}, },
@ -631,9 +631,9 @@ func TestGroupNodes(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "uptodate", Name: "uptodate",
Annotations: map[string]string{ Annotations: map[string]string{
scalingGroupAnnotation: scalingGroup, scalingGroupAnnotation: scalingGroup,
nodeImageAnnotation: latestImageReference, nodeImageAnnotation: latestImageReference,
mainconstants.NodeKubernetesComponentsHashAnnotationKey: latestK8sComponentsReference, mainconstants.NodeKubernetesComponentsAnnotationKey: latestK8sComponentsReference,
}, },
}, },
}, },
@ -643,10 +643,10 @@ func TestGroupNodes(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "donor", Name: "donor",
Annotations: map[string]string{ Annotations: map[string]string{
scalingGroupAnnotation: scalingGroup, scalingGroupAnnotation: scalingGroup,
nodeImageAnnotation: "old-image", nodeImageAnnotation: "old-image",
mainconstants.NodeKubernetesComponentsHashAnnotationKey: latestK8sComponentsReference, mainconstants.NodeKubernetesComponentsAnnotationKey: latestK8sComponentsReference,
heirAnnotation: "heir", heirAnnotation: "heir",
}, },
}, },
}, },
@ -654,10 +654,10 @@ func TestGroupNodes(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "donor", Name: "donor",
Annotations: map[string]string{ Annotations: map[string]string{
scalingGroupAnnotation: scalingGroup, scalingGroupAnnotation: scalingGroup,
nodeImageAnnotation: latestImageReference, nodeImageAnnotation: latestImageReference,
mainconstants.NodeKubernetesComponentsHashAnnotationKey: "old-ref", mainconstants.NodeKubernetesComponentsAnnotationKey: "old-ref",
heirAnnotation: "heir", heirAnnotation: "heir",
}, },
}, },
}, },
@ -667,10 +667,10 @@ func TestGroupNodes(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "heir", Name: "heir",
Annotations: map[string]string{ Annotations: map[string]string{
scalingGroupAnnotation: scalingGroup, scalingGroupAnnotation: scalingGroup,
nodeImageAnnotation: latestImageReference, nodeImageAnnotation: latestImageReference,
mainconstants.NodeKubernetesComponentsHashAnnotationKey: latestK8sComponentsReference, mainconstants.NodeKubernetesComponentsAnnotationKey: latestK8sComponentsReference,
donorAnnotation: "donor", donorAnnotation: "donor",
}, },
}, },
}, },
@ -680,10 +680,10 @@ func TestGroupNodes(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "obsolete", Name: "obsolete",
Annotations: map[string]string{ Annotations: map[string]string{
scalingGroupAnnotation: scalingGroup, scalingGroupAnnotation: scalingGroup,
nodeImageAnnotation: latestImageReference, nodeImageAnnotation: latestImageReference,
mainconstants.NodeKubernetesComponentsHashAnnotationKey: latestK8sComponentsReference, mainconstants.NodeKubernetesComponentsAnnotationKey: latestK8sComponentsReference,
obsoleteAnnotation: "true", obsoleteAnnotation: "true",
}, },
}, },
}, },
@ -694,9 +694,9 @@ func TestGroupNodes(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "mint", Name: "mint",
Annotations: map[string]string{ Annotations: map[string]string{
scalingGroupAnnotation: scalingGroup, scalingGroupAnnotation: scalingGroup,
nodeImageAnnotation: latestImageReference, nodeImageAnnotation: latestImageReference,
mainconstants.NodeKubernetesComponentsHashAnnotationKey: latestK8sComponentsReference, mainconstants.NodeKubernetesComponentsAnnotationKey: latestK8sComponentsReference,
}, },
}, },
}, },