Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Shawn Hurley committed Feb 1, 2019
1 parent e6f706c commit 214585b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
3 changes: 3 additions & 0 deletions pkg/ansible/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ func Add(mgr manager.Manager, options Options) *controller.Controller {
Writer: mgr.GetClient(),
StatusClient: mgr.GetClient(),
},
// This works because unstrucutred calls will go to the
// API by default.
APIReader: mgr.GetClient(),
GVK: options.GVK,
Runner: options.Runner,
EventHandlers: eventHandlers,
Expand Down
20 changes: 2 additions & 18 deletions pkg/ansible/controller/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type AnsibleOperatorReconciler struct {
GVK schema.GroupVersionKind
Runner runner.Runner
Client client.Client
APIReader client.Reader
EventHandlers []events.EventHandler
ReconcilePeriod time.Duration
ManageStatus bool
Expand Down Expand Up @@ -176,7 +177,7 @@ func (r *AnsibleOperatorReconciler) Reconcile(request reconcile.Request) (reconc
return reconcileResult, eventErr
}

err = r.Client.Get(context.TODO(), request.NamespacedName, u)
err = r.APIReader.Get(context.TODO(), request.NamespacedName, u)
if err != nil {
return reconcile.Result{}, err
}
Expand Down Expand Up @@ -209,12 +210,6 @@ func (r *AnsibleOperatorReconciler) Reconcile(request reconcile.Request) (reconc

func (r *AnsibleOperatorReconciler) markRunning(u *unstructured.Unstructured, namespacedName types.NamespacedName) error {
// Get the latest resource to prevent updating a stale status
/*
err := r.Client.Get(context.TODO(), namespacedName, u)
if err != nil {
return err
}
*/
statusInterface := u.Object["status"]
statusMap, _ := statusInterface.(map[string]interface{})
crStatus := ansiblestatus.CreateFromMap(statusMap)
Expand Down Expand Up @@ -245,17 +240,6 @@ func (r *AnsibleOperatorReconciler) markRunning(u *unstructured.Unstructured, na
}

func (r *AnsibleOperatorReconciler) markDone(u *unstructured.Unstructured, namespacedName types.NamespacedName, statusEvent eventapi.StatusJobEvent, failureMessages eventapi.FailureMessages) error {
/*
// Get the latest resource to prevent updating a stale status
err := r.Client.Get(context.TODO(), namespacedName, u)
if apierrors.IsNotFound(err) {
logger.Info("Resource not found, assuming it was deleted", err)
return nil
}
if err != nil {
return err
}
*/
statusInterface := u.Object["status"]
statusMap, _ := statusInterface.(map[string]interface{})
crStatus := ansiblestatus.CreateFromMap(statusMap)
Expand Down

0 comments on commit 214585b

Please sign in to comment.