Skip to content

Commit 13829ff

Browse files
mdboothmandre
authored andcommitted
openshift: Bump to CAPO v0.10.0
1 parent 735fa55 commit 13829ff

File tree

11 files changed

+11031
-4622
lines changed

11 files changed

+11031
-4622
lines changed

openshift/cmd/manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func main() {
130130
if err := (&infraclustercontroller.OpenShiftClusterReconciler{
131131
Client: mgr.GetClient(),
132132
Recorder: mgr.GetEventRecorderFor("openshiftcluster-controller"),
133-
ScopeFactory: scope.ScopeFactory,
133+
ScopeFactory: scope.NewFactory(1),
134134
}).SetupWithManager(mgr, controller.Options{}); err != nil {
135135
setupLog.Error(err, "unable to create controller", "controller", "OpenStackCluster")
136136
os.Exit(1)

openshift/e2e/e2e_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
runtimeclient "sigs.k8s.io/controller-runtime/pkg/client"
1515
"sigs.k8s.io/controller-runtime/pkg/client/config"
1616

17-
infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1alpha7"
17+
infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1"
1818
)
1919

2020
const (

openshift/e2e/openstack_test.go

Lines changed: 41 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -3,64 +3,55 @@ package e2e
33
import (
44
. "github.com/onsi/ginkgo/v2"
55
. "github.com/onsi/gomega"
6+
"github.com/onsi/gomega/format"
67
configv1 "github.com/openshift/api/config/v1"
78
mapiv1alpha1 "github.com/openshift/api/machine/v1alpha1"
89
mapiv1beta1 "github.com/openshift/api/machine/v1beta1"
910
"github.com/openshift/cluster-capi-operator/e2e/framework"
1011
corev1 "k8s.io/api/core/v1"
11-
apierrors "k8s.io/apimachinery/pkg/api/errors"
1212
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
13-
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
13+
"k8s.io/utils/ptr"
1414
"sigs.k8s.io/controller-runtime/pkg/client"
1515
yaml "sigs.k8s.io/yaml"
1616

1717
"github.com/openshift/cluster-api-provider-openstack/openshift/pkg/infraclustercontroller"
1818

19-
infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1alpha7"
19+
infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1"
2020
)
2121

2222
const (
2323
openStackMachineTemplateName = "openstack-machine-template"
2424
)
2525

2626
var _ = Describe("Cluster API OpenStack MachineSet", Ordered, func() {
27-
var openStackMachineTemplate *infrav1.OpenStackMachineTemplate
28-
var machineSet *clusterv1.MachineSet
2927
var mapiMachineSpec *mapiv1alpha1.OpenstackProviderSpec
3028

3129
BeforeAll(func() {
3230
if platform != configv1.OpenStackPlatformType {
3331
Skip("Skipping OpenStack E2E tests")
3432
}
35-
framework.CreateCoreCluster(cl, clusterName, "OpenStackCluster")
3633
mapiMachineSpec = getOpenStackMAPIProviderSpec(cl)
3734
})
3835

39-
AfterEach(func() {
40-
if platform != configv1.OpenStackPlatformType {
41-
// Because AfterEach always runs, even when tests are skipped, we have to
42-
// explicitly skip it here for other platforms.
43-
Skip("Skipping OpenStack E2E tests")
44-
}
45-
framework.DeleteMachineSets(cl, machineSet)
46-
framework.WaitForMachineSetsDeleted(cl, machineSet)
47-
framework.DeleteObjects(cl, openStackMachineTemplate)
48-
})
49-
50-
It("should be able to run a machine", func() {
51-
openStackMachineTemplate = createOpenStackMachineTemplate(cl, mapiMachineSpec)
36+
It("should be able to run a machine with implicit cluster default network", func() {
37+
openStackMachineTemplate := createOpenStackMachineTemplate(cl, mapiMachineSpec)
5238

53-
machineSet = framework.CreateMachineSet(cl, framework.NewMachineSetParams(
39+
machineSet := framework.CreateMachineSet(cl, framework.NewMachineSetParams(
5440
"openstack-machineset",
5541
clusterName,
5642
"",
5743
1,
5844
corev1.ObjectReference{
5945
Kind: "OpenStackMachineTemplate",
6046
APIVersion: infraAPIVersion,
61-
Name: openStackMachineTemplateName,
47+
Name: openStackMachineTemplate.Name,
6248
},
6349
))
50+
DeferCleanup(func() {
51+
By("Deleting machineset " + machineSet.Name)
52+
Expect(cl.Delete(ctx, machineSet)).To(Succeed())
53+
framework.WaitForMachineSetsDeleted(cl, machineSet)
54+
})
6455

6556
framework.WaitForMachineSet(cl, machineSet.Name)
6657
})
@@ -104,68 +95,48 @@ func createOpenStackMachineTemplate(cl client.Client, mapiProviderSpec *mapiv1al
10495

10596
if mapiProviderSpec.RootVolume != nil {
10697
rootVolume = &infrav1.RootVolume{
107-
Size: mapiProviderSpec.RootVolume.Size,
108-
VolumeType: mapiProviderSpec.RootVolume.VolumeType,
109-
AvailabilityZone: mapiProviderSpec.RootVolume.Zone,
98+
SizeGiB: mapiProviderSpec.RootVolume.Size,
99+
BlockDeviceVolume: infrav1.BlockDeviceVolume{
100+
Type: mapiProviderSpec.RootVolume.VolumeType,
101+
AvailabilityZone: &infrav1.VolumeAvailabilityZone{
102+
From: infrav1.VolumeAZFromName,
103+
Name: ptr.To(infrav1.VolumeAZName(mapiProviderSpec.RootVolume.Zone)),
104+
},
105+
},
110106
}
111107
} else {
112108
image = mapiProviderSpec.Image
113109
}
114110

115-
// NOTE(stephenfin): We intentionally ignore additional networks for now since we don't care
116-
// about e.g. Manila shares. We can re-evaluate this if necessary.
117-
ports := []infrav1.PortOpts{}
118-
for _, subnet := range mapiProviderSpec.Networks[0].Subnets {
119-
port := infrav1.PortOpts{
120-
FixedIPs: []infrav1.FixedIP{
121-
{
122-
Subnet: &infrav1.SubnetFilter{
123-
// NOTE(stephenfin): Only one of name or ID will be set.
124-
ID: subnet.Filter.ID,
125-
Name: subnet.Filter.Name,
126-
Tags: subnet.Filter.Tags,
127-
},
128-
},
129-
},
130-
}
131-
ports = append(ports, port)
132-
}
133-
port := infrav1.PortOpts{
134-
Network: &infrav1.NetworkFilter{
135-
// The installer still sets NetworkParam.Filter.ID rather than NetworkParam.ID,
136-
// at least as of 4.15.
137-
ID: mapiProviderSpec.Networks[0].Filter.ID, //nolint:staticcheck
138-
Name: mapiProviderSpec.Networks[0].Filter.Name,
139-
},
111+
// NOTE(stephenfin): We intentionally ignore additional security for now.
112+
var securityGroupParam infrav1.SecurityGroupParam
113+
securityGroup := mapiProviderSpec.SecurityGroups[0]
114+
if securityGroup.UUID != "" {
115+
securityGroupParam = infrav1.SecurityGroupParam{ID: &securityGroup.UUID}
116+
} else {
117+
securityGroupParam = infrav1.SecurityGroupParam{Filter: &infrav1.SecurityGroupFilter{Name: securityGroup.Name}}
140118
}
141-
ports = append(ports, port)
142-
143-
// NOTE(stephenfin): Ditto for security groups
144-
securityGroups := []infrav1.SecurityGroupFilter{
145-
{
146-
Name: mapiProviderSpec.SecurityGroups[0].Name,
147-
ID: mapiProviderSpec.SecurityGroups[0].UUID,
148-
},
119+
securityGroups := []infrav1.SecurityGroupParam{
120+
securityGroupParam,
149121
}
150122

123+
// We intentionally omit ports so the machine will default its network
124+
// from the OpenStackCluster created by the infracluster controller.
151125
openStackMachineSpec := infrav1.OpenStackMachineSpec{
152-
CloudName: infraclustercontroller.CloudName,
153-
Flavor: mapiProviderSpec.Flavor,
126+
Flavor: mapiProviderSpec.Flavor,
154127
IdentityRef: &infrav1.OpenStackIdentityReference{
155-
Kind: "Secret",
156-
Name: infraclustercontroller.CredentialsSecretName,
128+
CloudName: infraclustercontroller.CloudName,
129+
Name: infraclustercontroller.CredentialsSecretName,
157130
},
158-
Image: image,
159-
Ports: ports,
131+
Image: infrav1.ImageParam{Filter: &infrav1.ImageFilter{Name: &image}},
160132
RootVolume: rootVolume,
161133
SecurityGroups: securityGroups,
162-
Tags: mapiProviderSpec.Tags,
163134
}
164135

165136
openStackMachineTemplate := &infrav1.OpenStackMachineTemplate{
166137
ObjectMeta: metav1.ObjectMeta{
167-
Name: openStackMachineTemplateName,
168-
Namespace: framework.CAPINamespace,
138+
GenerateName: openStackMachineTemplateName + "-",
139+
Namespace: framework.CAPINamespace,
169140
},
170141
Spec: infrav1.OpenStackMachineTemplateSpec{
171142
Template: infrav1.OpenStackMachineTemplateResource{
@@ -174,9 +145,10 @@ func createOpenStackMachineTemplate(cl client.Client, mapiProviderSpec *mapiv1al
174145
},
175146
}
176147

177-
if err := cl.Create(ctx, openStackMachineTemplate); err != nil && !apierrors.IsAlreadyExists(err) {
178-
Expect(err).ToNot(HaveOccurred())
179-
}
148+
Expect(cl.Create(ctx, openStackMachineTemplate)).To(Succeed(), format.Object(openStackMachineTemplate, 1))
149+
DeferCleanup(func() error {
150+
return cl.Delete(ctx, openStackMachineTemplate)
151+
})
180152

181153
return openStackMachineTemplate
182154
}

openshift/go.mod

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
module github.com/openshift/cluster-api-provider-openstack/openshift
22

3-
go 1.20
3+
go 1.21
44

55
require (
6-
github.com/go-logr/logr v1.2.4
6+
github.com/go-logr/logr v1.3.0
77
github.com/gophercloud/gophercloud v1.7.0
88
github.com/openshift/api v0.0.0-20231003083825-c3f7566f6ef6
99
k8s.io/api v0.28.2
@@ -16,21 +16,20 @@ require (
1616

1717
require (
1818
github.com/beorn7/perks v1.0.1 // indirect
19-
github.com/blang/semver v3.5.1+incompatible // indirect
2019
github.com/blang/semver/v4 v4.0.0 // indirect
2120
github.com/cespare/xxhash/v2 v2.2.0 // indirect
22-
github.com/davecgh/go-spew v1.1.1 // indirect
23-
github.com/emicklei/go-restful/v3 v3.10.2 // indirect
24-
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
25-
github.com/fsnotify/fsnotify v1.6.0 // indirect
21+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
22+
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
23+
github.com/evanphx/json-patch/v5 v5.7.0 // indirect
24+
github.com/fsnotify/fsnotify v1.7.0 // indirect
2625
github.com/go-logr/zapr v1.2.4 // indirect
2726
github.com/go-openapi/jsonpointer v0.19.6 // indirect
2827
github.com/go-openapi/jsonreference v0.20.2 // indirect
2928
github.com/go-openapi/swag v0.22.3 // indirect
3029
github.com/gogo/protobuf v1.3.2 // indirect
3130
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
3231
github.com/golang/mock v1.6.0 // indirect
33-
github.com/golang/protobuf v1.5.3 // indirect
32+
github.com/golang/protobuf v1.5.4 // indirect
3433
github.com/google/gnostic-models v0.6.8 // indirect
3534
github.com/google/go-cmp v0.5.9 // indirect
3635
github.com/google/gofuzz v1.2.0 // indirect
@@ -55,15 +54,15 @@ require (
5554
go.uber.org/multierr v1.11.0 // indirect
5655
go.uber.org/zap v1.25.0 // indirect
5756
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
58-
golang.org/x/net v0.17.0 // indirect
59-
golang.org/x/oauth2 v0.13.0 // indirect
60-
golang.org/x/sys v0.13.0 // indirect
61-
golang.org/x/term v0.13.0 // indirect
62-
golang.org/x/text v0.13.0 // indirect
57+
golang.org/x/net v0.19.0 // indirect
58+
golang.org/x/oauth2 v0.14.0 // indirect
59+
golang.org/x/sys v0.15.0 // indirect
60+
golang.org/x/term v0.15.0 // indirect
61+
golang.org/x/text v0.14.0 // indirect
6362
golang.org/x/time v0.3.0 // indirect
6463
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
6564
google.golang.org/appengine v1.6.7 // indirect
66-
google.golang.org/protobuf v1.31.0 // indirect
65+
google.golang.org/protobuf v1.33.0 // indirect
6766
gopkg.in/inf.v0 v0.9.1 // indirect
6867
gopkg.in/yaml.v2 v2.4.0 // indirect
6968
gopkg.in/yaml.v3 v3.0.1 // indirect

0 commit comments

Comments
 (0)