Skip to content

Commit

Permalink
Introduce AWSMachine and AWSCluster feature gates
Browse files Browse the repository at this point in the history
  • Loading branch information
mzazrivec committed Jan 29, 2025
1 parent ba78656 commit 6dbdfb1
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 21 deletions.
10 changes: 10 additions & 0 deletions feature/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ const (
// owner: @enxebre
// alpha: v2.2
ROSA featuregate.Feature = "ROSA"

// owner: @mzazrivec
// alpha: v2.7
AWSMachine featuregate.Feature = "AWSMachine"

// owner: @mzazrivec
// alpha: v2.7
AWSCluster featuregate.Feature = "AWSCluster"
)

func init() {
Expand All @@ -108,4 +116,6 @@ var defaultCAPAFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec{
AlternativeGCStrategy: {Default: false, PreRelease: featuregate.Alpha},
TagUnmanagedNetworkResources: {Default: true, PreRelease: featuregate.Alpha},
ROSA: {Default: false, PreRelease: featuregate.Alpha},
AWSMachine: {Default: true, PreRelease: featuregate.Beta},
AWSCluster: {Default: true, PreRelease: featuregate.Beta},
}
51 changes: 30 additions & 21 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,29 +298,38 @@ func main() {
func setupReconcilersAndWebhooks(ctx context.Context, mgr ctrl.Manager, awsServiceEndpoints []scope.ServiceEndpoint,
externalResourceGC, alternativeGCStrategy bool,
) {
if err := (&controllers.AWSMachineReconciler{
Client: mgr.GetClient(),
Log: ctrl.Log.WithName("controllers").WithName("AWSMachine"),
Recorder: mgr.GetEventRecorderFor("awsmachine-controller"),
Endpoints: awsServiceEndpoints,
WatchFilterValue: watchFilterValue,
TagUnmanagedNetworkResources: feature.Gates.Enabled(feature.TagUnmanagedNetworkResources),
}).SetupWithManager(ctx, mgr, controller.Options{MaxConcurrentReconciles: awsMachineConcurrency, RecoverPanic: ptr.To[bool](true)}); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "AWSMachine")
os.Exit(1)
if feature.Gates.Enabled(feature.AWSMachine) {
setupLog.Debug("enabling AWSMachine controller and webhook")
if !feature.Gates.Enabled(feature.AWSCluster) {
setupLog.Warn("Enabling AWSMachine with disabled AWSCluster may lead to incorrectly functioning setup")
}
if err := (&controllers.AWSMachineReconciler{
Client: mgr.GetClient(),
Log: ctrl.Log.WithName("controllers").WithName("AWSMachine"),
Recorder: mgr.GetEventRecorderFor("awsmachine-controller"),
Endpoints: awsServiceEndpoints,
WatchFilterValue: watchFilterValue,
TagUnmanagedNetworkResources: feature.Gates.Enabled(feature.TagUnmanagedNetworkResources),
}).SetupWithManager(ctx, mgr, controller.Options{MaxConcurrentReconciles: awsMachineConcurrency, RecoverPanic: ptr.To[bool](true)}); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "AWSMachine")
os.Exit(1)
}
}

if err := (&controllers.AWSClusterReconciler{
Client: mgr.GetClient(),
Recorder: mgr.GetEventRecorderFor("awscluster-controller"),
Endpoints: awsServiceEndpoints,
WatchFilterValue: watchFilterValue,
ExternalResourceGC: externalResourceGC,
AlternativeGCStrategy: alternativeGCStrategy,
TagUnmanagedNetworkResources: feature.Gates.Enabled(feature.TagUnmanagedNetworkResources),
}).SetupWithManager(ctx, mgr, controller.Options{MaxConcurrentReconciles: awsClusterConcurrency, RecoverPanic: ptr.To[bool](true)}); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "AWSCluster")
os.Exit(1)
if feature.Gates.Enabled(feature.AWSCluster) {
setupLog.Debug("enabling AWSCluster controller and webhook")
if err := (&controllers.AWSClusterReconciler{
Client: mgr.GetClient(),
Recorder: mgr.GetEventRecorderFor("awscluster-controller"),
Endpoints: awsServiceEndpoints,
WatchFilterValue: watchFilterValue,
ExternalResourceGC: externalResourceGC,
AlternativeGCStrategy: alternativeGCStrategy,
TagUnmanagedNetworkResources: feature.Gates.Enabled(feature.TagUnmanagedNetworkResources),
}).SetupWithManager(ctx, mgr, controller.Options{MaxConcurrentReconciles: awsClusterConcurrency, RecoverPanic: ptr.To[bool](true)}); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "AWSCluster")
os.Exit(1)
}
}

if feature.Gates.Enabled(feature.MachinePool) {
Expand Down

0 comments on commit 6dbdfb1

Please sign in to comment.