Skip to content

Commit 20811e4

Browse files
committed
openshift: Bump to CAPO v0.10.0
1 parent 91e4dcf commit 20811e4

File tree

11 files changed

+11072
-4665
lines changed

11 files changed

+11072
-4665
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: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
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
8-
github.com/onsi/ginkgo/v2 v2.13.0
9-
github.com/onsi/gomega v1.28.1
8+
github.com/onsi/ginkgo/v2 v2.15.0
9+
github.com/onsi/gomega v1.30.0
1010
github.com/openshift/api v0.0.0-20231003083825-c3f7566f6ef6
1111
github.com/openshift/cluster-capi-operator/e2e v0.0.0-20231122173658-8acf83f7bf5c
12-
k8s.io/api v0.28.2
13-
k8s.io/apimachinery v0.28.2
14-
k8s.io/client-go v0.28.1
15-
sigs.k8s.io/cluster-api v1.5.3
16-
sigs.k8s.io/cluster-api-provider-openstack v0.8.0
17-
sigs.k8s.io/controller-runtime v0.16.2
18-
sigs.k8s.io/yaml v1.3.0
12+
k8s.io/api v0.29.3
13+
k8s.io/apimachinery v0.29.3
14+
k8s.io/client-go v0.29.3
15+
k8s.io/utils v0.0.0-20230726121419-3b25d923346b
16+
sigs.k8s.io/cluster-api v1.6.0
17+
sigs.k8s.io/cluster-api-provider-openstack v0.10.0
18+
sigs.k8s.io/controller-runtime v0.16.3
19+
sigs.k8s.io/yaml v1.4.0
1920
)
2021

2122
require (
2223
github.com/beorn7/perks v1.0.1 // indirect
23-
github.com/blang/semver v3.5.1+incompatible // indirect
2424
github.com/blang/semver/v4 v4.0.0 // indirect
2525
github.com/cespare/xxhash/v2 v2.2.0 // indirect
26-
github.com/davecgh/go-spew v1.1.1 // indirect
27-
github.com/emicklei/go-restful/v3 v3.10.2 // indirect
28-
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
29-
github.com/fsnotify/fsnotify v1.6.0 // indirect
26+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
27+
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
28+
github.com/evanphx/json-patch/v5 v5.7.0 // indirect
29+
github.com/fsnotify/fsnotify v1.7.0 // indirect
3030
github.com/go-logr/zapr v1.2.4 // indirect
3131
github.com/go-openapi/jsonpointer v0.19.6 // indirect
3232
github.com/go-openapi/jsonreference v0.20.2 // indirect
@@ -36,7 +36,7 @@ require (
3636
github.com/gogo/protobuf v1.3.2 // indirect
3737
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
3838
github.com/golang/mock v1.6.0 // indirect
39-
github.com/golang/protobuf v1.5.3 // indirect
39+
github.com/golang/protobuf v1.5.4 // indirect
4040
github.com/google/gnostic-models v0.6.8 // indirect
4141
github.com/google/go-cmp v0.6.0 // indirect
4242
github.com/google/gofuzz v1.2.0 // indirect
@@ -59,30 +59,28 @@ require (
5959
github.com/prometheus/common v0.44.0 // indirect
6060
github.com/prometheus/procfs v0.11.1 // indirect
6161
github.com/spf13/pflag v1.0.5 // indirect
62-
github.com/stretchr/testify v1.8.4 // indirect
6362
go.uber.org/multierr v1.11.0 // indirect
6463
go.uber.org/zap v1.25.0 // indirect
6564
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
66-
golang.org/x/net v0.17.0 // indirect
67-
golang.org/x/oauth2 v0.13.0 // indirect
68-
golang.org/x/sys v0.13.0 // indirect
69-
golang.org/x/term v0.13.0 // indirect
70-
golang.org/x/text v0.13.0 // indirect
65+
golang.org/x/net v0.19.0 // indirect
66+
golang.org/x/oauth2 v0.14.0 // indirect
67+
golang.org/x/sys v0.15.0 // indirect
68+
golang.org/x/term v0.15.0 // indirect
69+
golang.org/x/text v0.14.0 // indirect
7170
golang.org/x/time v0.3.0 // indirect
72-
golang.org/x/tools v0.14.0 // indirect
71+
golang.org/x/tools v0.16.1 // indirect
7372
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
7473
google.golang.org/appengine v1.6.7 // indirect
75-
google.golang.org/protobuf v1.31.0 // indirect
74+
google.golang.org/protobuf v1.33.0 // indirect
7675
gopkg.in/inf.v0 v0.9.1 // indirect
7776
gopkg.in/yaml.v2 v2.4.0 // indirect
7877
gopkg.in/yaml.v3 v3.0.1 // indirect
79-
k8s.io/apiextensions-apiserver v0.28.0 // indirect
80-
k8s.io/component-base v0.28.1 // indirect
81-
k8s.io/klog/v2 v2.100.1 // indirect
82-
k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect
83-
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
78+
k8s.io/apiextensions-apiserver v0.29.3 // indirect
79+
k8s.io/component-base v0.29.3 // indirect
80+
k8s.io/klog/v2 v2.110.1 // indirect
81+
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
8482
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
85-
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
83+
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
8684
)
8785

8886
replace sigs.k8s.io/cluster-api-provider-openstack => ../

0 commit comments

Comments
 (0)