Skip to content

Commit

Permalink
Fix notification timings not getting tracked
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuckal777 committed Aug 23, 2021
1 parent d747097 commit a8f7674
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion controllers/node_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
8 changes: 4 additions & 4 deletions state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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",
Expand Down

0 comments on commit a8f7674

Please sign in to comment.