Skip to content

pkg/ansible: Adding ansible operator runner package#472

Merged
shawn-hurley merged 1 commit into
operator-framework:masterfrom
shawn-hurley:feature/add-AO-runner
Sep 19, 2018
Merged

pkg/ansible: Adding ansible operator runner package#472
shawn-hurley merged 1 commit into
operator-framework:masterfrom
shawn-hurley:feature/add-AO-runner

Conversation

@shawn-hurley
Copy link
Copy Markdown
Member

No description provided.

@shawn-hurley shawn-hurley force-pushed the feature/add-AO-runner branch 2 times, most recently from 52387f8 to f0605d2 Compare September 11, 2018 20:23
@shawn-hurley shawn-hurley changed the title Adding ansible operator runner package pkg/ansible: Adding ansible operator runner package Sep 11, 2018
}
return nil
}
func (r *runner) makeParameters(u *unstructured.Unstructured) map[string]interface{} {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be helpful to have a comment here to explain what the output format for parameters is:

{ "meta": {
        "name": "<cr-name>",
        "namespace": "<cr-namespace>",
  },
 <CR.spec fields>,
  "_<group>_<kind>": {
     <Full CR contents>
   },
}

At least that's what I think it ends up as in the input directory's env/extravars.

Comment thread pkg/ansible/runner/runner.go Outdated

func (r *runner) isFinalizerRun(u *unstructured.Unstructured) bool {
finalizersSet := r.Finalizer != nil && u.GetFinalizers() != nil
// The the resource is deleted and our finalizer is present, we need to run the finalizer
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The resource ...

@hasbro17
Copy link
Copy Markdown
Contributor

LGTM after nits

Comment thread pkg/ansible/proxy/proxy.go Outdated
if req.Method == http.MethodPost {
logrus.Info("injecting owner reference")
dump, _ := httputil.DumpRequest(req, false)
fmt.Println(string(dump))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this supposed to be here? Seems like this should be a debug statement

Comment thread pkg/ansible/proxy/proxy.go Outdated
owner := metav1.OwnerReference{}
json.Unmarshal(authString, &owner)

logrus.Printf("%#+v", owner)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also seems like a debug statement.

Comment thread pkg/ansible/proxy/proxy.go Outdated
http.Error(w, m, http.StatusInternalServerError)
return
}
logrus.Printf(string(newBody))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Copy link
Copy Markdown
Contributor

@dymurray dymurray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only had some small nits. Everything else looks sane to me.

@shawn-hurley shawn-hurley force-pushed the feature/add-AO-runner branch 2 times, most recently from ac18a89 to 249e4cb Compare September 18, 2018 13:04
Comment thread pkg/ansible/runner/eventapi/eventapi.go Outdated
}

func (e *EventReceiver) handleEvents(w http.ResponseWriter, r *http.Request) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to have extra line here.

"code": "410",
}).Info("stopped and not accepting additional events for this job")
return
} else {
Copy link
Copy Markdown
Contributor

@fanminshi fanminshi Sep 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is else statement here necessary? since the previous if condition returns.

return err
}

if i.PlaybookPath != "" {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we change to

if i.PlaybookPath == "" {
 return nil
}

...

I think the code has less nested if statement which makes the code cleaner.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be a little cleaner but

  1. the nested if's are for error checking not logic. I would suggest that this is not that big of a concern.
  2. I think it is more clear, do X if PlaybookPath is set, rather than, if PlaybookPath is unset return and always do X. The first is more accurate to what we want rather than the second.

Thoughts?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair enough. let's keep as it is.

@fanminshi
Copy link
Copy Markdown
Contributor

lgtm

@shawn-hurley shawn-hurley merged commit fa3bbbd into operator-framework:master Sep 19, 2018
hasbro17 pushed a commit to hasbro17/operator-sdk that referenced this pull request Oct 3, 2018
hasbro17 added a commit that referenced this pull request Oct 4, 2018
#566)

* pkg/ansible: Adding paramconv and kubeconfig to ansible operator. (#471)

* Adding runner package. (#472)

* pkg/ansible: Adding ansible operator controller and events package (#473)

* make ansible task log outputs more readable (#545)
shawn-hurley pushed a commit to shawn-hurley/operator-sdk that referenced this pull request Oct 12, 2018
operator-framework#566)

* pkg/ansible: Adding paramconv and kubeconfig to ansible operator. (operator-framework#471)

* Adding runner package. (operator-framework#472)

* pkg/ansible: Adding ansible operator controller and events package (operator-framework#473)

* make ansible task log outputs more readable (operator-framework#545)
shawn-hurley pushed a commit that referenced this pull request Oct 16, 2018
#566)

* pkg/ansible: Adding paramconv and kubeconfig to ansible operator. (#471)

* Adding runner package. (#472)

* pkg/ansible: Adding ansible operator controller and events package (#473)

* make ansible task log outputs more readable (#545)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants