cluster-api-provider-openstack icon indicating copy to clipboard operation
cluster-api-provider-openstack copied to clipboard

✨ Allow for omitting AZ from control plane nodes

Open mkjpryor opened this issue 3 years ago • 7 comments

What this PR does / why we need it:

Allows control plane nodes to be created that do not specify a failure domain (availability zone). This is important for clouds that rely on other Nova scheduler features for placement, e.g. host aggregates, project isolation filters, flavor traits.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged): Fixes #1252

Special notes for your reviewer:

  1. Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

TODOs:

  • [ ] squashed commits
  • if necessary:
    • [ ] includes documentation
    • [ ] adds unit tests

/hold

mkjpryor avatar Aug 01 '22 16:08 mkjpryor

Deploy Preview for kubernetes-sigs-cluster-api-openstack ready!

Name Link
Latest commit 5b138e7fe931562cb2902bf31755042399461c83
Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cluster-api-openstack/deploys/631f62da0b8538000850ae71
Deploy Preview https://deploy-preview-1318--kubernetes-sigs-cluster-api-openstack.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

netlify[bot] avatar Aug 01 '22 16:08 netlify[bot]

Hi @mkjpryor. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Aug 01 '22 16:08 k8s-ci-robot

@mdbooth I finally got round to redoing this PR by setting the flag instead of not reporting AZs at all.

mkjpryor avatar Aug 01 '22 16:08 mkjpryor

/ok-to-test

jichenjc avatar Aug 08 '22 01:08 jichenjc

@jichenjc

I am trying to run make generate to fix the test error, and it keeps trying to remove the Convert_v1alpha6_OpenStackClusterSpec_To_v1alpha5_OpenStackClusterSpec function. Any idea why?

$ make verify-gen
/Library/Developer/CommandLineTools/usr/bin/make generate-go
/Library/Developer/CommandLineTools/usr/bin/make -B hack/tools/bin/controller-gen hack/tools/bin/conversion-gen hack/tools/bin/defaulter-gen
make -C hack/tools bin/controller-gen
mkdir -p bin
go build -tags=tools -o bin/controller-gen sigs.k8s.io/controller-tools/cmd/controller-gen
make -C hack/tools bin/conversion-gen
mkdir -p bin
go build -tags=tools -o bin/conversion-gen k8s.io/code-generator/cmd/conversion-gen
make -C hack/tools bin/defaulter-gen
mkdir -p bin
go build -tags=tools -o bin/defaulter-gen k8s.io/code-generator/cmd/defaulter-gen
hack/tools/bin/controller-gen \
                paths=./api/... \
                object:headerFile=./hack/boilerplate/boilerplate.generatego.txt
hack/tools/bin/conversion-gen \
                --input-dirs=./api/v1alpha3 \
                --input-dirs=./api/v1alpha4 \
                --input-dirs=./api/v1alpha5 \
                --input-dirs=./api/v1alpha6 \
                --output-file-base=zz_generated.conversion \
                --go-header-file=./hack/boilerplate/boilerplate.generatego.txt
E0808 09:19:11.926895   92381 conversion.go:756] Warning: could not find nor generate a final Conversion function for sigs.k8s.io/cluster-api-provider-openstack/api/v1alpha6.OpenStackClusterSpec -> ./api/v1alpha5.OpenStackClusterSpec
E0808 09:19:11.927014   92381 conversion.go:757]   the following fields need manual conversion:
E0808 09:19:11.927017   92381 conversion.go:759]       - ControlPlaneOmitAvailabilityZone
go generate ./...
/Library/Developer/CommandLineTools/usr/bin/make generate-manifests
hack/tools/bin/controller-gen \
                paths=./api/... \
                crd:crdVersions=v1 \
                output:crd:dir=config/crd/bases \
                output:webhook:dir=config/webhook \
                webhook
hack/tools/bin/controller-gen \
                paths=./controllers/... \
                output:rbac:dir=config/rbac \
                rbac:roleName=manager-role
diff --git a/api/v1alpha5/zz_generated.conversion.go b/api/v1alpha5/zz_generated.conversion.go
index 26249eae..875b7030 100644
--- a/api/v1alpha5/zz_generated.conversion.go
+++ b/api/v1alpha5/zz_generated.conversion.go
@@ -856,11 +856,6 @@ func autoConvert_v1alpha6_OpenStackClusterSpec_To_v1alpha5_OpenStackClusterSpec(
        return nil
 }
 
-// Convert_v1alpha6_OpenStackClusterSpec_To_v1alpha5_OpenStackClusterSpec is an autogenerated conversion function.
-func Convert_v1alpha6_OpenStackClusterSpec_To_v1alpha5_OpenStackClusterSpec(in *v1alpha6.OpenStackClusterSpec, out *OpenStackClusterSpec, s conversion.Scope) error {
-       return autoConvert_v1alpha6_OpenStackClusterSpec_To_v1alpha5_OpenStackClusterSpec(in, out, s)
-}
-
 func autoConvert_v1alpha5_OpenStackClusterStatus_To_v1alpha6_OpenStackClusterStatus(in *OpenStackClusterStatus, out *v1alpha6.OpenStackClusterStatus, s conversion.Scope) error {
        out.Ready = in.Ready
        out.Network = (*v1alpha6.Network)(unsafe.Pointer(in.Network))
generated files are out of date, run make generate
make: *** [verify-gen] Error 1

mkjpryor avatar Aug 08 '22 08:08 mkjpryor

@jichenjc @mdbooth @apricote @tobiasgiese

I am still having issues with the code generation above. I think maybe I am not understanding exactly what needs to be done when a new field is added... Any advice would be greatly appreciated!

mkjpryor avatar Aug 24 '22 09:08 mkjpryor

I am still having issues with the code generation above. I think maybe I am not understanding exactly what needs to be done when a new field is added... Any advice would be greatly appreciated!

This is to be expected. conversion-gen recognizes that it can not automatically generate the full conversion, and adds a comment saying as much to autoConvert...:

https://github.com/kubernetes-sigs/cluster-api-provider-openstack/blob/8b988a2a028828e2d4055a91758086dda26ef547/api/v1alpha5/zz_generated.conversion.go#L853

At that point, we need to implement a custom Convert_... and conversion-gen helpfully removes the default it generates (otherwise this would cause conflicts!). You can check out an example of these custom Convert_ functions in v1alpha4:

https://github.com/kubernetes-sigs/cluster-api-provider-openstack/blob/4975828973c3b8e704302ae3417f2ca026ec750e/api/v1alpha4/openstackcluster_conversion.go#L46-L51

As you add a new field, you need to use utilconversion to save the field when round-tripping to older API versions. See how it is done in these diffs from #1247:

https://github.com/kubernetes-sigs/cluster-api-provider-openstack/pull/1247/files#diff-9a53c6afb893cfd6bb4f50185dea035075cb0ef25fce713667c270d5c9668a31R39-R47

https://github.com/kubernetes-sigs/cluster-api-provider-openstack/pull/1247/files#diff-9a53c6afb893cfd6bb4f50185dea035075cb0ef25fce713667c270d5c9668a31R59-R62

apricote avatar Aug 24 '22 10:08 apricote

@mkjpryor maybe you can refer to https://github.com/kubernetes-sigs/cluster-api-provider-openstack/pull/1323 At least I can pass all the test :)

jichenjc avatar Aug 25 '22 01:08 jichenjc

@jichenjc @apricote @mdbooth

Finally got the tests passing 🎉

mkjpryor avatar Sep 13 '22 07:09 mkjpryor

@apricote @mdbooth @tobiasgiese Anything else before this is good to go?

mkjpryor avatar Sep 13 '22 12:09 mkjpryor

@apricote @mdbooth @tobiasgiese Anything else before this is good to go?

I‘ll take a look tomorrow :)

tobiasgiese avatar Sep 13 '22 19:09 tobiasgiese

/lgtm

Let's wait for an answer of https://github.com/kubernetes-sigs/cluster-api-provider-openstack/issues/1252#issuecomment-1246313295. @jichenjc can approve afterwards

tobiasgiese avatar Sep 15 '22 14:09 tobiasgiese

/approve /hold cancel

jichenjc avatar Sep 16 '22 02:09 jichenjc

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jichenjc, mkjpryor

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

k8s-ci-robot avatar Sep 16 '22 02:09 k8s-ci-robot