diff --git a/pkg/apis/upgrade.cattle.io/v1/types.go b/pkg/apis/upgrade.cattle.io/v1/types.go index 3df0e57e..84ea9345 100644 --- a/pkg/apis/upgrade.cattle.io/v1/types.go +++ b/pkg/apis/upgrade.cattle.io/v1/types.go @@ -44,6 +44,7 @@ type PlanSpec struct { Prepare *ContainerSpec `json:"prepare,omitempty"` Cordon bool `json:"cordon,omitempty"` Drain *DrainSpec `json:"drain,omitempty"` + Label *LabelSpec `json:"label,omitempty"` Upgrade *ContainerSpec `json:"upgrade,omitempty" wrangler:"required"` } @@ -80,3 +81,9 @@ type SecretSpec struct { Name string `json:"name,omitempty"` Path string `json:"path,omitempty"` } + +// LabelSpec specifies which label should be added to the node after update. +type LabelSpec struct { + Key string `json:"key,omitempty"` + Value string `json:"value,omitempty"` +} diff --git a/pkg/upgrade/handle_batch.go b/pkg/upgrade/handle_batch.go index 78c81bfc..e5f8909e 100644 --- a/pkg/upgrade/handle_batch.go +++ b/pkg/upgrade/handle_batch.go @@ -95,6 +95,15 @@ func (ctl *Controller) handleJobs(ctx context.Context) error { } return obj, enqueueOrDelete(jobs, obj, upgradejob.ConditionComplete) } + + // label the node after the update + if plan.Spec.Label != nil { + node.ObjectMeta.Labels[plan.Spec.Label.Key] = plan.Spec.Label.Value + if _, err := ctl.kcs.CoreV1().Nodes().Update(ctx, node, metav1.UpdateOptions{}); err != nil { + return obj, err + } + } + // if the job is hasn't failed or completed but the job Node is not on the applying list, consider it running out-of-turn and delete it if i := sort.SearchStrings(plan.Status.Applying, nodeName); i == len(plan.Status.Applying) || (i < len(plan.Status.Applying) && plan.Status.Applying[i] != nodeName) {