Skip to content

Commit

Permalink
Fix flake in operator-in-operator test (#799)
Browse files Browse the repository at this point in the history
  • Loading branch information
alenkacz authored Sep 12, 2019
1 parent 8c28565 commit 80a9972
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion pkg/controller/instance/instance_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func createPlanAndUpdateReference(c client.Client, r record.EventRecorder, schem

planExecution := newPlanExecution(instance, planName, scheme)
log.Printf("Creating PlanExecution of planExecution %s for instance %s", planName, instance.Name)
r.Event(instance, "Normal", "CreatePlanExecution", fmt.Sprintf("Creating \"%v\" planExecution execution", planName))
r.Event(instance, "Normal", "CreatePlanExecution", fmt.Sprintf("Creating \"%v\" planExecution on %s", planName, instance.Name))

// Make this instance the owner of the PlanExecution
if err := controllerutil.SetControllerReference(instance, planExecution, scheme); err != nil {
Expand Down
40 changes: 22 additions & 18 deletions pkg/controller/planexecution/planexecution_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,26 +165,28 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error {
&handler.EnqueueRequestsFromMapFunc{
ToRequests: handler.ToRequestsFunc(
func(a handler.MapObject) []reconcile.Request {
// instance in instance -> reconcile plan for outer instance
requests := mapToOwningInstanceActivePlan(a)
if len(requests) == 0 {
inst := &kudov1alpha1.Instance{}
err = mgr.GetClient().Get(context.TODO(), client.ObjectKey{
Name: a.Meta.GetName(),
Namespace: a.Meta.GetNamespace(),
}, inst)

if err == nil {
// for every updated/added instance also trigger reconcile for its active plan
requests = append(requests, reconcile.Request{
NamespacedName: types.NamespacedName{
Name: inst.Status.ActivePlan.Name,
Namespace: inst.Status.ActivePlan.Namespace,
},
})
} else {
log.Printf("PlanExecutionController: received event from Instance %s/%s but instance of that name does not exist", a.Meta.GetNamespace(), a.Meta.GetName())
}

// instance in instance -> reconcile plan for inner instance
inst := &kudov1alpha1.Instance{}
err = mgr.GetClient().Get(context.TODO(), client.ObjectKey{
Name: a.Meta.GetName(),
Namespace: a.Meta.GetNamespace(),
}, inst)

if err == nil {
// for every updated/added instance also trigger reconcile for its active plan
requests = append(requests, reconcile.Request{
NamespacedName: types.NamespacedName{
Name: inst.Status.ActivePlan.Name,
Namespace: inst.Status.ActivePlan.Namespace,
},
})
} else {
log.Printf("PlanExecutionController: received event from Instance %s/%s but instance of that name does not exist", a.Meta.GetNamespace(), a.Meta.GetName())
}

return requests
}),
},
Expand Down Expand Up @@ -313,6 +315,8 @@ func (r *ReconcilePlanExecution) Reconcile(request reconcile.Request) (reconcile
return reconcile.Result{}, err
}

log.Printf("Going to execute plan %s on instance %s", planExecution.Name, instance.Name)

// now we're actually starting with the execution of plan/phase/step
for i, phase := range planExecution.Status.Phases {
// If we still want to execute phases in this plan check if phase is healthy
Expand Down

0 comments on commit 80a9972

Please sign in to comment.