Skip to content

Commit 8ac779d

Browse files
committed
Move ports management outside of instances
1 parent 5b2cc5b commit 8ac779d

25 files changed

+2365
-1293
lines changed

api/v1alpha5/conversion_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func TestConvertFrom(t *testing.T) {
7979
Spec: OpenStackMachineSpec{},
8080
ObjectMeta: metav1.ObjectMeta{
8181
Annotations: map[string]string{
82-
"cluster.x-k8s.io/conversion-data": "{\"spec\":{\"cloudName\":\"\",\"flavor\":\"\",\"image\":{}},\"status\":{\"ready\":false,\"referencedResources\":{}}}",
82+
"cluster.x-k8s.io/conversion-data": "{\"spec\":{\"cloudName\":\"\",\"flavor\":\"\",\"image\":{}},\"status\":{\"dependentResources\":{},\"ready\":false,\"referencedResources\":{}}}",
8383
},
8484
},
8585
},

api/v1alpha5/zz_generated.conversion.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha6/conversion.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ func restorev1alpha8ClusterStatus(previous *infrav1.OpenStackClusterStatus, dst
110110
if previous.Bastion != nil {
111111
dst.Bastion.ReferencedResources = previous.Bastion.ReferencedResources
112112
}
113+
114+
if previous.Bastion != nil && previous.Bastion.DependentResources.PortsStatus != nil {
115+
dst.Bastion.DependentResources.PortsStatus = previous.Bastion.DependentResources.PortsStatus
116+
}
113117
}
114118

115119
func restorev1alpha6ClusterSpec(previous *OpenStackClusterSpec, dst *OpenStackClusterSpec) {
@@ -328,7 +332,11 @@ var v1alpha8OpenStackMachineRestorer = conversion.RestorerFor[*infrav1.OpenStack
328332
},
329333
restorev1alpha8MachineSpec,
330334
),
331-
335+
"depresources": conversion.UnconditionalFieldRestorer(
336+
func(c *infrav1.OpenStackMachine) *infrav1.DependentMachineResources {
337+
return &c.Status.DependentResources
338+
},
339+
),
332340
// No equivalent in v1alpha6
333341
"refresources": conversion.UnconditionalFieldRestorer(
334342
func(c *infrav1.OpenStackMachine) *infrav1.ReferencedMachineResources {

api/v1alpha6/zz_generated.conversion.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha7/conversion.go

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,11 @@ var v1alpha8OpenStackClusterRestorer = conversion.RestorerFor[*infrav1.OpenStack
8484
},
8585
),
8686
),
87-
88-
// No equivalent in v1alpha7
89-
"bastionrefresources": conversion.UnconditionalFieldRestorer(
90-
func(c *infrav1.OpenStackCluster) *infrav1.ReferencedMachineResources {
91-
if c.Status.Bastion == nil {
92-
return nil
93-
}
94-
return &c.Status.Bastion.ReferencedResources
87+
"status": conversion.HashedFieldRestorer(
88+
func(c *infrav1.OpenStackCluster) *infrav1.OpenStackClusterStatus {
89+
return &c.Status
9590
},
91+
restorev1alpha8ClusterStatus,
9692
),
9793
}
9894

@@ -167,6 +163,16 @@ func restorev1alpha8ClusterSpec(previous *infrav1.OpenStackClusterSpec, dst *inf
167163
dst.ManagedSubnets = previous.ManagedSubnets
168164
}
169165

166+
func restorev1alpha8ClusterStatus(previous *infrav1.OpenStackClusterStatus, dst *infrav1.OpenStackClusterStatus) {
167+
if previous.Bastion != nil {
168+
dst.Bastion.ReferencedResources = previous.Bastion.ReferencedResources
169+
}
170+
171+
if previous.Bastion != nil && previous.Bastion.DependentResources.PortsStatus != nil {
172+
dst.Bastion.DependentResources.PortsStatus = previous.Bastion.DependentResources.PortsStatus
173+
}
174+
}
175+
170176
func (r *OpenStackCluster) ConvertTo(dstRaw ctrlconversion.Hub) error {
171177
dst := dstRaw.(*infrav1.OpenStackCluster)
172178

@@ -269,6 +275,11 @@ var v1alpha8OpenStackMachineRestorer = conversion.RestorerFor[*infrav1.OpenStack
269275
},
270276
restorev1alpha8MachineSpec,
271277
),
278+
"depresources": conversion.UnconditionalFieldRestorer(
279+
func(c *infrav1.OpenStackMachine) *infrav1.DependentMachineResources {
280+
return &c.Status.DependentResources
281+
},
282+
),
272283

273284
// No equivalent in v1alpha7
274285
"refresources": conversion.UnconditionalFieldRestorer(
@@ -535,3 +546,12 @@ func Convert_v1alpha8_OpenStackClusterSpec_To_v1alpha7_OpenStackClusterSpec(in *
535546

536547
return nil
537548
}
549+
550+
func Convert_v1alpha8_OpenStackClusterStatus_To_v1alpha7_OpenStackClusterStatus(in *infrav1.OpenStackClusterStatus, out *OpenStackClusterStatus, s apiconversion.Scope) error {
551+
err := autoConvert_v1alpha8_OpenStackClusterStatus_To_v1alpha7_OpenStackClusterStatus(in, out, s)
552+
if err != nil {
553+
return err
554+
}
555+
556+
return nil
557+
}

api/v1alpha7/zz_generated.conversion.go

Lines changed: 7 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha8/openstackmachine_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ type OpenStackMachineStatus struct {
119119
// ReferencedResources contains resolved references to resources that the machine depends on.
120120
ReferencedResources ReferencedMachineResources `json:"referencedResources,omitempty"`
121121

122+
// DependentResources contains resolved dependent resources that were created by the machine.
123+
DependentResources DependentMachineResources `json:"dependentResources,omitempty"`
124+
122125
FailureReason *errors.MachineStatusError `json:"failureReason,omitempty"`
123126

124127
// FailureMessage will be set in the event that there is a terminal problem

api/v1alpha8/types.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,12 @@ type PortOpts struct {
147147
ValueSpecs []ValueSpec `json:"valueSpecs,omitempty"`
148148
}
149149

150+
type PortStatus struct {
151+
// ID is the unique identifier of the port.
152+
// +required
153+
ID string `json:"id"`
154+
}
155+
150156
type BindingProfile struct {
151157
// OVSHWOffload enables or disables the OVS hardware offload feature.
152158
OVSHWOffload bool `json:"ovsHWOffload,omitempty"`
@@ -175,6 +181,7 @@ type BastionStatus struct {
175181
IP string `json:"ip,omitempty"`
176182
FloatingIP string `json:"floatingIP,omitempty"`
177183
ReferencedResources ReferencedMachineResources `json:"referencedResources,omitempty"`
184+
DependentResources DependentMachineResources `json:"dependentResources,omitempty"`
178185
}
179186

180187
type RootVolume struct {
@@ -399,6 +406,16 @@ type ReferencedMachineResources struct {
399406
// ImageID is the ID of the image to use for the machine and is calculated based on ImageFilter.
400407
// +optional
401408
ImageID string `json:"imageID,omitempty"`
409+
410+
// portsOpts is the list of ports options to create for the machine.
411+
// +optional
412+
PortsOpts []PortOpts `json:"portsOpts,omitempty"`
413+
}
414+
415+
type DependentMachineResources struct {
416+
// PortsStatus is the status of the ports created for the machine.
417+
// +optional
418+
PortsStatus []PortStatus `json:"portsStatus,omitempty"`
402419
}
403420

404421
// ValueSpec represents a single value_spec key-value pair.

api/v1alpha8/zz_generated.deepcopy.go

Lines changed: 47 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)