Skip to content

Upgrade CAPI to 1.6 #422

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

Merged
merged 2 commits into from
Mar 21, 2025
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ managers:
manager-cloudstack-infrastructure: ## Build manager binary.
CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -ldflags "${LDFLAGS} -extldflags '-static'" -o $(BIN_DIR)/manager .

export K8S_VERSION=1.26.1
export K8S_VERSION=1.28.3
$(KUBECTL) $(API_SERVER) $(ETCD) &:
cd $(TOOLS_DIR) && curl --silent -L "https://go.kubebuilder.io/test-tools/${K8S_VERSION}/$(shell go env GOOS)/$(shell go env GOARCH)" --output - | \
tar -C ./ --strip-components=1 -zvxf -
Expand Down Expand Up @@ -244,7 +244,7 @@ delete-kind-cluster:
kind delete cluster --name $(KIND_CLUSTER_NAME)

cluster-api: ## Clone cluster-api repository for tilt use.
git clone --branch v1.4.8 --depth 1 https://github.com/kubernetes-sigs/cluster-api.git
git clone --branch v1.6.8 --depth 1 https://github.com/kubernetes-sigs/cluster-api.git

cluster-api/tilt-settings.json: hack/tilt-settings.json cluster-api
cp ./hack/tilt-settings.json cluster-api
Expand Down
2 changes: 1 addition & 1 deletion api/v1beta1/cloudstackaffinitygroup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@ type CloudStackAffinityGroupList struct {
}

func init() {
SchemeBuilder.Register(&CloudStackAffinityGroup{}, &CloudStackAffinityGroupList{})
objectTypes = append(objectTypes, &CloudStackAffinityGroup{}, &CloudStackAffinityGroupList{})
}
2 changes: 1 addition & 1 deletion api/v1beta1/cloudstackcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,5 @@ type CloudStackClusterList struct {
}

func init() {
SchemeBuilder.Register(&CloudStackCluster{}, &CloudStackClusterList{})
objectTypes = append(objectTypes, &CloudStackCluster{}, &CloudStackClusterList{})
}
2 changes: 1 addition & 1 deletion api/v1beta1/cloudstackisolatednetwork_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,5 @@ type CloudStackIsolatedNetworkList struct {
}

func init() {
SchemeBuilder.Register(&CloudStackIsolatedNetwork{}, &CloudStackIsolatedNetworkList{})
objectTypes = append(objectTypes, &CloudStackIsolatedNetwork{}, &CloudStackIsolatedNetworkList{})
}
2 changes: 1 addition & 1 deletion api/v1beta1/cloudstackmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,5 +180,5 @@ type CloudStackMachineList struct {
}

func init() {
SchemeBuilder.Register(&CloudStackMachine{}, &CloudStackMachineList{})
objectTypes = append(objectTypes, &CloudStackMachine{}, &CloudStackMachineList{})
}
2 changes: 1 addition & 1 deletion api/v1beta1/cloudstackmachinestatechecker_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ type CloudStackMachineStateCheckerList struct {
}

func init() {
SchemeBuilder.Register(&CloudStackMachineStateChecker{}, &CloudStackMachineStateCheckerList{})
objectTypes = append(objectTypes, &CloudStackMachineStateChecker{}, &CloudStackMachineStateCheckerList{})
}
2 changes: 1 addition & 1 deletion api/v1beta1/cloudstackmachinetemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ type CloudStackMachineTemplateList struct {
}

func init() {
SchemeBuilder.Register(&CloudStackMachineTemplate{}, &CloudStackMachineTemplateList{})
objectTypes = append(objectTypes, &CloudStackMachineTemplate{}, &CloudStackMachineTemplateList{})
}
2 changes: 1 addition & 1 deletion api/v1beta1/cloudstackzone_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@ type CloudStackZoneList struct {
}

func init() {
SchemeBuilder.Register(&CloudStackZone{}, &CloudStackZoneList{})
objectTypes = append(objectTypes, &CloudStackZone{}, &CloudStackZoneList{})
}
17 changes: 13 additions & 4 deletions api/v1beta1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,29 @@ limitations under the License.
package v1beta1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "infrastructure.cluster.x-k8s.io", Version: "v1beta1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
AddToScheme = schemeBuilder.AddToScheme

// So the auto-generated code can compile
localSchemeBuilder = &SchemeBuilder.SchemeBuilder
objectTypes = []runtime.Object{}

localSchemeBuilder = &schemeBuilder
)

func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(GroupVersion, objectTypes...)
metav1.AddToGroupVersion(scheme, GroupVersion)
return nil
}
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.

2 changes: 1 addition & 1 deletion api/v1beta2/cloudstackaffinitygroup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ type CloudStackAffinityGroupList struct {
}

func init() {
SchemeBuilder.Register(&CloudStackAffinityGroup{}, &CloudStackAffinityGroupList{})
objectTypes = append(objectTypes, &CloudStackAffinityGroup{}, &CloudStackAffinityGroupList{})
}
2 changes: 1 addition & 1 deletion api/v1beta2/cloudstackcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,5 @@ type CloudStackClusterList struct {
}

func init() {
SchemeBuilder.Register(&CloudStackCluster{}, &CloudStackClusterList{})
objectTypes = append(objectTypes, &CloudStackCluster{}, &CloudStackClusterList{})
}
2 changes: 1 addition & 1 deletion api/v1beta2/cloudstackfailuredomain_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,5 @@ type CloudStackFailureDomainList struct {
}

func init() {
SchemeBuilder.Register(&CloudStackFailureDomain{}, &CloudStackFailureDomainList{})
objectTypes = append(objectTypes, &CloudStackFailureDomain{}, &CloudStackFailureDomainList{})
}
2 changes: 1 addition & 1 deletion api/v1beta2/cloudstackisolatednetwork_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,5 @@ type CloudStackIsolatedNetworkList struct {
}

func init() {
SchemeBuilder.Register(&CloudStackIsolatedNetwork{}, &CloudStackIsolatedNetworkList{})
objectTypes = append(objectTypes, &CloudStackIsolatedNetwork{}, &CloudStackIsolatedNetworkList{})
}
2 changes: 1 addition & 1 deletion api/v1beta2/cloudstackmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,5 +182,5 @@ type CloudStackMachineList struct {
}

func init() {
SchemeBuilder.Register(&CloudStackMachine{}, &CloudStackMachineList{})
objectTypes = append(objectTypes, &CloudStackMachine{}, &CloudStackMachineList{})
}
2 changes: 1 addition & 1 deletion api/v1beta2/cloudstackmachinestatechecker_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ type CloudStackMachineStateCheckerList struct {
}

func init() {
SchemeBuilder.Register(&CloudStackMachineStateChecker{}, &CloudStackMachineStateCheckerList{})
objectTypes = append(objectTypes, &CloudStackMachineStateChecker{}, &CloudStackMachineStateCheckerList{})
}
2 changes: 1 addition & 1 deletion api/v1beta2/cloudstackmachinetemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ type CloudStackMachineTemplateList struct {
}

func init() {
SchemeBuilder.Register(&CloudStackMachineTemplate{}, &CloudStackMachineTemplateList{})
objectTypes = append(objectTypes, &CloudStackMachineTemplate{}, &CloudStackMachineTemplateList{})
}
18 changes: 13 additions & 5 deletions api/v1beta2/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,28 @@ limitations under the License.
package v1beta2

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "infrastructure.cluster.x-k8s.io", Version: "v1beta2"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
AddToScheme = schemeBuilder.AddToScheme

// localSchemeBuilder is used for type conversions.
localSchemeBuilder = &SchemeBuilder.SchemeBuilder
objectTypes = []runtime.Object{}

localSchemeBuilder = &schemeBuilder
)

func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(GroupVersion, objectTypes...)
metav1.AddToGroupVersion(scheme, GroupVersion)
return nil
}
2 changes: 1 addition & 1 deletion api/v1beta2/zz_generated.deepcopy.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/v1beta3/cloudstackaffinitygroup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ type CloudStackAffinityGroupList struct {
}

func init() {
SchemeBuilder.Register(&CloudStackAffinityGroup{}, &CloudStackAffinityGroupList{})
objectTypes = append(objectTypes, &CloudStackAffinityGroup{}, &CloudStackAffinityGroupList{})
}
2 changes: 1 addition & 1 deletion api/v1beta3/cloudstackcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,5 @@ type CloudStackClusterList struct {
}

func init() {
SchemeBuilder.Register(&CloudStackCluster{}, &CloudStackClusterList{})
objectTypes = append(objectTypes, &CloudStackCluster{}, &CloudStackClusterList{})
}
15 changes: 8 additions & 7 deletions api/v1beta3/cloudstackcluster_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

// log is for logging in this package.
Expand All @@ -53,7 +54,7 @@ func (r *CloudStackCluster) Default() {
var _ webhook.Validator = &CloudStackCluster{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (r *CloudStackCluster) ValidateCreate() error {
func (r *CloudStackCluster) ValidateCreate() (admission.Warnings, error) {
cloudstackclusterlog.V(1).Info("entered validate create webhook", "api resource name", r.Name)

var errorList field.ErrorList
Expand All @@ -80,18 +81,18 @@ func (r *CloudStackCluster) ValidateCreate() error {
}
}

return webhookutil.AggregateObjErrors(r.GroupVersionKind().GroupKind(), r.Name, errorList)
return nil, webhookutil.AggregateObjErrors(r.GroupVersionKind().GroupKind(), r.Name, errorList)
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (r *CloudStackCluster) ValidateUpdate(old runtime.Object) error {
func (r *CloudStackCluster) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
cloudstackclusterlog.V(1).Info("entered validate update webhook", "api resource name", r.Name)

spec := r.Spec

oldCluster, ok := old.(*CloudStackCluster)
if !ok {
return errors.NewBadRequest(fmt.Sprintf("expected a CloudStackCluster but got a %T", old))
return nil, errors.NewBadRequest(fmt.Sprintf("expected a CloudStackCluster but got a %T", old))
}
oldSpec := oldCluster.Spec

Expand All @@ -109,7 +110,7 @@ func (r *CloudStackCluster) ValidateUpdate(old runtime.Object) error {
"controlplaneendpoint.port", errorList)
}

return webhookutil.AggregateObjErrors(r.GroupVersionKind().GroupKind(), r.Name, errorList)
return nil, webhookutil.AggregateObjErrors(r.GroupVersionKind().GroupKind(), r.Name, errorList)
}

// ValidateFailureDomainUpdates verifies that at least one failure domain has not been deleted, and
Expand Down Expand Up @@ -150,8 +151,8 @@ func FailureDomainsEqual(fd1, fd2 CloudStackFailureDomainSpec) bool {
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (r *CloudStackCluster) ValidateDelete() error {
func (r *CloudStackCluster) ValidateDelete() (admission.Warnings, error) {
cloudstackclusterlog.V(1).Info("entered validate delete webhook", "api resource name", r.Name)
// No deletion validations. Deletion webhook not enabled.
return nil
return nil, nil
}
2 changes: 1 addition & 1 deletion api/v1beta3/cloudstackfailuredomain_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,5 @@ type CloudStackFailureDomainList struct {
}

func init() {
SchemeBuilder.Register(&CloudStackFailureDomain{}, &CloudStackFailureDomainList{})
objectTypes = append(objectTypes, &CloudStackFailureDomain{}, &CloudStackFailureDomainList{})
}
2 changes: 1 addition & 1 deletion api/v1beta3/cloudstackisolatednetwork_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,5 @@ type CloudStackIsolatedNetworkList struct {
}

func init() {
SchemeBuilder.Register(&CloudStackIsolatedNetwork{}, &CloudStackIsolatedNetworkList{})
objectTypes = append(objectTypes, &CloudStackIsolatedNetwork{}, &CloudStackIsolatedNetworkList{})
}
2 changes: 1 addition & 1 deletion api/v1beta3/cloudstackmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,5 @@ type CloudStackMachineList struct {
}

func init() {
SchemeBuilder.Register(&CloudStackMachine{}, &CloudStackMachineList{})
objectTypes = append(objectTypes, &CloudStackMachine{}, &CloudStackMachineList{})
}
15 changes: 8 additions & 7 deletions api/v1beta3/cloudstackmachine_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

// log is for logging in this package.
Expand All @@ -53,7 +54,7 @@ func (r *CloudStackMachine) Default() {
var _ webhook.Validator = &CloudStackMachine{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (r *CloudStackMachine) ValidateCreate() error {
func (r *CloudStackMachine) ValidateCreate() (admission.Warnings, error) {
cloudstackmachinelog.V(1).Info("entered validate create webhook", "api resource name", r.Name)

var errorList field.ErrorList
Expand All @@ -64,18 +65,18 @@ func (r *CloudStackMachine) ValidateCreate() error {
errorList = webhookutil.EnsureIntFieldsAreNotNegative(r.Spec.DiskOffering.CustomSize, "customSizeInGB", errorList)
}

return webhookutil.AggregateObjErrors(r.GroupVersionKind().GroupKind(), r.Name, errorList)
return nil, webhookutil.AggregateObjErrors(r.GroupVersionKind().GroupKind(), r.Name, errorList)
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (r *CloudStackMachine) ValidateUpdate(old runtime.Object) error {
func (r *CloudStackMachine) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
cloudstackmachinelog.V(1).Info("entered validate update webhook", "api resource name", r.Name)

var errorList field.ErrorList

oldMachine, ok := old.(*CloudStackMachine)
if !ok {
return errors.NewBadRequest(fmt.Sprintf("expected a CloudStackMachine but got a %T", old))
return nil, errors.NewBadRequest(fmt.Sprintf("expected a CloudStackMachine but got a %T", old))
}
oldSpec := oldMachine.Spec

Expand All @@ -98,12 +99,12 @@ func (r *CloudStackMachine) ValidateUpdate(old runtime.Object) error {
errorList = append(errorList, field.Forbidden(field.NewPath("spec", "AffinityGroupIDs"), "AffinityGroupIDs"))
}

return webhookutil.AggregateObjErrors(r.GroupVersionKind().GroupKind(), r.Name, errorList)
return nil, webhookutil.AggregateObjErrors(r.GroupVersionKind().GroupKind(), r.Name, errorList)
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (r *CloudStackMachine) ValidateDelete() error {
func (r *CloudStackMachine) ValidateDelete() (admission.Warnings, error) {
cloudstackmachinelog.V(1).Info("entered validate delete webhook", "api resource name", r.Name)
// No deletion validations. Deletion webhook not enabled.
return nil
return nil, nil
}
2 changes: 1 addition & 1 deletion api/v1beta3/cloudstackmachinestatechecker_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ type CloudStackMachineStateCheckerList struct {
}

func init() {
SchemeBuilder.Register(&CloudStackMachineStateChecker{}, &CloudStackMachineStateCheckerList{})
objectTypes = append(objectTypes, &CloudStackMachineStateChecker{}, &CloudStackMachineStateCheckerList{})
}
2 changes: 1 addition & 1 deletion api/v1beta3/cloudstackmachinetemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@ type CloudStackMachineTemplateList struct {
}

func init() {
SchemeBuilder.Register(&CloudStackMachineTemplate{}, &CloudStackMachineTemplateList{})
objectTypes = append(objectTypes, &CloudStackMachineTemplate{}, &CloudStackMachineTemplateList{})
}
Loading