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

oc logs must wait for first build from bc with ConfigChange trigger #12163

Merged
merged 1 commit into from
Dec 10, 2016
Merged

oc logs must wait for first build from bc with ConfigChange trigger #12163

merged 1 commit into from
Dec 10, 2016

Conversation

jupierce
Copy link
Contributor

@jupierce jupierce commented Dec 6, 2016

Fixes #12142
ptal @bparees

// Wait until timeout before giving up on the first build
return false, nil
} else {
return false, fmt.Errorf("no builds found for %q", t.Name)
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't this error going to get wrapped/eaten by line 495? I think we want to retain the existing output behavior for cases where there was no build found and no configchangetrigger on the BC.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we waiting in this code? This code should not be waiting for anything. If you need to wait, do it on the server.

Copy link
Contributor

Choose a reason for hiding this comment

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

there is no buildconfig/logs api endpoint that could do the waiting, we're just writing a clever client here.

setting up a watch on builds (which would still amount to the client waiting) seems like overkill for this trivial fix.

Copy link
Contributor

Choose a reason for hiding this comment

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

If this is something that a naive client would want to do, then we should be fixing this on the server. I am not in favor of overly complex code here to fix one client.

Copy link
Contributor

Choose a reason for hiding this comment

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

if that is true then the entire "logsforobject" concept is flawed and should have been done as api endpoints, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bparees I've given the potential outcomes their own error messages in the latest push.

@bparees bparees self-assigned this Dec 6, 2016
return nil, fmt.Errorf("no builds found for %q", t.Name)

hasConfigChangeTrigger := false
if t.Spec.Triggers != nil && len(t.Spec.Triggers) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be an utility HasConfigChangeTrigger or something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added utility method in buildapi.

}

err = wait.PollImmediate(time.Second, time.Minute, func() (bool, error) {
builds.Items = buildapi.FilterBuilds(builds.Items, buildapi.ByBuildConfigPredicate(t.Name))
Copy link
Contributor

@0xmichalis 0xmichalis Dec 7, 2016

Choose a reason for hiding this comment

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

You are never updating this list of builds meaning it's going to always be the same, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @Kargakis . Fixed in next push.

builds.Items = buildapi.FilterBuilds(builds.Items, buildapi.ByBuildConfigPredicate(t.Name))
if len(builds.Items) > 0 {
return true, nil
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for else

if hasConfigChangeTrigger {
// Wait until timeout before giving up on the first build
return false, nil
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for else

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using more compact style in next push.

err = nil
}
}
return buildTriggers, err
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems weird to return an error for this. i would expect the caller to check the array length and if it's zero, they know it wasn't found. errors should be used for issues that are harder to anticipate imho.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer your methodology. My initial pass was to preserve/unify on the signature I found in webhooks. Will make the change.

hasConfigChangeTrigger := buildapi.HasTriggerType(buildapi.ConfigChangeBuildTriggerType, t)

var builds *buildapi.BuildList
err = wait.PollImmediate(time.Second, time.Minute, func() (bool, error) {
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 I annoyed @smarterclayton enough that he decided to let this slide for now, but it does sound like if we find ourselves in this code much more, we should consider introducing a server side build/bc logs api endpoint.

@bparees
Copy link
Contributor

bparees commented Dec 9, 2016

lgtm [merge]

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to cd418ff

@openshift-bot
Copy link
Contributor

[Test]ing while waiting on the merge queue

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to cd418ff

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/12214/) (Base Commit: a954b6c)

@openshift-bot
Copy link
Contributor

openshift-bot commented Dec 9, 2016

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/12230/) (Base Commit: de5ab20) (Image: devenv-rhel7_5519)

@openshift-bot openshift-bot merged commit d97d6f4 into openshift:master Dec 10, 2016
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.

5 participants