From bc9623737a2342514aa6610b457081dc3e2729e4 Mon Sep 17 00:00:00 2001 From: Surinder Singh Date: Mon, 9 Mar 2020 14:36:22 -0600 Subject: [PATCH] Fixing attempt-count and unit-tests (#83) --- pkg/controller/nodes/executor.go | 2 +- pkg/controller/nodes/executor_test.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/controller/nodes/executor.go b/pkg/controller/nodes/executor.go index 604b20050c..c1afeb2de0 100644 --- a/pkg/controller/nodes/executor.go +++ b/pkg/controller/nodes/executor.go @@ -181,7 +181,7 @@ func (c *nodeExecutor) isEligibleForRetry(nCtx *execContext, nodeStatus v1alpha1 return } - currentAttempt = nodeStatus.GetAttempts() - nodeStatus.GetSystemFailures() + currentAttempt = (nodeStatus.GetAttempts() + 1) - nodeStatus.GetSystemFailures() if nCtx.Node().GetRetryStrategy() != nil && nCtx.Node().GetRetryStrategy().MinAttempts != nil { maxAttempts = uint32(*nCtx.Node().GetRetryStrategy().MinAttempts) } diff --git a/pkg/controller/nodes/executor_test.go b/pkg/controller/nodes/executor_test.go index 43afabfea1..f2b05ae5f4 100644 --- a/pkg/controller/nodes/executor_test.go +++ b/pkg/controller/nodes/executor_test.go @@ -741,7 +741,7 @@ func TestNodeExecutor_RecursiveNodeHandler_Recurse(t *testing.T) { {"(retryablefailure->running", v1alpha1.NodePhaseRetryableFailure, v1alpha1.NodePhaseRunning, executors.NodePhasePending, func() (handler.Transition, error) { return handler.UnknownTransition, fmt.Errorf("should not be invoked") - }, false, false, core.NodeExecution_RUNNING, 1}, + }, false, false, core.NodeExecution_RUNNING, 0}, {"running->failing", v1alpha1.NodePhaseRunning, v1alpha1.NodePhaseFailing, executors.NodePhasePending, func() (handler.Transition, error) { return handler.DoTransition(handler.TransitionTypeEphemeral, handler.PhaseInfoFailure("code", "reason", nil)), nil @@ -1210,6 +1210,7 @@ func Test_nodeExecutor_timeout(t *testing.T) { ns.On("GetQueuedAt").Return(queuedAtTime) ns.On("GetLastAttemptStartedAt").Return(queuedAtTime) ns.OnGetAttempts().Return(0) + ns.OnGetSystemFailures().Return(0) ns.On("ClearLastAttemptStartedAt").Return() for _, tt := range tests {