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

Bug 1566924 - renaming crd resources #907

Merged
merged 12 commits into from Apr 27, 2018

Conversation

shawn-hurley
Copy link
Contributor

Describe what this PR does and why we need it:

Changes proposed in this pull request

  • removes job state CRD
  • Moves state to Bundle Instance and Bundle Binding

Does this PR depend on another PR (Use this to track when PRs should be merged)

depends-on

Which issue this PR fixes (This will close that issue when PR gets merged)

fixes <issue_number>

@shawn-hurley shawn-hurley requested review from eriknelson, jmrodri and rthallisey and removed request for eriknelson and jmrodri April 25, 2018 18:36
@openshift-ci-robot openshift-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Apr 25, 2018
@shawn-hurley shawn-hurley added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 25, 2018
@shawn-hurley shawn-hurley added bug needs-review and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Apr 26, 2018
@shawn-hurley
Copy link
Contributor Author

@jmrodri @eriknelson This appears to be failing due to config changes between automationbroker-apb and the image created from this PR. Feels like the first time that the APB is hitting this problem.

Copy link
Contributor

@eriknelson eriknelson left a comment

Choose a reason for hiding this comment

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

Some Qs

}

// GetBindInstance - Retrieve a specific bind instance from the kvp API
func (d *Dao) GetBindInstance(id string) (*apb.BindInstance, error) {
log.Debugf("get binding instance: %v", id)
bi, err := d.client.ServiceBindings(d.namespace).Get(id, metav1.GetOptions{})
log.Debugf("get binidng instance: %v", id)
Copy link
Contributor

Choose a reason for hiding this comment

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

typo

} else if d.IsNotFoundError(err) {
si, err := d.client.BundleInstances(d.namespace).Get(id, metav1.GetOptions{})
if err != nil {
log.Errorf("Unable to update the job state: %v - %v", token, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the language on the errors in this else block should be "Unable to get the job state", right? This is a getter?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, err != nil and si.Status.Jobs branches here look the same? Could combine them?

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the BundleInstance not found case?

return d.GetState("", key)
bi, err := d.client.BundleBindings(d.namespace).Get(key, metav1.GetOptions{})
if err != nil {
log.Errorf("Unable to update the job state: %v - %v", key, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Logs should read not found?

}

// GetStateByKey - Retrieve a job state from the kvp API for a job key
func (d *Dao) GetStateByKey(key string) (apb.JobState, error) {
return d.GetState("", key)
bi, err := d.client.BundleBindings(d.namespace).Get(key, metav1.GetOptions{})
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does GetStateByKey only care about bindings? The usage in the broker only cares about that case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes that is the case, the only thing that has a key is the binding as well.

return apb.JobState{}, err
}
for token, j := range bi.Status.Jobs {
// Assuming a single bind job happens per binding instance.
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 seems like a fair assumption.

Status: metav1.StatusFailure,
Code: http.StatusNotFound,
Reason: metav1.StatusReasonNotFound,
}}
}

// FindJobStateByState - Retrieve all the jobs that match the specified state
func (d *Dao) FindJobStateByState(state apb.State) ([]apb.RecoverStatus, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 looks good.

}
return rs, nil
return rss, nil
}

// GetSvcInstJobsByState - Lookup all jobs of a given state for a specific instance
func (d *Dao) GetSvcInstJobsByState(ID string, state apb.State) ([]apb.JobState, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It's a little confusing seeing a "get service instance jobs by state" that also is looking for bindings? Does this imply that I can pass this a binding ID and it will give me back relevant jobs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes that is the case. I am making the functionality equivalent here but I agree with your point. I think this interface could use a second pair of eyes.

@jmrodri jmrodri self-requested a review April 26, 2018 20:52
Copy link
Contributor

@eriknelson eriknelson 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 ACKing this despite the CI issues because their root cause is understood and unrelated, and I've pulled this PR and confirmed it's working as expected.

@shawn-hurley just hit those log statements as discussed and I'm g2g.

Copy link
Contributor

@jmrodri jmrodri left a comment

Choose a reason for hiding this comment

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

ACK

@@ -1466,6 +1466,9 @@ func (a AnsibleBroker) LastOperation(instanceUUID uuid.UUID, req *LastOperationR

jobstate, err := a.dao.GetState(instanceUUID.String(), req.Operation)
if err != nil {
if a.dao.IsNotFoundError(err) {
return &LastOperationResponse{}, ErrorNotFound
}
// not sure what we do with the error if we can't find the state
log.Error(fmt.Sprintf("problem reading job state: [%s]. error: [%v]", instanceUUID, err.Error()))
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we move the log statement to the top? or do we not want to log this error if we can't find it?

return err
}

func (d *Dao) updateJobState(js *v1.JobState, spec v1.JobStateSpec, state apb.JobState) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey this code looks familiar. Glad I did this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-review size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants