Skip to content

Commit cc3f782

Browse files
committed
Move ports management outside of instances
1 parent fc47622 commit cc3f782

25 files changed

+2357
-1282
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: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,16 @@ func restorev1alpha8ClusterStatus(previous *infrav1.OpenStackClusterStatus, dst
122122
dst.Network = nil
123123
}
124124

125-
if previous.Bastion != nil {
126-
dst.Bastion.ReferencedResources = previous.Bastion.ReferencedResources
127-
}
128-
129125
dst.ControlPlaneSecurityGroup = previous.ControlPlaneSecurityGroup
130126
dst.WorkerSecurityGroup = previous.WorkerSecurityGroup
131127
dst.BastionSecurityGroup = previous.BastionSecurityGroup
128+
129+
if previous.Bastion != nil {
130+
dst.Bastion.ReferencedResources = previous.Bastion.ReferencedResources
131+
}
132+
if previous.Bastion != nil && previous.Bastion.DependentResources.PortsStatus != nil {
133+
dst.Bastion.DependentResources.PortsStatus = previous.Bastion.DependentResources.PortsStatus
134+
}
132135
}
133136

134137
func restorev1alpha6ClusterSpec(previous *OpenStackClusterSpec, dst *OpenStackClusterSpec) {
@@ -363,7 +366,11 @@ var v1alpha8OpenStackMachineRestorer = conversion.RestorerFor[*infrav1.OpenStack
363366
},
364367
restorev1alpha8MachineSpec,
365368
),
366-
369+
"depresources": conversion.UnconditionalFieldRestorer(
370+
func(c *infrav1.OpenStackMachine) *infrav1.DependentMachineResources {
371+
return &c.Status.DependentResources
372+
},
373+
),
367374
// No equivalent in v1alpha6
368375
"refresources": conversion.UnconditionalFieldRestorer(
369376
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: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,13 @@ func restorev1alpha8ClusterStatus(previous *infrav1.OpenStackClusterStatus, dst
121121
restorev1alpha8SecurityGroupStatus(previous.BastionSecurityGroup, dst.BastionSecurityGroup)
122122

123123
// ReferencedResources have no equivalent in v1alpha7
124-
if dst.Bastion != nil {
124+
if previous.Bastion != nil {
125125
dst.Bastion.ReferencedResources = previous.Bastion.ReferencedResources
126126
}
127+
128+
if previous.Bastion != nil && previous.Bastion.DependentResources.PortsStatus != nil {
129+
dst.Bastion.DependentResources.PortsStatus = previous.Bastion.DependentResources.PortsStatus
130+
}
127131
}
128132

129133
var v1alpha8OpenStackClusterRestorer = conversion.RestorerFor[*infrav1.OpenStackCluster]{
@@ -337,6 +341,11 @@ var v1alpha8OpenStackMachineRestorer = conversion.RestorerFor[*infrav1.OpenStack
337341
},
338342
restorev1alpha8MachineSpec,
339343
),
344+
"depresources": conversion.UnconditionalFieldRestorer(
345+
func(c *infrav1.OpenStackMachine) *infrav1.DependentMachineResources {
346+
return &c.Status.DependentResources
347+
},
348+
),
340349

341350
// No equivalent in v1alpha7
342351
"refresources": conversion.UnconditionalFieldRestorer(
@@ -669,3 +678,12 @@ func Convert_v1alpha7_SecurityGroup_To_v1alpha8_SecurityGroupStatus(in *Security
669678

670679
return nil
671680
}
681+
682+
func Convert_v1alpha8_OpenStackClusterStatus_To_v1alpha7_OpenStackClusterStatus(in *infrav1.OpenStackClusterStatus, out *OpenStackClusterStatus, s apiconversion.Scope) error {
683+
err := autoConvert_v1alpha8_OpenStackClusterStatus_To_v1alpha7_OpenStackClusterStatus(in, out, s)
684+
if err != nil {
685+
return err
686+
}
687+
688+
return nil
689+
}

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 {
@@ -496,6 +503,16 @@ type ReferencedMachineResources struct {
496503
// ImageID is the ID of the image to use for the machine and is calculated based on ImageFilter.
497504
// +optional
498505
ImageID string `json:"imageID,omitempty"`
506+
507+
// portsOpts is the list of ports options to create for the machine.
508+
// +optional
509+
PortsOpts []PortOpts `json:"portsOpts,omitempty"`
510+
}
511+
512+
type DependentMachineResources struct {
513+
// PortsStatus is the status of the ports created for the machine.
514+
// +optional
515+
PortsStatus []PortStatus `json:"portsStatus,omitempty"`
499516
}
500517

501518
// 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)