-
Notifications
You must be signed in to change notification settings - Fork 244
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
Testing build fix #2406
Testing build fix #2406
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1672,7 +1672,8 @@ func (c *Client) StartBuild(name string) (string, error) { | |
} | ||
|
||
// WaitForBuildToFinish block and waits for build to finish. Returns error if build failed or was canceled. | ||
func (c *Client) WaitForBuildToFinish(buildName string) error { | ||
func (c *Client) WaitForBuildToFinish(buildName string, stdout io.Writer) error { | ||
following := false | ||
glog.V(4).Infof("Waiting for %s build to finish", buildName) | ||
|
||
w, err := c.buildClient.Builds(c.Namespace).Watch(metav1.ListOptions{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand this is not touched in the proposed PR but can we add a comment that describes what this all about? At least I didn't understand a thing here. 😞 |
||
|
@@ -1682,23 +1683,36 @@ func (c *Client) WaitForBuildToFinish(buildName string) error { | |
return errors.Wrapf(err, "unable to watch build") | ||
} | ||
defer w.Stop() | ||
timeout := time.After(5 * time.Minute) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be a constant? (high above in |
||
for { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't understand what's going on in this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can help here a bit. So here first thing to observe is the now the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as for the need for the |
||
val, ok := <-w.ResultChan() | ||
if !ok { | ||
break | ||
} | ||
if e, ok := val.Object.(*buildv1.Build); ok { | ||
glog.V(4).Infof("Status of %s build is %s", e.Name, e.Status.Phase) | ||
switch e.Status.Phase { | ||
case buildv1.BuildPhaseComplete: | ||
glog.V(4).Infof("Build %s completed.", e.Name) | ||
return nil | ||
case buildv1.BuildPhaseFailed, buildv1.BuildPhaseCancelled, buildv1.BuildPhaseError: | ||
return errors.Errorf("build %s status %s", e.Name, e.Status.Phase) | ||
select { | ||
case val, ok := <-w.ResultChan(): | ||
if !ok { | ||
break | ||
} | ||
if e, ok := val.Object.(*buildv1.Build); ok { | ||
glog.V(4).Infof("Status of %s build is %s", e.Name, e.Status.Phase) | ||
switch e.Status.Phase { | ||
case buildv1.BuildPhaseComplete: | ||
glog.V(4).Infof("Build %s completed.", e.Name) | ||
return nil | ||
case buildv1.BuildPhaseFailed, buildv1.BuildPhaseCancelled, buildv1.BuildPhaseError: | ||
return errors.Errorf("build %s status %s", e.Name, e.Status.Phase) | ||
case buildv1.BuildPhaseRunning: | ||
// since the pod is ready and the build is now running, start following the logs | ||
if !following { | ||
following = true | ||
err := c.FollowBuildLog(buildName, stdout) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of this above looks good! |
||
} | ||
} | ||
case <-timeout: | ||
return errors.Errorf("timeout waiting for build %s to start", buildName) | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
// WaitAndGetDC block and waits until the DeploymentConfig has updated it's annotation | ||
|
@@ -1845,6 +1859,7 @@ func (c *Client) FollowBuildLog(buildName string, stdout io.Writer) error { | |
} | ||
|
||
rd, err := c.buildClient.RESTClient().Get(). | ||
Timeout(5*time.Minute). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be a constant |
||
Namespace(c.Namespace). | ||
Resource("builds"). | ||
Name(buildName). | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need more description on this, bit confused why we're setting following to false then true when going through the channel loop.