Skip to content

Commit

Permalink
Set instance in moving state to be not ready, but dont throw error (#367
Browse files Browse the repository at this point in the history
)
  • Loading branch information
shyamradhakrishnan committed Jun 17, 2024
1 parent cd00e30 commit b563ee5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion controllers/ocimachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,9 @@ func (r *OCIMachineReconciler) reconcileNormal(ctx context.Context, logger logr.
machineScope.Info("Instance is pending")
conditions.MarkFalse(machineScope.OCIMachine, infrastructurev1beta2.InstanceReadyCondition, infrastructurev1beta2.InstanceNotReadyReason, clusterv1.ConditionSeverityInfo, "")
return reconcile.Result{RequeueAfter: 10 * time.Second}, nil
case core.InstanceLifecycleStateStopping, core.InstanceLifecycleStateStopped:
case core.InstanceLifecycleStateStopping, core.InstanceLifecycleStateStopped, core.InstanceLifecycleStateMoving:
machineScope.SetNotReady()
machineScope.Info(fmt.Sprintf("Instance is in %s state and not ready", instance.LifecycleState))
conditions.MarkFalse(machineScope.OCIMachine, infrastructurev1beta2.InstanceReadyCondition, infrastructurev1beta2.InstanceNotReadyReason, clusterv1.ConditionSeverityInfo, "")
return reconcile.Result{}, nil
case core.InstanceLifecycleStateRunning:
Expand Down
16 changes: 16 additions & 0 deletions controllers/ocimachine_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,22 @@ func TestNormalReconciliationFunction(t *testing.T) {
}, nil)
},
},
{
name: "instance in moving state",
errorExpected: false,
conditionAssertion: []conditionAssertion{{infrastructurev1beta2.InstanceReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityInfo, infrastructurev1beta2.InstanceNotReadyReason}},
testSpecificSetup: func(t *test, machineScope *scope.MachineScope, computeClient *mock_compute.MockComputeClient, vcnClient *mock_vcn.MockClient, nlbclient *mock_nlb.MockNetworkLoadBalancerClient) {
computeClient.EXPECT().GetInstance(gomock.Any(), gomock.Eq(core.GetInstanceRequest{
InstanceId: common.String("test"),
})).
Return(core.GetInstanceResponse{
Instance: core.Instance{
Id: common.String("test"),
LifecycleState: core.InstanceLifecycleStateMoving,
},
}, nil)
},
},
{
name: "instance in terminated state",
errorExpected: true,
Expand Down

0 comments on commit b563ee5

Please sign in to comment.