Skip to content

Commit b08efa1

Browse files
author
OpenShift Bot
authored
Merge pull request #12842 from bparees/fatal_retries
Merged by openshift-bot
2 parents 70251e6 + 361b63f commit b08efa1

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

pkg/build/controller/config_controller.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ type ConfigControllerFatalError struct {
2222
}
2323

2424
// Error returns the error string for this fatal error
25-
func (e ConfigControllerFatalError) Error() string {
25+
func (e *ConfigControllerFatalError) Error() string {
2626
return fmt.Sprintf("fatal error processing BuildConfig: %s", e.Reason)
2727
}
2828

2929
// IsFatal returns true if err is a fatal error
3030
func IsFatal(err error) bool {
31-
_, isFatal := err.(ConfigControllerFatalError)
31+
_, isFatal := err.(*ConfigControllerFatalError)
3232
return isFatal
3333
}
3434

@@ -73,7 +73,10 @@ func (c *BuildConfigController) HandleBuildConfig(bc *buildapi.BuildConfig) erro
7373
if kerrors.IsConflict(err) {
7474
instantiateErr = fmt.Errorf("unable to instantiate Build for BuildConfig %s/%s due to a conflicting update: %v", bc.Namespace, bc.Name, err)
7575
utilruntime.HandleError(instantiateErr)
76-
} else if buildgenerator.IsFatal(err) || kerrors.IsNotFound(err) || kerrors.IsBadRequest(err) {
76+
} else if buildgenerator.IsFatal(err) || kerrors.IsNotFound(err) || kerrors.IsBadRequest(err) || kerrors.IsForbidden(err) {
77+
instantiateErr = fmt.Errorf("gave up on Build for BuildConfig %s/%s due to fatal error: %v", bc.Namespace, bc.Name, err)
78+
utilruntime.HandleError(instantiateErr)
79+
c.Recorder.Event(bc, kapi.EventTypeWarning, "BuildConfigInstantiateFailed", instantiateErr.Error())
7780
return &ConfigControllerFatalError{err.Error()}
7881
} else {
7982
instantiateErr = fmt.Errorf("error instantiating Build from BuildConfig %s/%s: %v", bc.Namespace, bc.Name, err)

pkg/build/controller/controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func (bc *BuildController) nextBuildPhase(build *buildapi.Build) error {
188188
build.Status.Reason = buildapi.StatusReasonCannotCreateBuildPodSpec
189189
build.Status.Message = buildapi.StatusMessageCannotCreateBuildPodSpec
190190
if strategy.IsFatal(err) {
191-
return strategy.FatalError(fmt.Sprintf("failed to create a build pod spec for build %s/%s: %v", build.Namespace, build.Name, err))
191+
return &strategy.FatalError{fmt.Sprintf("failed to create a build pod spec for build %s/%s: %v", build.Namespace, build.Name, err)}
192192
}
193193
return fmt.Errorf("failed to create a build pod spec for build %s/%s: %v", build.Namespace, build.Name, err)
194194
}

pkg/build/controller/strategy/custom.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func (bs *CustomBuildStrategy) CreateBuildPod(build *buildapi.Build) (*kapi.Pod,
3131
if len(strategy.BuildAPIVersion) != 0 {
3232
gv, err := unversioned.ParseGroupVersion(strategy.BuildAPIVersion)
3333
if err != nil {
34-
return nil, FatalError(fmt.Sprintf("failed to parse buildAPIVersion specified in custom build strategy (%q): %v", strategy.BuildAPIVersion, err))
34+
return nil, &FatalError{fmt.Sprintf("failed to parse buildAPIVersion specified in custom build strategy (%q): %v", strategy.BuildAPIVersion, err)}
3535
}
3636
codec = kapi.Codecs.LegacyCodec(gv)
3737
}

pkg/build/controller/strategy/util.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,19 @@ const (
2828
var whitelistEnvVarNames = []string{"BUILD_LOGLEVEL", "GIT_SSL_NO_VERIFY"}
2929

3030
// FatalError is an error which can't be retried.
31-
type FatalError string
31+
type FatalError struct {
32+
// Reason the fatal error occurred
33+
Reason string
34+
}
3235

3336
// Error implements the error interface.
34-
func (e FatalError) Error() string {
35-
return string(e)
37+
func (e *FatalError) Error() string {
38+
return fmt.Sprintf("fatal error: %s", e.Reason)
3639
}
3740

3841
// IsFatal returns true if the error is fatal
3942
func IsFatal(err error) bool {
40-
_, isFatal := err.(FatalError)
43+
_, isFatal := err.(*FatalError)
4144
return isFatal
4245
}
4346

pkg/build/generator/generator.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ type GeneratorFatalError struct {
3232
}
3333

3434
// Error returns the error string for this fatal error
35-
func (e GeneratorFatalError) Error() string {
35+
func (e *GeneratorFatalError) Error() string {
3636
return fmt.Sprintf("fatal error generating Build from BuildConfig: %s", e.Reason)
3737
}
3838

3939
// IsFatal returns true if err is a fatal error
4040
func IsFatal(err error) bool {
41-
_, isFatal := err.(GeneratorFatalError)
41+
_, isFatal := err.(*GeneratorFatalError)
4242
return isFatal
4343
}
4444

0 commit comments

Comments
 (0)