-
Notifications
You must be signed in to change notification settings - Fork 52
OSASINFRA-3960: Migrate OpenStack InfraCluster controller in-tree #411
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
openshift-merge-bot
merged 12 commits into
openshift:main
from
shiftstack:migrate-openstack-infracluster-controller
Dec 4, 2025
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5632602
powervs: Trivial error log fix
stephenfin 0b82954
openstack: Add in-tree implementation
stephenfin a050d7a
openstack: Implement network detection
stephenfin 0967160
openstack: Add e2e tests
stephenfin 4d41e19
openstack: Run local e2e tests
stephenfin b701c0c
openstack: Address review comments
stephenfin 1d4eade
openstack: Add credentials request
stephenfin c451352
openstack: Add images to manifests
stephenfin 7deb04d
Bump gophercloud
stephenfin 8dbd707
openstack: Stop setting ManagedBy annotation
stephenfin 2169beb
openstack: Make better use of framework utils
stephenfin a028609
openstack: Explicitly disable caching
stephenfin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,167 @@ | ||
| package e2e | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| "github.com/onsi/gomega/format" | ||
| configv1 "github.com/openshift/api/config/v1" | ||
| mapiv1alpha1 "github.com/openshift/api/machine/v1alpha1" | ||
| mapiv1beta1 "github.com/openshift/api/machine/v1beta1" | ||
| "github.com/openshift/cluster-capi-operator/e2e/framework" | ||
| corev1 "k8s.io/api/core/v1" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "k8s.io/utils/ptr" | ||
| clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" | ||
| "sigs.k8s.io/controller-runtime/pkg/client" | ||
| yaml "sigs.k8s.io/yaml" | ||
|
|
||
| openstackv1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1" | ||
|
|
||
| . "github.com/onsi/ginkgo/v2" | ||
| . "github.com/onsi/gomega" | ||
| ) | ||
|
|
||
| const ( | ||
| openStackMachineTemplateName = "openstack-machine-template" | ||
| ) | ||
|
|
||
| var _ = Describe("Cluster API OpenStack MachineSet", Ordered, func() { | ||
| var ( | ||
| machineSet *clusterv1.MachineSet | ||
| mapiMachineSpec *mapiv1alpha1.OpenstackProviderSpec | ||
| openStackMachineTemplate *openstackv1.OpenStackMachineTemplate | ||
| ) | ||
|
|
||
| BeforeAll(func() { | ||
| if platform != configv1.OpenStackPlatformType { | ||
| Skip("Skipping OpenStack E2E tests") | ||
| } | ||
| mapiMachineSpec = getOpenStackMAPIProviderSpec(cl) | ||
| }) | ||
|
|
||
| AfterEach(func() { | ||
| if platform != configv1.OpenStackPlatformType { | ||
| // Because AfterEach always runs, even when tests are skipped, we have to | ||
| // explicitly skip it here for other platforms. | ||
| Skip("Skipping OpenStack E2E tests") | ||
| } | ||
|
|
||
| framework.DeleteMachineSets(ctx, cl, machineSet) | ||
| framework.WaitForMachineSetsDeleted(cl, machineSet) | ||
| framework.DeleteObjects(ctx, cl, openStackMachineTemplate) | ||
| }) | ||
|
|
||
| It("should be able to run a machine with implicit cluster default network", func() { | ||
| openStackMachineTemplate = createOpenStackMachineTemplate(ctx, cl, mapiMachineSpec) | ||
|
|
||
| machineSet = framework.CreateMachineSet(ctx, cl, framework.NewMachineSetParams( | ||
| "openstack-machineset", | ||
| clusterName, | ||
| "", | ||
| 1, | ||
| corev1.ObjectReference{ | ||
| Kind: "OpenStackMachineTemplate", | ||
| APIVersion: infraAPIVersion, | ||
| Name: openStackMachineTemplate.Name, | ||
| }, | ||
| "worker-user-data", | ||
| )) | ||
|
|
||
| framework.WaitForMachineSet(cl, machineSet.Name, machineSet.Namespace) | ||
| }) | ||
| }) | ||
|
|
||
| func getOpenStackMAPIProviderSpec(cl client.Client) *mapiv1alpha1.OpenstackProviderSpec { | ||
| machineSetList := &mapiv1beta1.MachineSetList{} | ||
| Eventually(cl.List(ctx, machineSetList, client.InNamespace(framework.MAPINamespace))).Should(Succeed()) | ||
|
|
||
| Expect(machineSetList.Items).ToNot(HaveLen(0), "No MachineSets found in namespace %s", framework.MAPINamespace) | ||
| machineSet := machineSetList.Items[0] | ||
| Expect(machineSet.Spec.Template.Spec.ProviderSpec.Value).ToNot(BeNil()) | ||
|
|
||
| providerSpec := &mapiv1alpha1.OpenstackProviderSpec{} | ||
| Expect(yaml.Unmarshal(machineSet.Spec.Template.Spec.ProviderSpec.Value.Raw, providerSpec)).To(Succeed()) | ||
|
|
||
| return providerSpec | ||
| } | ||
|
|
||
| func createOpenStackMachineTemplate(ctx context.Context, cl client.Client, mapiProviderSpec *mapiv1alpha1.OpenstackProviderSpec) *openstackv1.OpenStackMachineTemplate { | ||
| By("Creating OpenStack machine template") | ||
|
|
||
| Expect(mapiProviderSpec).ToNot(BeNil()) | ||
| Expect(mapiProviderSpec.Flavor).ToNot(BeEmpty()) | ||
| // NOTE(stephenfin): Installer does not populate ps.Image when ps.RootVolume is set and will | ||
| // instead populate ps.RootVolume.SourceUUID. Moreover, according to the ClusterOSImage option | ||
| // definition this is always the name of the image and never the UUID. We should allow UUID | ||
| // at some point and this will need an update. | ||
| if mapiProviderSpec.RootVolume != nil { | ||
| Expect(mapiProviderSpec.RootVolume.SourceUUID).ToNot(BeEmpty()) | ||
| } else { | ||
| Expect(mapiProviderSpec.Image).ToNot(BeEmpty()) | ||
| } | ||
| Expect(len(mapiProviderSpec.Networks)).To(BeNumerically(">", 0)) | ||
| Expect(len(mapiProviderSpec.Networks[0].Subnets)).To(BeNumerically(">", 0)) | ||
| Expect(mapiProviderSpec.Tags).ToNot(BeNil()) | ||
| Expect(len(mapiProviderSpec.Tags)).To(BeNumerically(">", 0)) | ||
|
|
||
| var image openstackv1.ImageParam | ||
| var rootVolume *openstackv1.RootVolume | ||
|
|
||
| if mapiProviderSpec.RootVolume != nil { | ||
| rootVolume = &openstackv1.RootVolume{ | ||
| SizeGiB: mapiProviderSpec.RootVolume.Size, | ||
| BlockDeviceVolume: openstackv1.BlockDeviceVolume{ | ||
| Type: mapiProviderSpec.RootVolume.VolumeType, | ||
| AvailabilityZone: &openstackv1.VolumeAvailabilityZone{ | ||
| From: openstackv1.VolumeAZFromName, | ||
| Name: ptr.To(openstackv1.VolumeAZName(mapiProviderSpec.RootVolume.Zone)), | ||
| }, | ||
| }, | ||
| } | ||
| image.ID = ptr.To(mapiProviderSpec.RootVolume.SourceUUID) | ||
| } else { | ||
| image.Filter = &openstackv1.ImageFilter{Name: &mapiProviderSpec.Image} | ||
| } | ||
|
|
||
| // NOTE(stephenfin): We intentionally ignore additional security for now. | ||
| var securityGroupParam openstackv1.SecurityGroupParam | ||
| Expect(len(mapiProviderSpec.SecurityGroups)).To(BeNumerically(">", 0)) | ||
| securityGroup := mapiProviderSpec.SecurityGroups[0] | ||
| if securityGroup.UUID != "" { | ||
| securityGroupParam = openstackv1.SecurityGroupParam{ID: &securityGroup.UUID} | ||
| } else { | ||
| securityGroupParam = openstackv1.SecurityGroupParam{Filter: &openstackv1.SecurityGroupFilter{Name: securityGroup.Name}} | ||
| } | ||
| securityGroups := []openstackv1.SecurityGroupParam{ | ||
| securityGroupParam, | ||
| } | ||
|
|
||
| // We intentionally omit ports so the machine will default its network | ||
| // from the OpenStackCluster created by the infracluster controller. | ||
| openStackMachineSpec := openstackv1.OpenStackMachineSpec{ | ||
| Flavor: ptr.To(mapiProviderSpec.Flavor), | ||
| IdentityRef: &openstackv1.OpenStackIdentityReference{ | ||
| CloudName: "openstack", | ||
| Name: "openstack-cloud-credentials", | ||
| }, | ||
| Image: image, | ||
| RootVolume: rootVolume, | ||
| SecurityGroups: securityGroups, | ||
| } | ||
|
|
||
| openStackMachineTemplate := &openstackv1.OpenStackMachineTemplate{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| GenerateName: openStackMachineTemplateName + "-", | ||
| Namespace: framework.CAPINamespace, | ||
| }, | ||
| Spec: openstackv1.OpenStackMachineTemplateSpec{ | ||
| Template: openstackv1.OpenStackMachineTemplateResource{ | ||
| Spec: openStackMachineSpec, | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| Expect(cl.Create(ctx, openStackMachineTemplate)).To(Succeed(), format.Object(openStackMachineTemplate, 1)) | ||
|
|
||
| return openStackMachineTemplate | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,7 @@ | ||
| #!/bin/bash | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -euo pipefail | ||
| # TODO(stephenfin): This is legacy from when the OpenStack e2e tests lived | ||
| # elsewhere. We should remove this script and update the CI jobs to call the | ||
| # Makefile target like everyone else | ||
|
|
||
| echo "Running e2e-openstack.sh" | ||
|
|
||
| unset GOFLAGS | ||
| tmp="$(mktemp -d)" | ||
|
|
||
| echo "cloning github.com/openshift/cluster-api-provider-openstack at branch '$PULL_BASE_REF'" | ||
| git clone --single-branch --branch="$PULL_BASE_REF" --depth=1 "https://github.com/openshift/cluster-api-provider-openstack.git" "$tmp" | ||
|
|
||
| echo "running cluster-api-provider-openstack's: make e2e" | ||
| exec make -C "$tmp/openshift" e2e | ||
| exec make e2e | ||
stephenfin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.