Skip to content

Commit f2e2ef3

Browse files
authored
removed SetBootstrapCondition (#3120)
* removed SetBootstrapCodition * removed the unused imports * Used make-lint
1 parent 2d0f3a2 commit f2e2ef3

File tree

3 files changed

+0
-113
lines changed

3 files changed

+0
-113
lines changed

azure/scope/machine.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"encoding/base64"
2222
"encoding/json"
2323
"strings"
24-
"time"
2524

2625
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2021-11-01/compute"
2726
"github.com/Azure/go-autorest/autorest/to"
@@ -565,29 +564,6 @@ func (m *MachineScope) SetConditionFalse(conditionType clusterv1.ConditionType,
565564
conditions.MarkFalse(m.AzureMachine, conditionType, reason, severity, message)
566565
}
567566

568-
// SetBootstrapConditions sets the AzureMachine BootstrapSucceeded condition based on the extension provisioning states.
569-
func (m *MachineScope) SetBootstrapConditions(ctx context.Context, provisioningState string, extensionName string) error {
570-
_, log, done := tele.StartSpanWithLogger(ctx, "scope.MachineScope.SetBootstrapConditions")
571-
defer done()
572-
573-
switch infrav1.ProvisioningState(provisioningState) {
574-
case infrav1.Succeeded:
575-
log.V(4).Info("extension provisioning state is succeeded", "vm extension", extensionName, "virtual machine", m.Name())
576-
conditions.MarkTrue(m.AzureMachine, infrav1.BootstrapSucceededCondition)
577-
return nil
578-
case infrav1.Creating:
579-
log.V(4).Info("extension provisioning state is creating", "vm extension", extensionName, "virtual machine", m.Name())
580-
conditions.MarkFalse(m.AzureMachine, infrav1.BootstrapSucceededCondition, infrav1.BootstrapInProgressReason, clusterv1.ConditionSeverityInfo, "")
581-
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)
582-
case infrav1.Failed:
583-
log.V(4).Info("extension provisioning state is failed", "vm extension", extensionName, "virtual machine", m.Name())
584-
conditions.MarkFalse(m.AzureMachine, infrav1.BootstrapSucceededCondition, infrav1.BootstrapFailedReason, clusterv1.ConditionSeverityError, "")
585-
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"))
586-
default:
587-
return nil
588-
}
589-
}
590-
591567
// SetAnnotation sets a key value annotation on the AzureMachine.
592568
func (m *MachineScope) SetAnnotation(key, value string) {
593569
if m.AzureMachine.Annotations == nil {

azure/scope/machinepool.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"encoding/base64"
2222
"fmt"
2323
"strings"
24-
"time"
2524

2625
azureautorest "github.com/Azure/go-autorest/autorest/azure"
2726
"github.com/Azure/go-autorest/autorest/to"
@@ -458,29 +457,6 @@ func (m *MachinePoolScope) SetFailureReason(v capierrors.MachineStatusError) {
458457
m.AzureMachinePool.Status.FailureReason = &v
459458
}
460459

461-
// SetBootstrapConditions sets the AzureMachinePool BootstrapSucceeded condition based on the extension provisioning states.
462-
func (m *MachinePoolScope) SetBootstrapConditions(ctx context.Context, provisioningState string, extensionName string) error {
463-
_, log, done := tele.StartSpanWithLogger(ctx, "scope.MachinePoolScope.SetBootstrapConditions")
464-
defer done()
465-
466-
switch infrav1.ProvisioningState(provisioningState) {
467-
case infrav1.Succeeded:
468-
log.V(4).Info("extension provisioning state is succeeded", "vm extension", extensionName, "scale set", m.Name())
469-
conditions.MarkTrue(m.AzureMachinePool, infrav1.BootstrapSucceededCondition)
470-
return nil
471-
case infrav1.Creating:
472-
log.V(4).Info("extension provisioning state is creating", "vm extension", extensionName, "scale set", m.Name())
473-
conditions.MarkFalse(m.AzureMachinePool, infrav1.BootstrapSucceededCondition, infrav1.BootstrapInProgressReason, clusterv1.ConditionSeverityInfo, "")
474-
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)
475-
case infrav1.Failed:
476-
log.V(4).Info("extension provisioning state is failed", "vm extension", extensionName, "scale set", m.Name())
477-
conditions.MarkFalse(m.AzureMachinePool, infrav1.BootstrapSucceededCondition, infrav1.BootstrapFailedReason, clusterv1.ConditionSeverityError, "")
478-
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"))
479-
default:
480-
return nil
481-
}
482-
}
483-
484460
// AdditionalTags merges AdditionalTags from the scope's AzureCluster and AzureMachinePool. If the same key is present in both,
485461
// the value from AzureMachinePool takes precedence.
486462
func (m *MachinePoolScope) AdditionalTags() infrav1.Tags {

azure/scope/machinepool_test.go

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import (
3838
infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1"
3939
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
4040
expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1"
41-
"sigs.k8s.io/cluster-api/util/conditions"
4241
"sigs.k8s.io/controller-runtime/pkg/client/fake"
4342
)
4443

@@ -181,70 +180,6 @@ func TestMachinePoolScope_NetworkInterfaces(t *testing.T) {
181180
}
182181
}
183182

184-
func TestMachinePoolScope_SetBootstrapConditions(t *testing.T) {
185-
cases := []struct {
186-
Name string
187-
Setup func() (provisioningState string, extensionName string)
188-
Verify func(g *WithT, amp *infrav1exp.AzureMachinePool, err error)
189-
}{
190-
{
191-
Name: "should set bootstrap succeeded condition if provisioning state succeeded",
192-
Setup: func() (provisioningState string, extensionName string) {
193-
return string(infrav1.Succeeded), "foo"
194-
},
195-
Verify: func(g *WithT, amp *infrav1exp.AzureMachinePool, err error) {
196-
g.Expect(err).NotTo(HaveOccurred())
197-
g.Expect(conditions.IsTrue(amp, infrav1.BootstrapSucceededCondition))
198-
},
199-
},
200-
{
201-
Name: "should set bootstrap succeeded false condition with reason if provisioning state creating",
202-
Setup: func() (provisioningState string, extensionName string) {
203-
return string(infrav1.Creating), "bazz"
204-
},
205-
Verify: func(g *WithT, amp *infrav1exp.AzureMachinePool, err error) {
206-
g.Expect(err).To(MatchError("extension is still in provisioning state. This likely means that bootstrapping has not yet completed on the VM. Object will be requeued after 30s"))
207-
g.Expect(conditions.IsFalse(amp, infrav1.BootstrapSucceededCondition))
208-
g.Expect(conditions.GetReason(amp, infrav1.BootstrapSucceededCondition)).To(Equal(infrav1.BootstrapInProgressReason))
209-
severity := conditions.GetSeverity(amp, infrav1.BootstrapSucceededCondition)
210-
g.Expect(severity).NotTo(BeNil())
211-
g.Expect(*severity).To(Equal(clusterv1.ConditionSeverityInfo))
212-
},
213-
},
214-
{
215-
Name: "should set bootstrap succeeded false condition with reason if provisioning state failed",
216-
Setup: func() (provisioningState string, extensionName string) {
217-
return string(infrav1.Failed), "buzz"
218-
},
219-
Verify: func(g *WithT, amp *infrav1exp.AzureMachinePool, err error) {
220-
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"))
221-
g.Expect(conditions.IsFalse(amp, infrav1.BootstrapSucceededCondition))
222-
g.Expect(conditions.GetReason(amp, infrav1.BootstrapSucceededCondition)).To(Equal(infrav1.BootstrapFailedReason))
223-
severity := conditions.GetSeverity(amp, infrav1.BootstrapSucceededCondition)
224-
g.Expect(severity).NotTo(BeNil())
225-
g.Expect(*severity).To(Equal(clusterv1.ConditionSeverityError))
226-
},
227-
},
228-
}
229-
230-
for _, c := range cases {
231-
t.Run(c.Name, func(t *testing.T) {
232-
var (
233-
g = NewWithT(t)
234-
mockCtrl = gomock.NewController(t)
235-
)
236-
defer mockCtrl.Finish()
237-
238-
state, name := c.Setup()
239-
s := &MachinePoolScope{
240-
AzureMachinePool: &infrav1exp.AzureMachinePool{},
241-
}
242-
err := s.SetBootstrapConditions(context.TODO(), state, name)
243-
c.Verify(g, s.AzureMachinePool, err)
244-
})
245-
}
246-
}
247-
248183
func TestMachinePoolScope_MaxSurge(t *testing.T) {
249184
cases := []struct {
250185
Name string

0 commit comments

Comments
 (0)