Skip to content

Commit 70cdda0

Browse files
author
Cecile Robert-Michon
committed
Improve error messaging around bootstrap extension provisioning
1 parent 43b8486 commit 70cdda0

File tree

6 files changed

+16
-18
lines changed

6 files changed

+16
-18
lines changed

azure/errors.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,9 @@ func (t ReconcileError) Error() string {
8989
}
9090
switch t.errorType {
9191
case TransientErrorType:
92-
return fmt.Sprintf("reconcile error occurred that can be recovered. Object will be requeued after %s "+
93-
"The actual error is: %s", t.requestAfter.String(), errStr)
92+
return fmt.Sprintf("transient reconcile error occurred: %s. Object will be requeued after %s", errStr, t.requestAfter.String())
9493
case TerminalErrorType:
95-
return fmt.Sprintf("reconcile error occurred that cannot be recovered. Object will not be requeued. "+
96-
"The actual error is: %s", errStr)
94+
return fmt.Sprintf("reconcile error that cannot be recovered occurred: %s. Object will not be requeued", errStr)
9795
default:
9896
return fmt.Sprintf("reconcile error occurred with unknown recovery type. The actual error is: %s", errStr)
9997
}

azure/scope/machine.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,11 +379,11 @@ func (m *MachineScope) SetBootstrapConditions(provisioningState string, extensio
379379
case infrav1.Creating:
380380
m.V(4).Info("extension provisioning state is creating", "vm extension", extensionName, "virtual machine", m.Name())
381381
conditions.MarkFalse(m.AzureMachine, infrav1.BootstrapSucceededCondition, infrav1.BootstrapInProgressReason, clusterv1.ConditionSeverityInfo, "")
382-
return azure.WithTransientError(errors.New("extension still provisioning"), 30*time.Second)
382+
return azure.WithTransientError(errors.New("extension is still in provisioning state. This likely means that bootstrapping has not yet completed on the VM"), 30*time.Second)
383383
case infrav1.Failed:
384384
m.V(4).Info("extension provisioning state is failed", "vm extension", extensionName, "virtual machine", m.Name())
385385
conditions.MarkFalse(m.AzureMachine, infrav1.BootstrapSucceededCondition, infrav1.BootstrapFailedReason, clusterv1.ConditionSeverityError, "")
386-
return azure.WithTerminalError(errors.New("extension state failed"))
386+
return azure.WithTerminalError(errors.New("extension state failed. This likely means the Kubernetes node bootstrapping process failed or timed out. Check VM boot diagnostics logs to learn more"))
387387
default:
388388
return nil
389389
}

azure/scope/machinepool.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,11 +447,11 @@ func (m *MachinePoolScope) SetBootstrapConditions(provisioningState string, exte
447447
case infrav1.Creating:
448448
m.V(4).Info("extension provisioning state is creating", "vm extension", extensionName, "scale set", m.Name())
449449
conditions.MarkFalse(m.AzureMachinePool, infrav1.BootstrapSucceededCondition, infrav1.BootstrapInProgressReason, clusterv1.ConditionSeverityInfo, "")
450-
return azure.WithTransientError(errors.New("extension still provisioning"), 30*time.Second)
450+
return azure.WithTransientError(errors.New("extension is still in provisioning state. This likely means that bootstrapping has not yet completed on the VM"), 30*time.Second)
451451
case infrav1.Failed:
452452
m.V(4).Info("extension provisioning state is failed", "vm extension", extensionName, "scale set", m.Name())
453453
conditions.MarkFalse(m.AzureMachinePool, infrav1.BootstrapSucceededCondition, infrav1.BootstrapFailedReason, clusterv1.ConditionSeverityError, "")
454-
return azure.WithTerminalError(errors.New("extension state failed"))
454+
return azure.WithTerminalError(errors.New("extension state failed. This likely means the Kubernetes node bootstrapping process failed or timed out. Check VM boot diagnostics logs to learn more"))
455455
default:
456456
return nil
457457
}

azure/scope/machinepool_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func TestMachinePoolScope_SetBootstrapConditions(t *testing.T) {
116116
return string(infrav1.Creating), "bazz"
117117
},
118118
Verify: func(g *WithT, amp *infrav1exp.AzureMachinePool, err error) {
119-
g.Expect(err).To(MatchError("reconcile error occurred that can be recovered. Object will be requeued after 30s The actual error is: extension still provisioning"))
119+
g.Expect(err).To(MatchError("transient reconcile error occurred: extension is still in provisioning state. This likely means that bootstrapping has not yet completed on the VM. Object will be requeued after 30s"))
120120
g.Expect(conditions.IsFalse(amp, infrav1.BootstrapSucceededCondition))
121121
g.Expect(conditions.GetReason(amp, infrav1.BootstrapSucceededCondition)).To(Equal(infrav1.BootstrapInProgressReason))
122122
severity := conditions.GetSeverity(amp, infrav1.BootstrapSucceededCondition)
@@ -130,7 +130,7 @@ func TestMachinePoolScope_SetBootstrapConditions(t *testing.T) {
130130
return string(infrav1.Failed), "buzz"
131131
},
132132
Verify: func(g *WithT, amp *infrav1exp.AzureMachinePool, err error) {
133-
g.Expect(err).To(MatchError("reconcile error occurred that cannot be recovered. Object will not be requeued. The actual error is: extension state failed"))
133+
g.Expect(err).To(MatchError("reconcile error that cannot be recovered occurred: extension state failed. This likely means the Kubernetes node bootstrapping process failed or timed out. Check VM boot diagnostics logs to learn more. Object will not be requeued"))
134134
g.Expect(conditions.IsFalse(amp, infrav1.BootstrapSucceededCondition))
135135
g.Expect(conditions.GetReason(amp, infrav1.BootstrapSucceededCondition)).To(Equal(infrav1.BootstrapFailedReason))
136136
severity := conditions.GetSeverity(amp, infrav1.BootstrapSucceededCondition)

azure/services/scalesets/scalesets_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ func TestReconcileVMSS(t *testing.T) {
402402
},
403403
{
404404
name: "creating a vmss with encryption at host enabled for unsupported VM type fails",
405-
expectedError: "reconcile error occurred that cannot be recovered. Object will not be requeued. The actual error is: encryption at host is not supported for VM type VM_SIZE",
405+
expectedError: "reconcile error that cannot be recovered occurred: encryption at host is not supported for VM type VM_SIZE. Object will not be requeued",
406406
expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, m *mock_scalesets.MockClientMockRecorder) {
407407
s.ScaleSetSpec().Return(azure.ScaleSetSpec{
408408
Name: defaultVMSSName,
@@ -444,7 +444,7 @@ func TestReconcileVMSS(t *testing.T) {
444444
},
445445
{
446446
name: "less than 2 vCPUs",
447-
expectedError: "reconcile error occurred that cannot be recovered. Object will not be requeued. The actual error is: vm size should be bigger or equal to at least 2 vCPUs",
447+
expectedError: "reconcile error that cannot be recovered occurred: vm size should be bigger or equal to at least 2 vCPUs. Object will not be requeued",
448448
expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, m *mock_scalesets.MockClientMockRecorder) {
449449
s.ScaleSetSpec().Return(azure.ScaleSetSpec{
450450
Name: defaultVMSSName,
@@ -456,7 +456,7 @@ func TestReconcileVMSS(t *testing.T) {
456456
},
457457
{
458458
name: "Memory is less than 2Gi",
459-
expectedError: "reconcile error occurred that cannot be recovered. Object will not be requeued. The actual error is: vm memory should be bigger or equal to at least 2Gi",
459+
expectedError: "reconcile error that cannot be recovered occurred: vm memory should be bigger or equal to at least 2Gi. Object will not be requeued",
460460
expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, m *mock_scalesets.MockClientMockRecorder) {
461461
s.ScaleSetSpec().Return(azure.ScaleSetSpec{
462462
Name: defaultVMSSName,
@@ -468,7 +468,7 @@ func TestReconcileVMSS(t *testing.T) {
468468
},
469469
{
470470
name: "failed to get SKU",
471-
expectedError: "reconcile error occurred that cannot be recovered. Object will not be requeued. The actual error is: failed to get SKU INVALID_VM_SIZE in compute api: resource sku with name 'INVALID_VM_SIZE' and category 'virtualMachines' not found in location 'test-location'",
471+
expectedError: "reconcile error that cannot be recovered occurred: failed to get SKU INVALID_VM_SIZE in compute api: resource sku with name 'INVALID_VM_SIZE' and category 'virtualMachines' not found in location 'test-location'. Object will not be requeued",
472472
expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, m *mock_scalesets.MockClientMockRecorder) {
473473
s.ScaleSetSpec().Return(azure.ScaleSetSpec{
474474
Name: defaultVMSSName,

azure/services/virtualmachines/virtualmachines_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,7 @@ func TestReconcileVM(t *testing.T) {
11171117
m.Get(gomockinternal.AContext(), "my-rg", "my-vm").
11181118
Return(compute.VirtualMachine{}, autorest.NewErrorWithResponse("", "", &http.Response{StatusCode: 404}, "Not found"))
11191119
},
1120-
ExpectedError: "reconcile error occurred that cannot be recovered. Object will not be requeued. The actual error is: encryption at host is not supported for VM type Standard_D2v3",
1120+
ExpectedError: "reconcile error that cannot be recovered occurred: encryption at host is not supported for VM type Standard_D2v3. Object will not be requeued",
11211121
SetupSKUs: func(svc *Service) {
11221122
skus := []compute.ResourceSku{
11231123
{
@@ -1252,7 +1252,7 @@ func TestReconcileVM(t *testing.T) {
12521252
m.Get(gomockinternal.AContext(), "my-rg", "my-vm").
12531253
Return(compute.VirtualMachine{}, autorest.NewErrorWithResponse("", "", &http.Response{StatusCode: 404}, "Not found"))
12541254
},
1255-
ExpectedError: "reconcile error occurred that cannot be recovered. Object will not be requeued. The actual error is: vm size should be bigger or equal to at least 2 vCPUs",
1255+
ExpectedError: "reconcile error that cannot be recovered occurred: vm size should be bigger or equal to at least 2 vCPUs. Object will not be requeued",
12561256
SetupSKUs: func(svc *Service) {
12571257
skus := []compute.ResourceSku{
12581258
{
@@ -1319,7 +1319,7 @@ func TestReconcileVM(t *testing.T) {
13191319
m.Get(gomockinternal.AContext(), "my-rg", "my-vm").
13201320
Return(compute.VirtualMachine{}, autorest.NewErrorWithResponse("", "", &http.Response{StatusCode: 404}, "Not found"))
13211321
},
1322-
ExpectedError: "reconcile error occurred that cannot be recovered. Object will not be requeued. The actual error is: vm memory should be bigger or equal to at least 2Gi",
1322+
ExpectedError: "reconcile error that cannot be recovered occurred: vm memory should be bigger or equal to at least 2Gi. Object will not be requeued",
13231323
SetupSKUs: func(svc *Service) {
13241324
skus := []compute.ResourceSku{
13251325
{
@@ -1389,7 +1389,7 @@ func TestReconcileVM(t *testing.T) {
13891389
m.Get(gomockinternal.AContext(), "my-rg", "my-vm").
13901390
Return(compute.VirtualMachine{}, autorest.NewErrorWithResponse("", "", &http.Response{StatusCode: 404}, "Not found"))
13911391
},
1392-
ExpectedError: "reconcile error occurred that cannot be recovered. Object will not be requeued. The actual error is: vm size Standard_D2v3 does not support ephemeral os. select a different vm size or disable ephemeral os",
1392+
ExpectedError: "reconcile error that cannot be recovered occurred: vm size Standard_D2v3 does not support ephemeral os. select a different vm size or disable ephemeral os. Object will not be requeued",
13931393
SetupSKUs: func(svc *Service) {
13941394
skus := []compute.ResourceSku{
13951395
{

0 commit comments

Comments
 (0)