Skip to content

Commit 8664b9d

Browse files
committed
treat fatal errors as actually fatal
1 parent 6cebc0e commit 8664b9d

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

pkg/build/controller/config_controller.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@ func (e ConfigControllerFatalError) Error() string {
2828

2929
// IsFatal returns true if err is a fatal error
3030
func IsFatal(err error) bool {
31-
_, isFatal := err.(ConfigControllerFatalError)
32-
return isFatal
31+
switch err.(type) {
32+
case ConfigControllerFatalError, *ConfigControllerFatalError:
33+
return true
34+
default:
35+
return false
36+
}
3337
}
3438

3539
type BuildConfigController struct {
@@ -73,7 +77,10 @@ func (c *BuildConfigController) HandleBuildConfig(bc *buildapi.BuildConfig) erro
7377
if kerrors.IsConflict(err) {
7478
instantiateErr = fmt.Errorf("unable to instantiate Build for BuildConfig %s/%s due to a conflicting update: %v", bc.Namespace, bc.Name, err)
7579
utilruntime.HandleError(instantiateErr)
76-
} else if buildgenerator.IsFatal(err) || kerrors.IsNotFound(err) || kerrors.IsBadRequest(err) {
80+
} else if buildgenerator.IsFatal(err) || kerrors.IsNotFound(err) || kerrors.IsBadRequest(err) || kerrors.IsForbidden(err) {
81+
instantiateErr = fmt.Errorf("gave up on Build for BuildConfig %s/%s due to fatal error: %v", bc.Namespace, bc.Name, err)
82+
utilruntime.HandleError(instantiateErr)
83+
c.Recorder.Event(bc, kapi.EventTypeWarning, "BuildConfigInstantiateFailed", instantiateErr.Error())
7784
return &ConfigControllerFatalError{err.Error()}
7885
} else {
7986
instantiateErr = fmt.Errorf("error instantiating Build from BuildConfig %s/%s: %v", bc.Namespace, bc.Name, err)

pkg/build/controller/strategy/util.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,12 @@ func (e FatalError) Error() string {
3737

3838
// IsFatal returns true if the error is fatal
3939
func IsFatal(err error) bool {
40-
_, isFatal := err.(FatalError)
41-
return isFatal
40+
switch err.(type) {
41+
case FatalError, *FatalError:
42+
return true
43+
default:
44+
return false
45+
}
4246
}
4347

4448
// setupDockerSocket configures the pod to support the host's Docker socket

pkg/build/generator/generator.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,12 @@ func (e GeneratorFatalError) Error() string {
3838

3939
// IsFatal returns true if err is a fatal error
4040
func IsFatal(err error) bool {
41-
_, isFatal := err.(GeneratorFatalError)
42-
return isFatal
41+
switch err.(type) {
42+
case GeneratorFatalError, *GeneratorFatalError:
43+
return true
44+
default:
45+
return false
46+
}
4347
}
4448

4549
// BuildGenerator is a central place responsible for generating new Build objects

0 commit comments

Comments
 (0)