diff --git a/internal/constellation/helm/charts/edgeless/operators/charts/constellation-operator/crds/nodeversion-crd.yaml b/internal/constellation/helm/charts/edgeless/operators/charts/constellation-operator/crds/nodeversion-crd.yaml index 4b7f7b7e0..04693de2e 100644 --- a/internal/constellation/helm/charts/edgeless/operators/charts/constellation-operator/crds/nodeversion-crd.yaml +++ b/internal/constellation/helm/charts/edgeless/operators/charts/constellation-operator/crds/nodeversion-crd.yaml @@ -54,6 +54,11 @@ spec: description: KubernetesComponentsReference is a reference to the ConfigMap containing the Kubernetes components to use for all nodes. type: string + maxNodeBudget: + description: MaxNodeBudget is the maximum number of nodes that can + be created simultaneously. + format: int32 + type: integer type: object status: description: NodeVersionStatus defines the observed state of NodeVersion. diff --git a/operators/constellation-node-operator/api/v1alpha1/nodeversion_types.go b/operators/constellation-node-operator/api/v1alpha1/nodeversion_types.go index f5d81dfed..6e741c7d8 100644 --- a/operators/constellation-node-operator/api/v1alpha1/nodeversion_types.go +++ b/operators/constellation-node-operator/api/v1alpha1/nodeversion_types.go @@ -21,6 +21,8 @@ type NodeVersionSpec struct { KubernetesComponentsReference string `json:"kubernetesComponentsReference,omitempty"` // KubernetesClusterVersion is the advertised Kubernetes version of the cluster. KubernetesClusterVersion string `json:"kubernetesClusterVersion,omitempty"` + // MaxNodeBudget is the maximum number of nodes that can be created simultaneously. + MaxNodeBudget uint32 `json:"maxNodeBudget,omitempty"` } // NodeVersionStatus defines the observed state of NodeVersion. diff --git a/operators/constellation-node-operator/config/crd/bases/update.edgeless.systems_nodeversions.yaml b/operators/constellation-node-operator/config/crd/bases/update.edgeless.systems_nodeversions.yaml index 4b7f7b7e0..04693de2e 100644 --- a/operators/constellation-node-operator/config/crd/bases/update.edgeless.systems_nodeversions.yaml +++ b/operators/constellation-node-operator/config/crd/bases/update.edgeless.systems_nodeversions.yaml @@ -54,6 +54,11 @@ spec: description: KubernetesComponentsReference is a reference to the ConfigMap containing the Kubernetes components to use for all nodes. type: string + maxNodeBudget: + description: MaxNodeBudget is the maximum number of nodes that can + be created simultaneously. + format: int32 + type: integer type: object status: description: NodeVersionStatus defines the observed state of NodeVersion. diff --git a/operators/constellation-node-operator/config/manager/kustomization.yaml b/operators/constellation-node-operator/config/manager/kustomization.yaml index 23ff3a7e4..6919d782b 100644 --- a/operators/constellation-node-operator/config/manager/kustomization.yaml +++ b/operators/constellation-node-operator/config/manager/kustomization.yaml @@ -13,4 +13,4 @@ kind: Kustomization images: - name: controller newName: ghcr.io/edgelesssys/constellation/node-operator - newTag: v0.0.0 + newTag: v0.0.1 diff --git a/operators/constellation-node-operator/controllers/nodeversion_controller.go b/operators/constellation-node-operator/controllers/nodeversion_controller.go index fc185b1e2..5bbc9e1ce 100644 --- a/operators/constellation-node-operator/controllers/nodeversion_controller.go +++ b/operators/constellation-node-operator/controllers/nodeversion_controller.go @@ -38,8 +38,6 @@ import ( ) const ( - // nodeOverprovisionLimit is the maximum number of extra nodes created during the update procedure at any point in time. - nodeOverprovisionLimit = 1 // nodeJoinTimeout is the time limit pending nodes have to join the cluster before being terminated. nodeJoinTimeout = time.Minute * 30 // nodeLeaveTimeout is the time limit pending nodes have to leave the cluster and being terminated. @@ -161,9 +159,14 @@ func (r *NodeVersionReconciler) Reconcile(ctx context.Context, req ctrl.Request) // - being created (joining) // - being destroyed (leaving) // - heirs to outdated nodes - extraNodes := len(groups.Heirs) + len(groups.AwaitingAnnotation) + len(pendingNodeList.Items) + extraNodes := uint32(len(groups.Heirs) + len(groups.AwaitingAnnotation) + len(pendingNodeList.Items)) // newNodesBudget is the maximum number of new nodes that can be created in this Reconcile call. - var newNodesBudget int + var newNodesBudget uint32 + nodeOverprovisionLimit := uint32(1) + // Use user definable value if it makes sense + if desiredNodeVersion.Spec.MaxNodeBudget > 0 { + nodeOverprovisionLimit = desiredNodeVersion.Spec.MaxNodeBudget + } if extraNodes < nodeOverprovisionLimit { newNodesBudget = nodeOverprovisionLimit - extraNodes } @@ -743,7 +746,7 @@ func (r *NodeVersionReconciler) tryUpdateStatus(ctx context.Context, name types. } // nodeVersionStatus generates the NodeVersion.Status field given node groups and the budget for new nodes. -func nodeVersionStatus(scheme *runtime.Scheme, groups nodeGroups, pendingNodes []updatev1alpha1.PendingNode, invalidNodes []corev1.Node, newNodesBudget int) updatev1alpha1.NodeVersionStatus { +func nodeVersionStatus(scheme *runtime.Scheme, groups nodeGroups, pendingNodes []updatev1alpha1.PendingNode, invalidNodes []corev1.Node, newNodesBudget uint32) updatev1alpha1.NodeVersionStatus { var status updatev1alpha1.NodeVersionStatus outdatedCondition := metav1.Condition{ Type: updatev1alpha1.ConditionOutdated, @@ -821,7 +824,7 @@ func nodeVersionStatus(scheme *runtime.Scheme, groups nodeGroups, pendingNodes [ } status.Pending = append(status.Pending, *pendingRef) } - status.Budget = uint32(newNodesBudget) + status.Budget = newNodesBudget return status } @@ -941,5 +944,5 @@ type newNodeConfig struct { outdatedNodes []corev1.Node pendingNodes []updatev1alpha1.PendingNode scalingGroupByID map[string]updatev1alpha1.ScalingGroup - newNodesBudget int + newNodesBudget uint32 } diff --git a/operators/constellation-node-operator/controllers/nodeversion_controller_test.go b/operators/constellation-node-operator/controllers/nodeversion_controller_test.go index c9ae88042..e32b99af3 100644 --- a/operators/constellation-node-operator/controllers/nodeversion_controller_test.go +++ b/operators/constellation-node-operator/controllers/nodeversion_controller_test.go @@ -332,7 +332,7 @@ func TestCreateNewNodes(t *testing.T) { outdatedNodes []corev1.Node pendingNodes []updatev1alpha1.PendingNode scalingGroupByID map[string]updatev1alpha1.ScalingGroup - budget int + budget uint32 wantCreateCalls []string }{ "no outdated nodes": {