Skip to content

Commit 38a0440

Browse files
Merge pull request #5060 from openshift-cherrypick-robot/cherry-pick-5049-to-release-4.17
[release-4.17] OCPBUGS-56395: error from generateAndValidateRenderedMachineConfig function can be misleading
2 parents 71ba6e6 + f133aca commit 38a0440

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

pkg/controller/render/render_controller.go

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ package render
22

33
import (
44
"context"
5-
goerrs "errors"
65
"fmt"
76
"reflect"
87
"sort"
8+
"strings"
99
"time"
1010

1111
mcfgv1 "github.com/openshift/api/machineconfiguration/v1"
@@ -665,8 +665,33 @@ func generateAndValidateRenderedMachineConfig(currentMC *mcfgv1.MachineConfig, p
665665

666666
klog.V(4).Infof("Considering generated MachineConfig %q", generated.Name)
667667

668-
if err := ctrlcommon.IsRenderedConfigReconcilable(currentMC, generated); err != nil {
669-
return nil, goerrs.Join(err, ctrlcommon.IsComponentConfigsReconcilable(currentMC, configs))
668+
if fullErr := ctrlcommon.IsRenderedConfigReconcilable(currentMC, generated); fullErr != nil {
669+
fullMsg := fullErr.Error()
670+
671+
// trying to match error reason suffix
672+
for _, cfg := range configs {
673+
singleErr := ctrlcommon.IsComponentConfigsReconcilable(
674+
currentMC, []*mcfgv1.MachineConfig{cfg},
675+
)
676+
if singleErr == nil {
677+
continue
678+
}
679+
singleMsg := singleErr.Error()
680+
681+
// split off prefix
682+
parts := strings.SplitN(singleMsg, ": ", 2)
683+
if len(parts) == 2 {
684+
reason := parts[1]
685+
if strings.Contains(fullMsg, reason) {
686+
klog.V(4).Infof("match found for base %q on reason %q", cfg.Name, reason)
687+
return nil, fmt.Errorf("reconciliation failed between current config %q and base config %q: %s", currentMC.Name, cfg.Name, reason)
688+
}
689+
}
690+
}
691+
692+
// fallback
693+
compErr := ctrlcommon.IsComponentConfigsReconcilable(currentMC, configs)
694+
return nil, fmt.Errorf("render reconciliation error: %v; component errors: %v", fullErr, compErr)
670695
}
671696

672697
klog.V(4).Infof("Rendered MachineConfig %q is reconcilable against %q", generated.Name, currentMC.Name)

0 commit comments

Comments
 (0)