From a8f7674972b29058bda5284f2ae1e9365dd405d0 Mon Sep 17 00:00:00 2001 From: D074096 Date: Mon, 23 Aug 2021 18:05:25 +0200 Subject: [PATCH] Fix notification timings not getting tracked --- controllers/node_controller.go | 2 +- state/state.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/controllers/node_controller.go b/controllers/node_controller.go index 3cafed6..18d348a 100644 --- a/controllers/node_controller.go +++ b/controllers/node_controller.go @@ -194,7 +194,7 @@ func reconcileInternal(params reconcileParameters) error { pluginParams := plugin.Parameters{Client: params.client, Ctx: params.ctx, Log: log, Node: node, State: stateStr, StateKey: StateLabelKey, LastTransition: data.LastTransition, Recorder: params.recorder} - next, err := state.Apply(stateObj, node, data, pluginParams) + next, err := state.Apply(stateObj, node, &data, pluginParams) if err != nil { return fmt.Errorf("Failed to apply current state: %w", err) } diff --git a/state/state.go b/state/state.go index f055650..07149e8 100644 --- a/state/state.go +++ b/state/state.go @@ -93,15 +93,15 @@ func FromLabel(label NodeStateLabel, chains PluginChains, interval time.Duration // and invokes all trigger plugins if a transitions happens. // Returns the next node state. // In case of an error state.Label() is retuned alongside with the error. -func Apply(state NodeState, node *v1.Node, data Data, params plugin.Parameters) (NodeStateLabel, error) { +func Apply(state NodeState, node *v1.Node, data *Data, params plugin.Parameters) (NodeStateLabel, error) { // invoke notifications and check for transition - err := state.Notify(params, &data) + err := state.Notify(params, data) if err != nil { params.Recorder.Eventf(node, "Normal", "ChangeMaintenanceStateFailed", "At least one notification plugin failed: Will stay in %v state", params.State) return state.Label(), fmt.Errorf("failed to notify: %w", err) } - next, err := state.Transition(params, &data) + next, err := state.Transition(params, data) if err != nil { params.Recorder.Eventf(node, "Normal", "ChangeMaintenanceStateFailed", "At least one check plugin failed: Will stay in %v state", params.State) @@ -110,7 +110,7 @@ func Apply(state NodeState, node *v1.Node, data Data, params plugin.Parameters) // check if a transition should happen if next != state.Label() { - err = state.Trigger(params, &data) + err = state.Trigger(params, data) if err != nil { params.Log.Error(err, "Failed to execute triggers", "state", params.State) params.Recorder.Eventf(node, "Normal", "ChangeMaintenanceStateFailed",