Skip to content

Commit

Permalink
Improve log messages in controller (#591)
Browse files Browse the repository at this point in the history
  • Loading branch information
alenkacz committed Jul 19, 2019
1 parent 8fa68ef commit ea2ea7c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pkg/controller/planexecution/planexecution_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ func (r *ReconcilePlanExecution) Reconcile(request reconcile.Request) (reconcile
err := r.Client.Get(context.TODO(), key, truth)
rawObj, _ := apijson.Marshal(obj)
if err == nil {
log.Printf("PlanExecutionController: CreateOrUpdate Object present")
log.Printf("PlanExecutionController: Object %v already exists for instance %v, going to apply patch", key, instance.Name)
//update
log.Printf("Going to apply patch\n%+v\n\n to object\n%s\n", string(rawObj), prettyPrint(truth))
if err != nil {
Expand All @@ -464,18 +464,20 @@ func (r *ReconcilePlanExecution) Reconcile(request reconcile.Request) (reconcile
if errors.IsUnsupportedMediaType(err) {
err = r.Client.Patch(context.TODO(), truth, client.ConstantPatch(types.MergePatchType, rawObj))
if err != nil {
log.Printf("PlanExecutionController: CreateOrUpdate MergePatch: %v", err)
log.Printf("PlanExecutionController: Error when applying merge patch to object %v for instance %v: %v", key, instance.Name, err)
}
} else {
log.Printf("PlanExecutionController: CreateOrUpdate StrategicMergePatch: Unknown Error: %v", err)
log.Printf("PlanExecutionController: Error when applying StrategicMergePatch to object %v for instance %v: %v", key, instance.Name, err)
}
}
}
} else {
//create
log.Println("PlanExecutionController: CreateOrUpdate Object not present")
log.Printf("PlanExecutionController: Object %v does not exist, going to create new object for instance %v", key, instance.Name)
err = r.Client.Create(context.TODO(), obj)
log.Printf("PlanExecutionController: CreateOrUpdate Create: %v", err)
if err != nil {
log.Printf("PlanExecutionController: Error when creating object %v: %v", key, err)
}
}

if err != nil {
Expand Down

0 comments on commit ea2ea7c

Please sign in to comment.