Skip to content

Commit

Permalink
atlas/schema: handle no plans case
Browse files Browse the repository at this point in the history
  • Loading branch information
giautm committed Nov 24, 2024
1 parent 2fb4209 commit 5327b34
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions internal/controller/atlasschema_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,15 @@ func (r *AtlasSchemaReconciler) Reconcile(ctx context.Context, req ctrl.Request)
To: []string{desiredURL},
Pending: true,
})
if err != nil {
switch {
case err != nil && strings.Contains(err.Error(), "no changes to be made"):
res.SetReady(dbv1alpha1.AtlasSchemaStatus{
LastApplied: time.Now().Unix(),
ObservedHash: hash,
}, nil)
r.recorder.Event(res, corev1.EventTypeNormal, "Applied", "Applied schema")
return ctrl.Result{}, nil
case err != nil:
reason, msg := "SchemaPlan", err.Error()
res.SetNotReady(reason, msg)
r.recorder.Event(res, corev1.EventTypeWarning, reason, msg)
Expand All @@ -281,14 +289,15 @@ func (r *AtlasSchemaReconciler) Reconcile(ctx context.Context, req ctrl.Request)
}
r.recordErrEvent(res, err)
return result(err)
default:
log.Info("created a new schema plan", "plan", plan.File.URL, "desiredURL", desiredURL)
res.Status.PlanURL = plan.File.URL
res.Status.PlanLink = plan.File.Link
reason, msg := "ApprovalPending", "Schema plan is waiting for approval"
res.SetNotReady(reason, msg)
r.recorder.Event(res, corev1.EventTypeNormal, reason, msg)
return ctrl.Result{RequeueAfter: time.Second * 5}, nil
}
log.Info("created a new schema plan", "plan", plan.File.URL, "desiredURL", desiredURL)
res.Status.PlanURL = plan.File.URL
res.Status.PlanLink = plan.File.Link
reason, msg := "ApprovalPending", "Schema plan is waiting for approval"
res.SetNotReady(reason, msg)
r.recorder.Event(res, corev1.EventTypeNormal, reason, msg)
return ctrl.Result{RequeueAfter: time.Second * 5}, nil
}
// List the schema plans to check if there are any plans.
switch plans, err := cli.SchemaPlanList(ctx, &atlasexec.SchemaPlanListParams{
Expand Down

0 comments on commit 5327b34

Please sign in to comment.