Skip to content

Commit fd37971

Browse files
authored
Merge pull request #1788 from shiftstack/ports
✨ Re-work ports management
2 parents dd85470 + 7ec4c14 commit fd37971

25 files changed

+2350
-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
@@ -125,13 +125,16 @@ func restorev1alpha8ClusterStatus(previous *infrav1.OpenStackClusterStatus, dst
125125
dst.Network = nil
126126
}
127127

128-
if previous.Bastion != nil {
129-
dst.Bastion.ReferencedResources = previous.Bastion.ReferencedResources
130-
}
131-
132128
dst.ControlPlaneSecurityGroup = previous.ControlPlaneSecurityGroup
133129
dst.WorkerSecurityGroup = previous.WorkerSecurityGroup
134130
dst.BastionSecurityGroup = previous.BastionSecurityGroup
131+
132+
if previous.Bastion != nil {
133+
dst.Bastion.ReferencedResources = previous.Bastion.ReferencedResources
134+
}
135+
if previous.Bastion != nil && previous.Bastion.DependentResources.PortsStatus != nil {
136+
dst.Bastion.DependentResources.PortsStatus = previous.Bastion.DependentResources.PortsStatus
137+
}
135138
}
136139

137140
func restorev1alpha6ClusterSpec(previous *OpenStackClusterSpec, dst *OpenStackClusterSpec) {
@@ -375,7 +378,11 @@ var v1alpha8OpenStackMachineRestorer = conversion.RestorerFor[*infrav1.OpenStack
375378
},
376379
restorev1alpha8MachineSpec,
377380
),
378-
381+
"depresources": conversion.UnconditionalFieldRestorer(
382+
func(c *infrav1.OpenStackMachine) *infrav1.DependentMachineResources {
383+
return &c.Status.DependentResources
384+
},
385+
),
379386
// No equivalent in v1alpha6
380387
"refresources": conversion.UnconditionalFieldRestorer(
381388
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: 14 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]{
@@ -349,6 +353,11 @@ var v1alpha8OpenStackMachineRestorer = conversion.RestorerFor[*infrav1.OpenStack
349353
},
350354
restorev1alpha8MachineSpec,
351355
),
356+
"depresources": conversion.UnconditionalFieldRestorer(
357+
func(c *infrav1.OpenStackMachine) *infrav1.DependentMachineResources {
358+
return &c.Status.DependentResources
359+
},
360+
),
352361

353362
// No equivalent in v1alpha7
354363
"refresources": conversion.UnconditionalFieldRestorer(
@@ -688,3 +697,7 @@ func Convert_v1alpha7_SecurityGroup_To_v1alpha8_SecurityGroupStatus(in *Security
688697
func Convert_v1alpha7_OpenStackIdentityReference_To_v1alpha8_OpenStackIdentityReference(in *OpenStackIdentityReference, out *infrav1.OpenStackIdentityReference, s apiconversion.Scope) error {
689698
return autoConvert_v1alpha7_OpenStackIdentityReference_To_v1alpha8_OpenStackIdentityReference(in, out, s)
690699
}
700+
701+
func Convert_v1alpha8_OpenStackClusterStatus_To_v1alpha7_OpenStackClusterStatus(in *infrav1.OpenStackClusterStatus, out *OpenStackClusterStatus, s apiconversion.Scope) error {
702+
return autoConvert_v1alpha8_OpenStackClusterStatus_To_v1alpha7_OpenStackClusterStatus(in, out, s)
703+
}

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)