Skip to content

Commit

Permalink
Fix BuildConfigInstantiateFailed warning when lastVersion == 0
Browse files Browse the repository at this point in the history
Build config instatiate should not emit a warning when
bc.Status.LastVersion != lastVersion and lastVersion == 0
Fixes #16557
  • Loading branch information
coreydaley committed Nov 2, 2017
1 parent cf510ea commit 14a0f39
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/build/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,9 @@ func (g *BuildGenerator) instantiate(ctx apirequest.Context, request *buildapi.B
}

// checkBuildConfigLastVersion will return an error if the BuildConfig's LastVersion doesn't match the passed in lastVersion
// when lastVersion is not nil
// when lastVersion is not nil and lastVersion is not zero
func (g *BuildGenerator) checkLastVersion(bc *buildapi.BuildConfig, lastVersion *int64) error {
if lastVersion != nil && bc.Status.LastVersion != *lastVersion {
if lastVersion != nil && *lastVersion != 0 && bc.Status.LastVersion != *lastVersion {
glog.V(2).Infof("Aborting version triggered build for BuildConfig %s/%s because the BuildConfig LastVersion (%d) does not match the requested LastVersion (%d)", bc.Namespace, bc.Name, bc.Status.LastVersion, *lastVersion)
return fmt.Errorf("the LastVersion(%v) on build config %s/%s does not match the build request LastVersion(%d)",
bc.Status.LastVersion, bc.Namespace, bc.Name, *lastVersion)
Expand Down
9 changes: 8 additions & 1 deletion pkg/build/generator/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,9 +596,16 @@ func TestInstantiateWithLastVersion(t *testing.T) {
t.Errorf("Unexpected error %v", err)
}

// Version specified, but doesn't match
// Version 0 specified, but doesn't match
lastVersion = 0
_, err = g.Instantiate(apirequest.NewDefaultContext(), &buildapi.BuildRequest{LastVersion: &lastVersion})
if err != nil {
t.Errorf("Unexpected error %v", err)
}

// Version specified, but doesn't match
lastVersion = int64(2)
_, err = g.Instantiate(apirequest.NewDefaultContext(), &buildapi.BuildRequest{LastVersion: &lastVersion})
if err == nil {
t.Errorf("Expected an error and did not get one")
}
Expand Down

0 comments on commit 14a0f39

Please sign in to comment.