Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move webhook registration behind feature gate flag #5099

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 53 additions & 49 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,11 @@ func registerWebhooks(mgr manager.Manager) {
os.Exit(1)
}

if err := infrav1.SetupAzureMachineWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "AzureMachine")
os.Exit(1)
}

if err := (&infrav1.AzureMachineTemplate{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "AzureMachineTemplate")
os.Exit(1)
Expand All @@ -599,66 +604,65 @@ func registerWebhooks(mgr manager.Manager) {
os.Exit(1)
}

if err := (&infrav1exp.AzureMachinePoolMachine{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "AzureMachinePoolMachine")
os.Exit(1)
}

// NOTE: AzureManagedCluster is behind AKS feature gate flag; the webhook
// is going to prevent creating or updating new objects in case the feature flag is disabled
if err := (&infrav1.AzureManagedCluster{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "AzureManagedCluster")
os.Exit(1)
}
if feature.Gates.Enabled(capifeature.MachinePool) {
if err := infrav1exp.SetupAzureMachinePoolWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "AzureMachinePool")
os.Exit(1)
}

if err := (&infrav1.AzureManagedClusterTemplate{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "AzureManagedClusterTemplate")
os.Exit(1)
}
if err := (&infrav1exp.AzureMachinePoolMachine{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "AzureMachinePoolMachine")
os.Exit(1)
}

if err := infrav1exp.SetupAzureMachinePoolWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "AzureMachinePool")
os.Exit(1)
}
if err := infrav1.SetupAzureManagedMachinePoolWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "AzureManagedMachinePool")
os.Exit(1)
}

if err := infrav1.SetupAzureMachineWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "AzureMachine")
os.Exit(1)
}
if err := infrav1.SetupAzureManagedMachinePoolTemplateWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "AzureManagedMachinePoolTemplate")
os.Exit(1)
}

if err := infrav1.SetupAzureManagedMachinePoolWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "AzureManagedMachinePool")
os.Exit(1)
}
// NOTE: AzureManagedCluster is behind AKS feature gate flag; the webhook
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment still valid or can it be removed? Looks like its from a few years back.

// is going to prevent creating or updating new objects in case the feature flag is disabled
if err := (&infrav1.AzureManagedCluster{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "AzureManagedCluster")
os.Exit(1)
}

if err := infrav1.SetupAzureManagedMachinePoolTemplateWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "AzureManagedMachinePoolTemplate")
os.Exit(1)
}
if err := (&infrav1.AzureManagedClusterTemplate{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "AzureManagedClusterTemplate")
os.Exit(1)
}

if err := infrav1.SetupAzureManagedControlPlaneWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "AzureManagedControlPlane")
os.Exit(1)
}
if err := infrav1.SetupAzureManagedControlPlaneWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "AzureManagedControlPlane")
os.Exit(1)
}

if err := infrav1.SetupAzureManagedControlPlaneTemplateWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "AzureManagedControlPlaneTemplate")
os.Exit(1)
if err := infrav1.SetupAzureManagedControlPlaneTemplateWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "AzureManagedControlPlaneTemplate")
os.Exit(1)
}
}

if err := infrav1alpha.SetupAzureASOManagedClusterWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "AzureASOManagedCluster")
os.Exit(1)
}
if feature.Gates.Enabled(feature.ASOAPI) {
if err := infrav1alpha.SetupAzureASOManagedClusterWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "AzureASOManagedCluster")
os.Exit(1)
}

if err := infrav1alpha.SetupAzureASOManagedControlPlaneWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "AzureASOManagedControlPlane")
os.Exit(1)
}
if err := infrav1alpha.SetupAzureASOManagedControlPlaneWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "AzureASOManagedControlPlane")
os.Exit(1)
}

if err := infrav1alpha.SetupAzureASOManagedMachinePoolWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "AzureASOManagedMachinePool")
os.Exit(1)
if err := infrav1alpha.SetupAzureASOManagedMachinePoolWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "AzureASOManagedMachinePool")
os.Exit(1)
}
}

if err := mgr.AddReadyzCheck("webhook", mgr.GetWebhookServer().StartedChecker()); err != nil {
Expand Down