Skip to content

Commit

Permalink
[feature]Replace update (#147)
Browse files Browse the repository at this point in the history
* [feat] add pod update policy: replaceUpdate  in collaset

* add unit test, and revert revisionManager change.

* fix: update by cr.
1. use replace new id instead of new pod name
2. allocate id when replaceUpdate needed.
3. judge whether pod need update based on whether it is in the "replace" state.

* add implemention of revision.IsInUsed

* change check label value with exist instead of =

* in replaceUpdate policy, origin pod do not go through opslifecycle

* [feat]trigger pod replace by specifying a to-replace label. combine the process of creating pod and delete pod in replace update and specify pod replace

* add unit test

* modify as cr. and add test case for collaset_controller

* remove golint sh

* change Chinese comment to English

* Correct label key typo
  • Loading branch information
dbug-dk committed Mar 11, 2024
1 parent d146ad4 commit 5eae342
Show file tree
Hide file tree
Showing 10 changed files with 1,092 additions and 106 deletions.
4 changes: 4 additions & 0 deletions apis/apps/v1alpha1/collaset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ const (
// CollaSetInPlaceOnlyPodUpdateStrategyType indicates that CollaSet will always update Pod in-place, instead of
// recreating pod. It will encounter an error on original Kubernetes cluster.
CollaSetInPlaceOnlyPodUpdateStrategyType PodUpdateStrategyType = "InPlaceOnly"

// CollaSetReplaceUpdatePodUpdateStrategyType indicates that CollaSet will always update Pod by replace, it will
// create a new Pod and delete update pod when new created pod service available.
CollaSetReplaceUpdatePodUpdateStrategyType PodUpdateStrategyType = "ReplaceUpdate"
)

// CollaSetSpec defines the desired state of CollaSet
Expand Down
10 changes: 8 additions & 2 deletions apis/apps/v1alpha1/well_known_labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,16 @@ const (
PodPostCheckedLabelPrefix = "post-checked.podopslifecycle.kusionstack.io" // indicate a pod has finished post-check phase
PodCompletingLabelPrefix = "completing.podopslifecycle.kusionstack.io" // indicate a pod is completing operation

PodServiceAvailableLabel = "podopslifecycle.kusionstack.io/service-available" // indicate a pod is available to serve
PodDeletionIndicationLabelKey = "podopslifecycle.kusionstack.io/to-delete" // users can use this label to indicate a pod to delete
PodServiceAvailableLabel = "podopslifecycle.kusionstack.io/service-available" // indicate a pod is available to serve
PodDeletionIndicationLabelKey = "podopslifecycle.kusionstack.io/to-delete" // users can use this label to indicate a pod to delete
PodReplaceIndicationLabelKey = "podopslifecycle.kusionstack.io/to-replace" // users can use this label to indicate a pod to replace
PodReplaceByReplaceUpdateLabelKey = "podopslifecycle.kusionstack.io/replaced-by-replace-update"

PodInstanceIDLabelKey = "collaset.kusionstack.io/instance-id" // used to attach Pod instance ID on Pod

PodReplacePairOriginName = "collaset.kusionstack.io/replace-pair-origin-name" // used to indicate the original Pod name for replacement.

PodReplacePairNewId = "collaset.kusionstack.io/replace-pair-new-id" // used to indicate the new created Pod instance ID for replacement.
)

const (
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/collaset/collaset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (r *CollaSetReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
return ctrl.Result{}, err
} else if !satisfied {
logger.Info("CollaSet is not satisfied to reconcile")
return ctrl.Result{}, nil
return ctrl.Result{RequeueAfter: 30 * time.Second}, nil
}

if instance.DeletionTimestamp != nil {
Expand Down
Loading

0 comments on commit 5eae342

Please sign in to comment.