Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/ansible - update status to include failure message on the status. #639

Merged

Conversation

shawn-hurley
Copy link
Member

Description of the change:
Updates the ansible operator status to align better conventions

Motivation for the change:

  • Adding failure message to the user to see why the operator was unable to complete
  • Better align base operator to fit in with the conventions.

@@ -21,12 +21,14 @@ import (
"os"
"time"

ansiblestatus "github.com/operator-framework/operator-sdk/pkg/ansible/controller/status"
Copy link
Member Author

Choose a reason for hiding this comment

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

This name is not super great but status seems to be overused.

@shawn-hurley shawn-hurley changed the title [WIP] pkg/ansible - update status to include failure message on the status. pkg/ansible - update status to include failure message on the status. Oct 18, 2018
@shawn-hurley shawn-hurley added the language/ansible Issue is related to an Ansible operator project label Oct 18, 2018
Copy link
Member

@mhrivnak mhrivnak left a comment

Choose a reason for hiding this comment

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

I'm interested in thinking about how to re-organize the status module to better use namespaces, so we don't end up doing things like:

status := ansiblestatus.NewAnsibleStatusFromStatusJobEvent(...)

I had to type "ansible" twice and "status" an impressive four times. :)

Also, the difference between a Status and an AnsibleStatus could be a little confusing, and it certainly contributes to the naming ambiguity. Maybe there's another way. But for the moment I'll need to sleep on it and take a second look tomorrow.

pkg/ansible/controller/reconcile.go Outdated Show resolved Hide resolved
pkg/ansible/controller/status/types.go Outdated Show resolved Hide resolved
pkg/ansible/controller/status/types.go Outdated Show resolved Hide resolved
pkg/ansible/controller/status/utils.go Outdated Show resolved Hide resolved
pkg/ansible/controller/status/utils.go Outdated Show resolved Hide resolved
}

// GetCondition returns the condition with the provided type.
func GetCondition(status Status, condType ConditionType) *Condition {
Copy link
Member

Choose a reason for hiding this comment

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

What do you think of making this, plus Set and Remove below, methods on Status?

Copy link
Contributor

Choose a reason for hiding this comment

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

Upstream generally avoids adding methods to the API types, so I think it's generally preferable to use functions. Plus, everything they're messing with is public, so there's not really a reason for it to be a method.

pkg/ansible/runner/eventapi/types.go Outdated Show resolved Hide resolved
pkg/ansible/runner/eventapi/types.go Outdated Show resolved Hide resolved
pkg/ansible/runner/eventapi/types.go Outdated Show resolved Hide resolved
pkg/ansible/runner/eventapi/types.go Outdated Show resolved Hide resolved
@openshift-ci-robot openshift-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Oct 26, 2018
logrus.Debugf("status was not found")
u.Object["status"] = map[string]interface{}{}
statusInterface := u.Object["status"]
statusMap, _ := statusInterface.(map[string]interface{})
Copy link
Contributor

@hasbro17 hasbro17 Oct 28, 2018

Choose a reason for hiding this comment

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

We no longer need to check if Object["status"] exists or is of type map[string]interface{}?

Copy link
Member Author

Choose a reason for hiding this comment

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

The below func CreateFromMap will check this and handle the edge cases.

v1.ConditionTrue,
ansibleStatus,
ansiblestatus.SuccessfulReason,
ansiblestatus.SuccessfulMessage,
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be useful to record what you did to some degree in the message? Or perhaps you just want that to be in the logs/events?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was thinking that events would be more useful for this.

@shawn-hurley shawn-hurley merged commit 160aafe into operator-framework:master Nov 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language/ansible Issue is related to an Ansible operator project size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants