mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-01-13 00:19:32 -05:00
operator: use mainconstants
This commit is contained in:
parent
94694c6e06
commit
01e870c83a
@ -10,6 +10,7 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
mainconstants "github.com/edgelesssys/constellation/v2/internal/constants"
|
||||
updatev1alpha1 "github.com/edgelesssys/constellation/v2/operators/constellation-node-operator/v2/api/v1alpha1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
@ -26,9 +27,6 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
// NodeKubernetesComponentsReferenceAnnotationKey is the name of the annotation holding the reference to the ConfigMap listing all K8s components.
|
||||
NodeKubernetesComponentsReferenceAnnotationKey = "constellation.edgeless.systems/kubernetes-components"
|
||||
|
||||
joiningNodeNameKey = ".spec.name"
|
||||
)
|
||||
|
||||
@ -76,7 +74,7 @@ func (r *JoiningNodesReconciler) Reconcile(ctx context.Context, req ctrl.Request
|
||||
if node.Annotations == nil {
|
||||
node.Annotations = map[string]string{}
|
||||
}
|
||||
node.Annotations[NodeKubernetesComponentsReferenceAnnotationKey] = joiningNode.Spec.ComponentsReference
|
||||
node.Annotations[mainconstants.NodeKubernetesComponentsHashAnnotationKey] = joiningNode.Spec.ComponentsReference
|
||||
return r.Update(ctx, &node)
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -18,6 +18,7 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
|
||||
mainconstants "github.com/edgelesssys/constellation/v2/internal/constants"
|
||||
updatev1alpha1 "github.com/edgelesssys/constellation/v2/operators/constellation-node-operator/v2/api/v1alpha1"
|
||||
)
|
||||
|
||||
@ -80,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[NodeKubernetesComponentsReferenceAnnotationKey]
|
||||
return createdNode.Annotations[mainconstants.NodeKubernetesComponentsHashAnnotationKey]
|
||||
}, timeout, interval).Should(Equal(ComponentsReference1))
|
||||
|
||||
By("deleting the joining node resource")
|
||||
@ -134,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[NodeKubernetesComponentsReferenceAnnotationKey]
|
||||
return createdNode.Annotations[mainconstants.NodeKubernetesComponentsHashAnnotationKey]
|
||||
}, timeout, interval).Should(Equal(ComponentsReference2))
|
||||
|
||||
By("deleting the joining node resource")
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
mainconstants "github.com/edgelesssys/constellation/v2/internal/constants"
|
||||
nodeutil "github.com/edgelesssys/constellation/v2/operators/constellation-node-operator/v2/internal/node"
|
||||
"github.com/edgelesssys/constellation/v2/operators/constellation-node-operator/v2/internal/patch"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
@ -776,7 +777,7 @@ func groupNodes(nodes []corev1.Node, pendingNodes []updatev1alpha1.PendingNode,
|
||||
continue
|
||||
}
|
||||
if !strings.EqualFold(node.Annotations[nodeImageAnnotation], latestImageReference) ||
|
||||
!strings.EqualFold(node.Annotations[NodeKubernetesComponentsReferenceAnnotationKey], latestK8sComponentsReference) {
|
||||
!strings.EqualFold(node.Annotations[mainconstants.NodeKubernetesComponentsHashAnnotationKey], latestK8sComponentsReference) {
|
||||
if heir := node.Annotations[heirAnnotation]; heir != "" {
|
||||
groups.Donors = append(groups.Donors, node)
|
||||
} else {
|
||||
|
@ -18,6 +18,7 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
|
||||
mainconstants "github.com/edgelesssys/constellation/v2/internal/constants"
|
||||
updatev1alpha1 "github.com/edgelesssys/constellation/v2/operators/constellation-node-operator/v2/api/v1alpha1"
|
||||
)
|
||||
|
||||
@ -608,9 +609,9 @@ func TestGroupNodes(t *testing.T) {
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "outdated",
|
||||
Annotations: map[string]string{
|
||||
scalingGroupAnnotation: scalingGroup,
|
||||
NodeKubernetesComponentsReferenceAnnotationKey: latestK8sComponentsReference,
|
||||
nodeImageAnnotation: "old-image",
|
||||
scalingGroupAnnotation: scalingGroup,
|
||||
mainconstants.NodeKubernetesComponentsHashAnnotationKey: latestK8sComponentsReference,
|
||||
nodeImageAnnotation: "old-image",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -618,9 +619,9 @@ func TestGroupNodes(t *testing.T) {
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "outdated",
|
||||
Annotations: map[string]string{
|
||||
scalingGroupAnnotation: scalingGroup,
|
||||
NodeKubernetesComponentsReferenceAnnotationKey: "old-ref",
|
||||
nodeImageAnnotation: latestImageReference,
|
||||
scalingGroupAnnotation: scalingGroup,
|
||||
mainconstants.NodeKubernetesComponentsHashAnnotationKey: "old-ref",
|
||||
nodeImageAnnotation: latestImageReference,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -630,9 +631,9 @@ func TestGroupNodes(t *testing.T) {
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "uptodate",
|
||||
Annotations: map[string]string{
|
||||
scalingGroupAnnotation: scalingGroup,
|
||||
nodeImageAnnotation: latestImageReference,
|
||||
NodeKubernetesComponentsReferenceAnnotationKey: latestK8sComponentsReference,
|
||||
scalingGroupAnnotation: scalingGroup,
|
||||
nodeImageAnnotation: latestImageReference,
|
||||
mainconstants.NodeKubernetesComponentsHashAnnotationKey: latestK8sComponentsReference,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -642,10 +643,10 @@ func TestGroupNodes(t *testing.T) {
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "donor",
|
||||
Annotations: map[string]string{
|
||||
scalingGroupAnnotation: scalingGroup,
|
||||
nodeImageAnnotation: "old-image",
|
||||
NodeKubernetesComponentsReferenceAnnotationKey: latestK8sComponentsReference,
|
||||
heirAnnotation: "heir",
|
||||
scalingGroupAnnotation: scalingGroup,
|
||||
nodeImageAnnotation: "old-image",
|
||||
mainconstants.NodeKubernetesComponentsHashAnnotationKey: latestK8sComponentsReference,
|
||||
heirAnnotation: "heir",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -653,10 +654,10 @@ func TestGroupNodes(t *testing.T) {
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "donor",
|
||||
Annotations: map[string]string{
|
||||
scalingGroupAnnotation: scalingGroup,
|
||||
nodeImageAnnotation: latestImageReference,
|
||||
NodeKubernetesComponentsReferenceAnnotationKey: "old-ref",
|
||||
heirAnnotation: "heir",
|
||||
scalingGroupAnnotation: scalingGroup,
|
||||
nodeImageAnnotation: latestImageReference,
|
||||
mainconstants.NodeKubernetesComponentsHashAnnotationKey: "old-ref",
|
||||
heirAnnotation: "heir",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -666,10 +667,10 @@ func TestGroupNodes(t *testing.T) {
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "heir",
|
||||
Annotations: map[string]string{
|
||||
scalingGroupAnnotation: scalingGroup,
|
||||
nodeImageAnnotation: latestImageReference,
|
||||
NodeKubernetesComponentsReferenceAnnotationKey: latestK8sComponentsReference,
|
||||
donorAnnotation: "donor",
|
||||
scalingGroupAnnotation: scalingGroup,
|
||||
nodeImageAnnotation: latestImageReference,
|
||||
mainconstants.NodeKubernetesComponentsHashAnnotationKey: latestK8sComponentsReference,
|
||||
donorAnnotation: "donor",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -679,10 +680,10 @@ func TestGroupNodes(t *testing.T) {
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "obsolete",
|
||||
Annotations: map[string]string{
|
||||
scalingGroupAnnotation: scalingGroup,
|
||||
nodeImageAnnotation: latestImageReference,
|
||||
NodeKubernetesComponentsReferenceAnnotationKey: latestK8sComponentsReference,
|
||||
obsoleteAnnotation: "true",
|
||||
scalingGroupAnnotation: scalingGroup,
|
||||
nodeImageAnnotation: latestImageReference,
|
||||
mainconstants.NodeKubernetesComponentsHashAnnotationKey: latestK8sComponentsReference,
|
||||
obsoleteAnnotation: "true",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -693,9 +694,9 @@ func TestGroupNodes(t *testing.T) {
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "mint",
|
||||
Annotations: map[string]string{
|
||||
scalingGroupAnnotation: scalingGroup,
|
||||
nodeImageAnnotation: latestImageReference,
|
||||
NodeKubernetesComponentsReferenceAnnotationKey: latestK8sComponentsReference,
|
||||
scalingGroupAnnotation: scalingGroup,
|
||||
nodeImageAnnotation: latestImageReference,
|
||||
mainconstants.NodeKubernetesComponentsHashAnnotationKey: latestK8sComponentsReference,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user