-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancer and HealthUtil now differentiate between fatal and transient…
… errors (#1427) Summary: previously any error returned by the `Enhancer` was treated as fatal. It made sense because it would act deterministically on a prepared set of resources. However, since #1319 enhancer also uses the discovery interface to determine whether or not the given resource is namespaced. These API requests may fail and must be retried. With this fix, `DefaultEnhancer` clearly marks certain errors as fatal. Fixes #1413 Signed-off-by: Aleksey Dukhovniy <[email protected]>
- Loading branch information
Aleksey Dukhovniy
authored
Mar 18, 2020
1 parent
5a3ad3a
commit b5f1f29
Showing
9 changed files
with
78 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ package task | |
import ( | ||
"context" | ||
"encoding/json" | ||
"errors" | ||
"fmt" | ||
"log" | ||
|
||
|
@@ -18,6 +19,7 @@ import ( | |
"sigs.k8s.io/controller-runtime/pkg/client" | ||
|
||
"github.com/kudobuilder/kudo/pkg/apis/kudo/v1beta1" | ||
"github.com/kudobuilder/kudo/pkg/engine" | ||
"github.com/kudobuilder/kudo/pkg/engine/health" | ||
"github.com/kudobuilder/kudo/pkg/engine/resource" | ||
"github.com/kudobuilder/kudo/pkg/util/kudo" | ||
|
@@ -46,7 +48,7 @@ func (at ApplyTask) Run(ctx Context) (bool, error) { | |
// 2. - Enhance them with metadata - | ||
enhanced, err := enhance(rendered, ctx.Meta, ctx.Enhancer) | ||
if err != nil { | ||
return false, fatalExecutionError(err, taskEnhancementError, ctx.Meta) | ||
return false, err | ||
} | ||
|
||
// 3. - Apply them using the client - | ||
|
@@ -58,8 +60,8 @@ func (at ApplyTask) Run(ctx Context) (bool, error) { | |
// 4. - Check health for all resources - | ||
err = isHealthy(applied) | ||
if err != nil { | ||
if fatal := isTerminallyFailed(applied); fatal != nil { | ||
return false, fatalExecutionError(fatal, failedTerminalState, ctx.Meta) | ||
if errors.Is(err, engine.ErrFatalExecution) { | ||
return false, fatalExecutionError(err, failedTerminalState, ctx.Meta) | ||
} | ||
// an error during a health check is not treated task execution error | ||
log.Printf("TaskExecution: %v", err) | ||
|
@@ -239,16 +241,6 @@ func isHealthy(ro []runtime.Object) error { | |
return nil | ||
} | ||
|
||
func isTerminallyFailed(ro []runtime.Object) error { | ||
for _, r := range ro { | ||
if failed, msg := health.IsTerminallyFailed(r); failed { | ||
key, _ := client.ObjectKeyFromObject(r) | ||
return fmt.Errorf("object %s/%s has failed: %s", key.Namespace, key.Name, msg) | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
// copy from k8s.io/[email protected]/pkg/util/apply.go, with adjustments | ||
// GetOriginalConfiguration retrieves the original configuration of the object | ||
// from the annotation. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters