Skip to content
Closed
Show file tree
Hide file tree
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
25 changes: 16 additions & 9 deletions pkg/controller/drain/drain_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ func (ctrl *Controller) syncNode(key string) error {
}

// Get MCP associated with node
pool, err := helpers.GetPrimaryPoolNameForMCN(ctrl.mcpLister, node)
mcpName, desiredConfigVersion, err := helpers.GetPrimaryPoolDetailsForMCN(ctrl.mcpLister, node)
if err != nil {
return err
}
Expand All @@ -334,7 +334,8 @@ func (ctrl *Controller) syncNode(key string) error {
node,
ctrl.client,
ctrl.featureGatesAccessor,
pool,
mcpName,
desiredConfigVersion,
)
if nErr != nil {
klog.Errorf("Error making MCN for Uncordon failure: %v", err)
Expand All @@ -350,7 +351,8 @@ func (ctrl *Controller) syncNode(key string) error {
node,
ctrl.client,
ctrl.featureGatesAccessor,
pool,
mcpName,
desiredConfigVersion,
)
if err != nil {
klog.Errorf("Error making MCN for UnCordon success: %v", err)
Expand Down Expand Up @@ -406,7 +408,7 @@ func (ctrl *Controller) drainNode(node *corev1.Node, drainer *drain.Helper) erro
}

// Get MCP associated with node
pool, err := helpers.GetPrimaryPoolNameForMCN(ctrl.mcpLister, node)
mcpName, desiredConfigVersion, err := helpers.GetPrimaryPoolDetailsForMCN(ctrl.mcpLister, node)
if err != nil {
return err
}
Expand All @@ -422,7 +424,8 @@ func (ctrl *Controller) drainNode(node *corev1.Node, drainer *drain.Helper) erro
node,
ctrl.client,
ctrl.featureGatesAccessor,
pool,
mcpName,
desiredConfigVersion,
)
if Nerr != nil {
klog.Errorf("Error making MCN for Cordon Failure: %v", Nerr)
Expand All @@ -437,7 +440,8 @@ func (ctrl *Controller) drainNode(node *corev1.Node, drainer *drain.Helper) erro
node,
ctrl.client,
ctrl.featureGatesAccessor,
pool,
mcpName,
desiredConfigVersion,
)
if err != nil {
klog.Errorf("Error making MCN for Cordon Success: %v", err)
Expand All @@ -454,7 +458,8 @@ func (ctrl *Controller) drainNode(node *corev1.Node, drainer *drain.Helper) erro
node,
ctrl.client,
ctrl.featureGatesAccessor,
pool,
mcpName,
desiredConfigVersion,
)
if err != nil {
klog.Errorf("Error making MCN for Drain beginning: %v", err)
Expand Down Expand Up @@ -484,7 +489,8 @@ func (ctrl *Controller) drainNode(node *corev1.Node, drainer *drain.Helper) erro
node,
ctrl.client,
ctrl.featureGatesAccessor,
pool,
mcpName,
desiredConfigVersion,
)
if nErr != nil {
klog.Errorf("Error making MCN for Drain failure: %v", nErr)
Expand All @@ -501,7 +507,8 @@ func (ctrl *Controller) drainNode(node *corev1.Node, drainer *drain.Helper) erro
node,
ctrl.client,
ctrl.featureGatesAccessor,
pool,
mcpName,
desiredConfigVersion,
)
if err != nil {
klog.Errorf("Error making MCN for Drain success: %v", err)
Expand Down
16 changes: 5 additions & 11 deletions pkg/controller/node/node_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func newFixtureWithFeatureGates(t *testing.T, enabled, disabled []configv1.Featu
}

func newFixture(t *testing.T) *fixture {
return newFixtureWithFeatureGates(t, []configv1.FeatureGateName{features.FeatureGatePinnedImages, features.FeatureGateOnClusterBuild}, []configv1.FeatureGateName{})
return newFixtureWithFeatureGates(t, []configv1.FeatureGateName{features.FeatureGateMachineConfigNodes, features.FeatureGatePinnedImages, features.FeatureGateOnClusterBuild}, []configv1.FeatureGateName{})
}

func (f *fixture) newControllerWithStopChan(stopCh <-chan struct{}) *Controller {
Expand Down Expand Up @@ -140,18 +140,10 @@ func (f *fixture) newController() *Controller {
return f.newControllerWithStopChan(stopCh)
}

func (f *fixture) newControllerWithContext(ctx context.Context) *Controller {
return f.newControllerWithStopChan(ctx.Done())
}

func (f *fixture) run(pool string) {
f.runController(pool, false)
}

func (f *fixture) runExpectError(pool string) {
f.runController(pool, true)
}

func (f *fixture) runController(pool string, expectError bool) {
c := f.newController()

Expand Down Expand Up @@ -260,7 +252,9 @@ func filterInformerActions(actions []core.Action) []core.Action {
action.Matches("list", "machineosbuilds") ||
action.Matches("watch", "machineosbuilds") ||
action.Matches("list", "machineosconfigs") ||
action.Matches("watch", "machineosconfigs")) {
action.Matches("watch", "machineosconfigs") ||
action.Matches("get", "machineconfignodes") ||
action.Matches("create", "machineconfignodes")) {
continue
}
ret = append(ret, action)
Expand Down Expand Up @@ -1146,7 +1140,7 @@ func TestShouldMakeProgress(t *testing.T) {
expectTaintsAddPatch: false,
},
{
description: "node not at desired config, patch on annotation and taints", // failing
description: "node not at desired config, patch on annotation and taints",
node: newNodeWithLabel("nodeNeedingUpdates", machineConfigV0, machineConfigV0, map[string]string{"node-role/worker": "", "node-role/infra": ""}),
expectAnnotationPatch: true,
expectTaintsAddPatch: true,
Expand Down
19 changes: 12 additions & 7 deletions pkg/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ func (dn *Daemon) syncNode(key string) error {
}

// Get MCP associated with node
pool, err := helpers.GetPrimaryPoolNameForMCN(dn.mcpLister, node)
mcpName, desiredConfigVersion, err := helpers.GetPrimaryPoolDetailsForMCN(dn.mcpLister, node)
if err != nil {
return err
}
Expand All @@ -728,7 +728,8 @@ func (dn *Daemon) syncNode(key string) error {
node,
dn.mcfgClient,
dn.featureGatesAccessor,
pool,
mcpName,
desiredConfigVersion,
)
if err != nil {
klog.Errorf("Error making MCN for Rebooted: %v", err)
Expand Down Expand Up @@ -804,7 +805,8 @@ func (dn *Daemon) syncNode(key string) error {
node,
dn.mcfgClient,
dn.featureGatesAccessor,
pool,
mcpName,
desiredConfigVersion,
)
if err != nil {
klog.Errorf("Error making MCN for Resumed true: %v", err)
Expand Down Expand Up @@ -843,7 +845,8 @@ func (dn *Daemon) syncNode(key string) error {
dn.node,
dn.mcfgClient,
dn.featureGatesAccessor,
pool,
mcpName,
desiredConfigVersion,
)
if err != nil {
klog.Errorf("Error making MCN for Updated false: %v", err)
Expand All @@ -868,7 +871,8 @@ func (dn *Daemon) syncNode(key string) error {
dn.node,
dn.mcfgClient,
dn.featureGatesAccessor,
pool,
mcpName,
desiredConfigVersion,
)
if err != nil {
klog.Errorf("Error making MCN for Updated: %v", err)
Expand Down Expand Up @@ -2319,7 +2323,7 @@ func (dn *Daemon) updateConfigAndState(state *stateAndConfigs) (bool, bool, erro
// let's mark it done!

// Get MCP associated with node
pool, err := helpers.GetPrimaryPoolNameForMCN(dn.mcpLister, dn.node)
mcpName, desiredConfigVersion, err := helpers.GetPrimaryPoolDetailsForMCN(dn.mcpLister, dn.node)
if err != nil {
return missingODC, inDesiredConfig, err
}
Expand All @@ -2332,7 +2336,8 @@ func (dn *Daemon) updateConfigAndState(state *stateAndConfigs) (bool, bool, erro
dn.node,
dn.mcfgClient,
dn.featureGatesAccessor,
pool,
mcpName,
desiredConfigVersion,
)
if err != nil {
klog.Errorf("Error making MCN for Resumed true: %v", err)
Expand Down
5 changes: 3 additions & 2 deletions pkg/daemon/drain.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (dn *Daemon) performDrain() error {
logSystem("Drain not required, skipping")

// Get MCP associated with node
pool, err := helpers.GetPrimaryPoolNameForMCN(dn.mcpLister, dn.node)
mcpName, desiredConfigVersion, err := helpers.GetPrimaryPoolDetailsForMCN(dn.mcpLister, dn.node)
if err != nil {
return err
}
Expand All @@ -56,7 +56,8 @@ func (dn *Daemon) performDrain() error {
dn.node,
dn.mcfgClient,
dn.featureGatesAccessor,
pool,
mcpName,
desiredConfigVersion,
)
if err != nil {
klog.Errorf("Error making MCN for Drain not required: %v", err)
Expand Down
18 changes: 11 additions & 7 deletions pkg/daemon/pinned_image_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ func (p *PinnedImageSetManager) updateStatusProgressing(pools []*mcfgv1.MachineC
}

// Get MCP associated with node
pool, err := helpers.GetPrimaryPoolNameForMCN(p.mcpLister, node)
mcpName, desiredConfigVersion, err := helpers.GetPrimaryPoolDetailsForMCN(p.mcpLister, node)
if err != nil {
return err
}
Expand All @@ -565,7 +565,8 @@ func (p *PinnedImageSetManager) updateStatusProgressing(pools []*mcfgv1.MachineC
p.mcfgClient,
applyCfg,
p.featureGatesAccessor,
pool,
mcpName,
desiredConfigVersion,
)
}

Expand All @@ -582,7 +583,7 @@ func (p *PinnedImageSetManager) updateStatusProgressingComplete(pools []*mcfgv1.
}

// Get MCP associated with node
pool, err := helpers.GetPrimaryPoolNameForMCN(p.mcpLister, node)
mcpName, desiredConfigVersion, err := helpers.GetPrimaryPoolDetailsForMCN(p.mcpLister, node)
if err != nil {
return err
}
Expand All @@ -600,7 +601,8 @@ func (p *PinnedImageSetManager) updateStatusProgressingComplete(pools []*mcfgv1.
p.mcfgClient,
applyCfg,
p.featureGatesAccessor,
pool,
mcpName,
desiredConfigVersion,
)
if err != nil {
klog.Errorf("Failed to update machine config node: %v", err)
Expand All @@ -620,7 +622,8 @@ func (p *PinnedImageSetManager) updateStatusProgressingComplete(pools []*mcfgv1.
p.mcfgClient,
nil,
p.featureGatesAccessor,
pool,
mcpName,
desiredConfigVersion,
)
}

Expand All @@ -637,7 +640,7 @@ func (p *PinnedImageSetManager) updateStatusError(pools []*mcfgv1.MachineConfigP
}

// Get MCP associated with node
pool, err := helpers.GetPrimaryPoolNameForMCN(p.mcpLister, node)
mcpName, desiredConfigVersion, err := helpers.GetPrimaryPoolDetailsForMCN(p.mcpLister, node)
if err != nil {
return err
}
Expand All @@ -655,7 +658,8 @@ func (p *PinnedImageSetManager) updateStatusError(pools []*mcfgv1.MachineConfigP
p.mcfgClient,
applyCfg,
p.featureGatesAccessor,
pool,
mcpName,
desiredConfigVersion,
)
}

Expand Down
Loading