Skip to content

Commit

Permalink
Test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
willie-yao committed Dec 8, 2023
1 parent 4fb90e8 commit c668049
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
30 changes: 22 additions & 8 deletions api/v1beta1/azuremanagedcontrolplane_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,6 @@ func (mw *azureManagedControlPlaneWebhook) ValidateUpdate(ctx context.Context, o
allErrs = append(allErrs, err)
}

if err := webhookutils.ValidateImmutable(
field.NewPath("Spec", "FleetsMember.Name"),
m.Spec.FleetsMember.Name,
old.Spec.FleetsMember.Name,
); err != nil {
allErrs = append(allErrs, err)
}

// Consider removing this once moves out of preview
// Updating outboundType after cluster creation (PREVIEW)
// https://learn.microsoft.com/en-us/azure/aks/egress-outboundtype#updating-outboundtype-after-cluster-creation-preview
Expand Down Expand Up @@ -258,6 +250,10 @@ func (mw *azureManagedControlPlaneWebhook) ValidateUpdate(ctx context.Context, o
allErrs = append(allErrs, errs...)
}

if errs := m.validateFleetsMember(old); len(errs) > 0 {
allErrs = append(allErrs, errs...)
}

if len(allErrs) == 0 {
return nil, m.Validate(mw.Client)
}
Expand Down Expand Up @@ -685,6 +681,24 @@ func (m *AzureManagedControlPlane) validateOIDCIssuerProfileUpdate(old *AzureMan
return allErrs
}

// validateFleetsMember validates a FleetsMember.
func (m *AzureManagedControlPlane) validateFleetsMember(old *AzureManagedControlPlane) field.ErrorList {
var allErrs field.ErrorList

if old.Spec.FleetsMember != nil && m.Spec.FleetsMember != nil {
if old.Spec.FleetsMember.Name != m.Spec.FleetsMember.Name {
allErrs = append(allErrs,
field.Forbidden(
field.NewPath("Spec", "FleetsMember", "Name"),
"Name is immutable",
),
)
}
}

return allErrs
}

func validateName(name string, fldPath *field.Path) field.ErrorList {
var allErrs field.ErrorList
if lName := strings.ToLower(name); strings.Contains(lName, "microsoft") ||
Expand Down
9 changes: 4 additions & 5 deletions test/e2e/aks_fleets_member.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,10 @@ func AKSFleetsMemberSpec(ctx context.Context, inputGetter func() AKSFleetsMember
Location: ptr.To(os.Getenv(AzureLocation)),
}, nil)
Expect(err).To(BeNil())

Eventually(func(g Gomega) {
_, err := poller.PollUntilDone(ctx, nil)
Expect(err).NotTo(HaveOccurred())
}, input.WaitIntervals...).Should(Succeed(), "failed to create fleet manager")
res, err := poller.PollUntilDone(ctx, nil)
Expect(err).To(BeNil())
Logf("Fleet manager created: %v", res.Fleet.Name)
Logf("Fleet manager arm id: %v", *res.Fleet.ID)

By("Joining the cluster to the fleet hub")
var infraControlPlane = &infrav1.AzureManagedControlPlane{}
Expand Down

0 comments on commit c668049

Please sign in to comment.