Skip to content

Commit

Permalink
🌱 Bump CAPI to v1.8.4 (kubernetes-sigs#5061)
Browse files Browse the repository at this point in the history
* capi v1.8.0-beta.0

* use source.Kind generics

* update e2e testing versions

* set terminationMessagePolicy to FallbackToLogsOnError for manager

* bump go version to 1.22

* Update metrics options for new types

Signed-off-by: Nolan Brubaker <[email protected]>

* Update to CAPI 1.8.3

Signed-off-by: Nolan Brubaker <[email protected]>

* Fix test linting

Signed-off-by: Nolan Brubaker <[email protected]>

* Use latest versions of setup-envtest

Signed-off-by: Nolan Brubaker <[email protected]>

* Update generation tools for Kube 1.30

We carry a very small patch for the conversion-gen tool so that we can
support having types of the same name in both the standard and
experimental APIs. During the v1.30 timeframe, the Kubernetes code
generation tools were refactored to more modern Go module standards,
while also cleaning up the code.

This commit carries the v1.30 (specifically,
commit 304c1999892b41b6a3ff5dae260253f39cf53660) changes for the main.go
and conversion.go files, alongside our patch.

This commit also includes the updated conversion code output by our
vendored/forked conversion_gen tool.

Signed-off-by: Nolan Brubaker <[email protected]>

* Update to CAPI 1.8.4

---------

Signed-off-by: Nolan Brubaker <[email protected]>
Co-authored-by: Nolan Brubaker <[email protected]>
  • Loading branch information
2 people authored and fad3t committed Oct 24, 2024
1 parent 93a286d commit a071084
Show file tree
Hide file tree
Showing 45 changed files with 571 additions and 529 deletions.
56 changes: 26 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ E2E_SKIP_EKS_UPGRADE ?= "false"
EKS_SOURCE_TEMPLATE ?= eks/cluster-template-eks-control-plane-only.yaml

# set up `setup-envtest` to install kubebuilder dependency
export KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ?= 1.28.3
SETUP_ENVTEST_VER := v0.0.0-20240531134648-6636df17d67b
export KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ?= 1.30.2
SETUP_ENVTEST_VER := v0.0.0-20240923090159-236e448db12c
SETUP_ENVTEST_BIN := setup-envtest
SETUP_ENVTEST := $(abspath $(TOOLS_BIN_DIR)/$(SETUP_ENVTEST_BIN)-$(SETUP_ENVTEST_VER))
SETUP_ENVTEST_PKG := sigs.k8s.io/controller-runtime/tools/setup-envtest
Expand Down Expand Up @@ -194,14 +194,15 @@ endif
.PHONY: defaulters
defaulters: $(DEFAULTER_GEN) ## Generate all Go types
$(DEFAULTER_GEN) \
--input-dirs=./api/v1beta2 \
--input-dirs=./$(EXP_DIR)/api/v1beta2 \
--input-dirs=./controlplane/rosa/api/v1beta2 \
--input-dirs=./cmd/clusterawsadm/api/bootstrap/v1beta1 \
--input-dirs=./cmd/clusterawsadm/api/bootstrap/v1alpha1 \
--extra-peer-dirs=sigs.k8s.io/cluster-api/api/v1beta1 \
--v=0 $(GEN_OUTPUT_BASE) \
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt
--v=0 \
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt \
--output-file=zz_generated.defaults.go \
./api/v1beta2 \
./$(EXP_DIR)/api/v1beta2 \
./controlplane/rosa/api/v1beta2 \
./cmd/clusterawsadm/api/bootstrap/v1beta1 \
./cmd/clusterawsadm/api/bootstrap/v1alpha1

.PHONY: generate
generate: ## Generate code
Expand Down Expand Up @@ -251,44 +252,39 @@ generate-go-apis: ## Alias for .build/generate-go-apis
$(MAKE) defaulters

$(CONVERSION_GEN) \
--input-dirs=./api/v1beta1 \
--input-dirs=./cmd/clusterawsadm/api/bootstrap/v1alpha1 \
--extra-peer-dirs=sigs.k8s.io/cluster-api/api/v1beta1 \
--build-tag=ignore_autogenerated_conversions \
--output-file-base=zz_generated.conversion $(GEN_OUTPUT_BASE) \
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt
--output-file=zz_generated.conversion.go \
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt \
./api/v1beta1 \
./cmd/clusterawsadm/api/bootstrap/v1alpha1

$(CONVERSION_GEN) \
--input-dirs=./$(EXP_DIR)/api/v1beta1 \
--extra-peer-dirs=sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta1 \
--extra-peer-dirs=sigs.k8s.io/cluster-api/api/v1beta1 \
--build-tag=ignore_autogenerated_conversions \
--output-file-base=zz_generated.conversion $(GEN_OUTPUT_BASE) \
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt
--output-file=zz_generated.conversion.go \
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt \
./$(EXP_DIR)/api/v1beta1

$(CONVERSION_GEN) \
--input-dirs=./bootstrap/eks/api/v1beta1 \
--extra-peer-dirs=sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta1 \
--extra-peer-dirs=sigs.k8s.io/cluster-api/api/v1beta1 \
--build-tag=ignore_autogenerated_conversions \
--output-file-base=zz_generated.conversion $(GEN_OUTPUT_BASE) \
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt
--output-file=zz_generated.conversion.go \
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt \
./bootstrap/eks/api/v1beta1

$(CONVERSION_GEN) \
--input-dirs=./controlplane/eks/api/v1beta1 \
--extra-peer-dirs=sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta1 \
--extra-peer-dirs=sigs.k8s.io/cluster-api/api/v1beta1 \
--build-tag=ignore_autogenerated_conversions \
--output-file-base=zz_generated.conversion $(GEN_OUTPUT_BASE) \
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt
--output-file=zz_generated.conversion.go \
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt \
./controlplane/eks/api/v1beta1

$(CONVERSION_GEN) \
--input-dirs=./controlplane/rosa/api/v1beta2 \
--extra-peer-dirs=sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta1 \
--extra-peer-dirs=sigs.k8s.io/cluster-api/api/v1beta1 \
--build-tag=ignore_autogenerated_conversions \
--output-file-base=zz_generated.conversion $(GEN_OUTPUT_BASE) \
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt
--output-file=zz_generated.conversion.go \
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt \
./controlplane/rosa/api/v1beta2

touch $@

Expand Down
4 changes: 2 additions & 2 deletions api/v1beta1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions bootstrap/eks/api/v1beta1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bootstrap/eks/api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bootstrap/eks/api/v1beta2/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ limitations under the License.
// Package v1beta2 contains API Schema definitions for the Amazon EKS Bootstrap v1beta2 API group.
// +gencrdrefdocs:force //nolint: revive
// +groupName=bootstrap.cluster.x-k8s.io
// +k8s:conversion-gen=sigs.k8s.io/cluster-api-provider-aws/v2/bootstrap/eks/api/v1beta1
package v1beta2
6 changes: 3 additions & 3 deletions bootstrap/eks/controllers/eksconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,9 @@ func (r *EKSConfigReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Man
}

err = c.Watch(
source.Kind(mgr.GetCache(), &clusterv1.Cluster{}),
handler.EnqueueRequestsFromMapFunc((r.ClusterToEKSConfigs)),
predicates.ClusterUnpausedAndInfrastructureReady(logger.FromContext(ctx).GetLogger()),
source.Kind[client.Object](mgr.GetCache(), &clusterv1.Cluster{},
handler.EnqueueRequestsFromMapFunc((r.ClusterToEKSConfigs)),
predicates.ClusterUnpausedAndInfrastructureReady(logger.FromContext(ctx).GetLogger())),
)
if err != nil {
return errors.Wrap(err, "failed adding watch for Clusters to controller manager")
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -959,10 +959,15 @@ spec:
description: The key to select.
type: string
name:
default: ""
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
TODO: Add other useful fields. apiVersion, kind, uid?
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896.
type: string
optional:
description: Specify whether the ConfigMap or its
Expand Down Expand Up @@ -1022,10 +1027,15 @@ spec:
be a valid secret key.
type: string
name:
default: ""
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
TODO: Add other useful fields. apiVersion, kind, uid?
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896.
type: string
optional:
description: Specify whether the Secret or its key
Expand Down Expand Up @@ -3010,10 +3020,15 @@ spec:
description: The key to select.
type: string
name:
default: ""
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
TODO: Add other useful fields. apiVersion, kind, uid?
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896.
type: string
optional:
description: Specify whether the ConfigMap or its
Expand Down Expand Up @@ -3073,10 +3088,15 @@ spec:
be a valid secret key.
type: string
name:
default: ""
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
TODO: Add other useful fields. apiVersion, kind, uid?
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896.
type: string
optional:
description: Specify whether the Secret or its key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,15 @@ spec:
- ocmApiUrl: Optional, defaults to 'https://api.openshift.com'
properties:
name:
default: ""
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
TODO: Add other useful fields. apiVersion, kind, uid?
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896.
type: string
type: object
x-kubernetes-map-type: atomic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,13 @@ spec:
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- key
- operator
type: object
type: array
x-kubernetes-list-type: atomic
matchLabels:
additionalProperties:
type: string
Expand Down Expand Up @@ -186,11 +188,13 @@ spec:
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- key
- operator
type: object
type: array
x-kubernetes-list-type: atomic
matchLabels:
additionalProperties:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,13 @@ spec:
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- key
- operator
type: object
type: array
x-kubernetes-list-type: atomic
matchLabels:
additionalProperties:
type: string
Expand Down Expand Up @@ -245,11 +247,13 @@ spec:
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- key
- operator
type: object
type: array
x-kubernetes-list-type: atomic
matchLabels:
additionalProperties:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,13 @@ spec:
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- key
- operator
type: object
type: array
x-kubernetes-list-type: atomic
matchLabels:
additionalProperties:
type: string
Expand Down Expand Up @@ -196,11 +198,13 @@ spec:
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- key
- operator
type: object
type: array
x-kubernetes-list-type: atomic
matchLabels:
additionalProperties:
type: string
Expand Down
1 change: 1 addition & 0 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ spec:
- ALL
runAsUser: 65532
runAsGroup: 65532
terminationMessagePolicy: FallbackToLogsOnError
securityContext:
runAsNonRoot: true
seccompProfile:
Expand Down
8 changes: 4 additions & 4 deletions controllers/awscluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,10 +413,10 @@ func (r *AWSClusterReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Ma
}

return controller.Watch(
source.Kind(mgr.GetCache(), &clusterv1.Cluster{}),
handler.EnqueueRequestsFromMapFunc(r.requeueAWSClusterForUnpausedCluster(ctx, log)),
predicates.ClusterUnpaused(log.GetLogger()),
)
source.Kind[client.Object](mgr.GetCache(), &clusterv1.Cluster{},
handler.EnqueueRequestsFromMapFunc(r.requeueAWSClusterForUnpausedCluster(ctx, log)),
predicates.ClusterUnpaused(log.GetLogger()),
))
}

func (r *AWSClusterReconciler) requeueAWSClusterForUnpausedCluster(_ context.Context, log logger.Wrapper) handler.MapFunc {
Expand Down
6 changes: 3 additions & 3 deletions controllers/awsmachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,9 @@ func (r *AWSMachineReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Ma

requeueAWSMachinesForUnpausedCluster := r.requeueAWSMachinesForUnpausedCluster(log)
return controller.Watch(
source.Kind(mgr.GetCache(), &clusterv1.Cluster{}),
handler.EnqueueRequestsFromMapFunc(requeueAWSMachinesForUnpausedCluster),
predicates.ClusterUnpausedAndInfrastructureReady(log.GetLogger()),
source.Kind[client.Object](mgr.GetCache(), &clusterv1.Cluster{},
handler.EnqueueRequestsFromMapFunc(requeueAWSMachinesForUnpausedCluster),
predicates.ClusterUnpausedAndInfrastructureReady(log.GetLogger())),
)
}

Expand Down
10 changes: 5 additions & 5 deletions controllers/awsmanagedcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,17 @@ func (r *AWSManagedClusterReconciler) SetupWithManager(ctx context.Context, mgr

// Add a watch for clusterv1.Cluster unpaise
if err = controller.Watch(
source.Kind(mgr.GetCache(), &clusterv1.Cluster{}),
handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(ctx, infrav1.GroupVersion.WithKind("AWSManagedCluster"), mgr.GetClient(), &infrav1.AWSManagedCluster{})),
predicates.ClusterUnpaused(log.GetLogger()),
source.Kind[client.Object](mgr.GetCache(), &clusterv1.Cluster{},
handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(ctx, infrav1.GroupVersion.WithKind("AWSManagedCluster"), mgr.GetClient(), &infrav1.AWSManagedCluster{})),
predicates.ClusterUnpaused(log.GetLogger())),
); err != nil {
return fmt.Errorf("failed adding a watch for ready clusters: %w", err)
}

// Add a watch for AWSManagedControlPlane
if err = controller.Watch(
source.Kind(mgr.GetCache(), &ekscontrolplanev1.AWSManagedControlPlane{}),
handler.EnqueueRequestsFromMapFunc(r.managedControlPlaneToManagedCluster(ctx, log)),
source.Kind[client.Object](mgr.GetCache(), &ekscontrolplanev1.AWSManagedControlPlane{},
handler.EnqueueRequestsFromMapFunc(r.managedControlPlaneToManagedCluster(ctx, log))),
); err != nil {
return fmt.Errorf("failed adding watch on AWSManagedControlPlane: %w", err)
}
Expand Down
Loading

0 comments on commit a071084

Please sign in to comment.