Skip to content

Commit 3af34aa

Browse files
Support pause rollout
1 parent 699c054 commit 3af34aa

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

controllers/function_controller.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@ func (r *FunctionReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
9999
function.Status.Conditions = make(map[v1alpha1.Component]v1alpha1.ResourceCondition)
100100
}
101101

102+
isNewGeneration := r.checkIfFunctionGenerationsIsIncreased(function)
103+
104+
// skip reconcile if pauseRollout is set to true and the generation is not increased
105+
if spec.IsPauseRollout(function) && !isNewGeneration {
106+
return ctrl.Result{}, nil
107+
}
108+
102109
err = r.ObserveFunctionStatefulSet(ctx, function)
103110
if err != nil {
104111
return reconcile.Result{}, err
@@ -130,8 +137,6 @@ func (r *FunctionReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
130137
return ctrl.Result{}, err
131138
}
132139

133-
isNewGeneration := r.checkIfFunctionGenerationsIsIncreased(function)
134-
135140
err = r.ApplyFunctionStatefulSet(ctx, function, isNewGeneration)
136141
if err != nil {
137142
return reconcile.Result{}, err

controllers/sink_controller.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ func (r *SinkReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
9898
sink.Status.Conditions = make(map[v1alpha1.Component]v1alpha1.ResourceCondition)
9999
}
100100

101+
isNewGeneration := r.checkIfSinkGenerationsIsIncreased(sink)
102+
103+
// skip reconcile if pauseRollout is set to true and the generation is not increased
104+
if spec.IsPauseRollout(sink) && !isNewGeneration {
105+
return ctrl.Result{}, nil
106+
}
107+
101108
err = r.ObserveSinkStatefulSet(ctx, sink)
102109
if err != nil {
103110
return reconcile.Result{}, err
@@ -129,8 +136,6 @@ func (r *SinkReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
129136
return ctrl.Result{}, err
130137
}
131138

132-
isNewGeneration := r.checkIfSinkGenerationsIsIncreased(sink)
133-
134139
err = r.ApplySinkStatefulSet(ctx, sink, isNewGeneration)
135140
if err != nil {
136141
return reconcile.Result{}, err

controllers/source_controller.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ func (r *SourceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
9898
source.Status.Conditions = make(map[v1alpha1.Component]v1alpha1.ResourceCondition)
9999
}
100100

101+
isNewGeneration := r.checkIfSourceGenerationsIsIncreased(source)
102+
103+
// skip reconcile if pauseRollout is set to true and the generation is not increased
104+
if spec.IsPauseRollout(source) && !isNewGeneration {
105+
return ctrl.Result{}, nil
106+
}
107+
101108
err = r.ObserveSourceStatefulSet(ctx, source)
102109
if err != nil {
103110
return reconcile.Result{}, err
@@ -129,8 +136,6 @@ func (r *SourceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
129136
return ctrl.Result{}, err
130137
}
131138

132-
isNewGeneration := r.checkIfSourceGenerationsIsIncreased(source)
133-
134139
err = r.ApplySourceStatefulSet(ctx, source, isNewGeneration)
135140
if err != nil {
136141
return reconcile.Result{}, err

controllers/spec/common.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ const (
9999
AnnotationPrometheusScrape = "prometheus.io/scrape"
100100
AnnotationPrometheusPort = "prometheus.io/port"
101101
AnnotationManaged = "compute.functionmesh.io/managed"
102+
AnnotationPauseRollout = "compute.functionmesh.io/pause-rollout"
102103
AnnotationNeedCleanup = "compute.functionmesh.io/need-cleanup"
103104

104105
// if labels contains below, we think it comes from function-mesh-worker-service
@@ -171,6 +172,11 @@ func IsManaged(object metav1.Object) bool {
171172
return !exists || managed != "false"
172173
}
173174

175+
func IsPauseRollout(object metav1.Object) bool {
176+
pauseRollout, exists := object.GetAnnotations()[AnnotationPauseRollout]
177+
return exists && pauseRollout == "true"
178+
}
179+
174180
func NeedCleanup(object metav1.Object) bool {
175181
// don't cleanup if it's managed by function-mesh-worker-service
176182
_, exists := object.GetLabels()[LabelPulsarCluster]

0 commit comments

Comments
 (0)