forked from keptn/lifecycle-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(lifecycle-operator): implement promotion task (keptn#3057)
Signed-off-by: Florian Bacher <[email protected]>
- Loading branch information
Showing
15 changed files
with
366 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
lifecycle-operator/controllers/lifecycle/interfaces/fake/phaseitem_mock.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,13 +52,14 @@ const traceComponentName = "keptn/lifecycle-operator/appversion" | |
type KeptnAppVersionReconciler struct { | ||
Scheme *runtime.Scheme | ||
client.Client | ||
Log logr.Logger | ||
EventSender eventsender.IEvent | ||
TracerFactory telemetry.TracerFactory | ||
Meters apicommon.KeptnMeters | ||
SpanHandler telemetry.ISpanHandler | ||
EvaluationHandler evaluation.IEvaluationHandler | ||
PhaseHandler phase.IHandler | ||
Log logr.Logger | ||
EventSender eventsender.IEvent | ||
TracerFactory telemetry.TracerFactory | ||
Meters apicommon.KeptnMeters | ||
SpanHandler telemetry.ISpanHandler | ||
EvaluationHandler evaluation.IEvaluationHandler | ||
PhaseHandler phase.IHandler | ||
PromotionTasksEnabled bool | ||
} | ||
|
||
// +kubebuilder:rbac:groups=lifecycle.keptn.sh,resources=keptnappversions,verbs=get;list;watch;create;update;patch;delete | ||
|
@@ -76,7 +77,7 @@ type KeptnAppVersionReconciler struct { | |
// For more details, check Reconcile and its Result here: | ||
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile | ||
// | ||
//nolint:gocyclo | ||
//nolint:gocyclo,gocognit | ||
func (r *KeptnAppVersionReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { | ||
requestInfo := controllercommon.GetRequestInfo(req) | ||
r.Log.Info("Searching for Keptn App Version", "requestInfo", requestInfo) | ||
|
@@ -114,7 +115,7 @@ func (r *KeptnAppVersionReconciler) Reconcile(ctx context.Context, req ctrl.Requ | |
|
||
if !appVersion.IsPreDeploymentSucceeded() { | ||
reconcilePreDep := func(phaseCtx context.Context) (apicommon.KeptnState, error) { | ||
return r.reconcilePrePostDeployment(ctx, phaseCtx, appVersion, apicommon.PreDeploymentCheckType) | ||
return r.reconcilePhase(ctx, phaseCtx, appVersion, apicommon.PreDeploymentCheckType) | ||
} | ||
result, err := r.PhaseHandler.HandlePhase(ctx, ctxAppTrace, r.getTracer(), appVersion, currentPhase, reconcilePreDep) | ||
if !result.Continue { | ||
|
@@ -147,7 +148,7 @@ func (r *KeptnAppVersionReconciler) Reconcile(ctx context.Context, req ctrl.Requ | |
currentPhase = apicommon.PhaseAppPostDeployment | ||
if !appVersion.IsPostDeploymentSucceeded() { | ||
reconcilePostDep := func(phaseCtx context.Context) (apicommon.KeptnState, error) { | ||
return r.reconcilePrePostDeployment(ctx, phaseCtx, appVersion, apicommon.PostDeploymentCheckType) | ||
return r.reconcilePhase(ctx, phaseCtx, appVersion, apicommon.PostDeploymentCheckType) | ||
} | ||
result, err := r.PhaseHandler.HandlePhase(ctx, ctxAppTrace, r.getTracer(), appVersion, currentPhase, reconcilePostDep) | ||
if !result.Continue { | ||
|
@@ -166,6 +167,17 @@ func (r *KeptnAppVersionReconciler) Reconcile(ctx context.Context, req ctrl.Requ | |
} | ||
} | ||
|
||
if r.PromotionTasksEnabled && !appVersion.IsPromotionCompleted() { | ||
currentPhase = apicommon.PhasePromotion | ||
reconcilePromotionFunc := func(phaseCtx context.Context) (apicommon.KeptnState, error) { | ||
return r.reconcilePhase(ctx, phaseCtx, appVersion, apicommon.PromotionCheckType) | ||
} | ||
result, err := r.PhaseHandler.HandlePhase(ctx, ctxAppTrace, r.getTracer(), appVersion, currentPhase, reconcilePromotionFunc) | ||
if !result.Continue { | ||
return result.Result, err | ||
} | ||
} | ||
|
||
// AppVersion is completed at this place | ||
return r.finishKeptnAppVersionReconcile(ctx, appVersion, spanAppTrace) | ||
} | ||
|
Oops, something went wrong.