Skip to content

Commit

Permalink
Debugging commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mfojtik committed Apr 28, 2016
1 parent 885b8f5 commit ddf7809
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pkg/cmd/cli/cmd/cancelbuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,21 @@ func (o *CancelBuildOptions) Run() error {
wg.Add(1)
go func(build *buildapi.Build) {
defer wg.Done()
build.Status.Cancelled = true
err := wait.Poll(500*time.Millisecond, 30*time.Second, func() (bool, error) {
build.Status.Cancelled = true
_, err := o.BuildClient.Update(build)
if err != nil && errors.IsConflict(err) {
return false, nil
switch {
case err == nil:
return true, nil
case errors.IsConflict(err):
fmt.Println("update has conflict on", build.Name)
build, err = o.BuildClient.Get(build.Name)
return false, err
}
return true, err
})
if err != nil {
o.ReportError(fmt.Errorf("build %s/%s failed to cancel: %v", build.Namespace, build.Name, err))
o.ReportError(fmt.Errorf("build %s/%s failed to update: %v", build.Namespace, build.Name, err))
return
}
// Make sure the build phase is really cancelled.
Expand All @@ -207,6 +212,7 @@ func (o *CancelBuildOptions) Run() error {
if err != nil {
return true, err
}
fmt.Printf("build %s state is %s\n", build.Name, string(updatedBuild.Status.Phase))
return updatedBuild.Status.Phase == buildapi.BuildPhaseCancelled, nil
})
if err != nil {
Expand Down

0 comments on commit ddf7809

Please sign in to comment.