mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +00:00
fix: improve accumulation failure message
For accumulation errors when the file load fails due to malformed YAML and the base load fails due to a timeout, report both errors. Previously only the malformed YAML error was returned, masking the git repo timeout.
This commit is contained in:
@@ -425,7 +425,14 @@ func (kt *KustTarget) accumulateResources(
|
||||
}
|
||||
ldr, err := kt.ldr.New(path)
|
||||
if err != nil {
|
||||
if kusterr.IsMalformedYAMLError(errF) { // Some error occurred while tyring to decode YAML file
|
||||
// If accumulateFile found malformed YAML and there was a failure
|
||||
// loading the resource as a base, then the resource is likely a
|
||||
// file. The loader failure message is unnecessary, and could be
|
||||
// confusing. Report only the file load error.
|
||||
//
|
||||
// However, a loader timeout implies there is a git repo at the
|
||||
// path. In that case, both errors could be important.
|
||||
if kusterr.IsMalformedYAMLError(errF) && !utils.IsErrTimeout(err) {
|
||||
return nil, errF
|
||||
}
|
||||
return nil, errors.WrapPrefixf(
|
||||
|
||||
@@ -15,11 +15,11 @@ type errTimeOut struct {
|
||||
cmd string
|
||||
}
|
||||
|
||||
func NewErrTimeOut(d time.Duration, c string) errTimeOut {
|
||||
return errTimeOut{duration: d, cmd: c}
|
||||
func NewErrTimeOut(d time.Duration, c string) *errTimeOut {
|
||||
return &errTimeOut{duration: d, cmd: c}
|
||||
}
|
||||
|
||||
func (e errTimeOut) Error() string {
|
||||
func (e *errTimeOut) Error() string {
|
||||
return fmt.Sprintf("hit %s timeout running '%s'", e.duration, e.cmd)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user