Skip to content

[release-4.19] OCPBUGS-56119: error from generateAndValidateRenderedMachineConfig function can be misleading #5044

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions pkg/controller/render/render_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package render

import (
"context"
goerrs "errors"
"fmt"
"reflect"
"sort"
"strings"
"time"

mcfgv1 "github.com/openshift/api/machineconfiguration/v1"
Expand Down Expand Up @@ -667,8 +667,33 @@ func generateAndValidateRenderedMachineConfig(currentMC *mcfgv1.MachineConfig, p

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

if err := ctrlcommon.IsRenderedConfigReconcilable(currentMC, generated); err != nil {
return nil, goerrs.Join(err, ctrlcommon.IsComponentConfigsReconcilable(currentMC, configs))
if fullErr := ctrlcommon.IsRenderedConfigReconcilable(currentMC, generated); fullErr != nil {
fullMsg := fullErr.Error()

// trying to match error reason suffix
for _, cfg := range configs {
singleErr := ctrlcommon.IsComponentConfigsReconcilable(
currentMC, []*mcfgv1.MachineConfig{cfg},
)
if singleErr == nil {
continue
}
singleMsg := singleErr.Error()

// split off prefix
parts := strings.SplitN(singleMsg, ": ", 2)
if len(parts) == 2 {
reason := parts[1]
if strings.Contains(fullMsg, reason) {
klog.V(4).Infof("match found for base %q on reason %q", cfg.Name, reason)
return nil, fmt.Errorf("reconciliation failed between current config %q and base config %q: %s", currentMC.Name, cfg.Name, reason)
}
}
}

// fallback
compErr := ctrlcommon.IsComponentConfigsReconcilable(currentMC, configs)
return nil, fmt.Errorf("render reconciliation error: %v; component errors: %v", fullErr, compErr)
}

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