Skip to content

Commit 3c2bfe6

Browse files
committed
Support propagate uplink status for ports
1 parent 19ec23c commit 3c2bfe6

14 files changed

+278
-36
lines changed

api/v1alpha4/conversion_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ func TestFuzzyConversion(t *testing.T) {
313313
}
314314
v1alpha7PortOpts.SecurityGroupFilters = nil
315315
v1alpha7PortOpts.ValueSpecs = nil
316+
v1alpha7PortOpts.PropagateUplinkStatus = nil
316317
},
317318
func(v1alpha7FixedIP *infrav1.FixedIP, c fuzz.Continue) {
318319
c.FuzzNoCustom(v1alpha7FixedIP)

api/v1alpha4/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/v1alpha5/conversion.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ func Convert_v1alpha7_LoadBalancer_To_v1alpha5_LoadBalancer(in *infrav1.LoadBala
208208
}
209209

210210
func Convert_v1alpha7_PortOpts_To_v1alpha5_PortOpts(in *infrav1.PortOpts, out *PortOpts, s conversion.Scope) error {
211-
// value specs have been added in v1alpha7 but have no equivalent in v1alpha5
211+
// value specs and propagate uplink status have been added in v1alpha7 but have no equivalent in v1alpha5
212212
return autoConvert_v1alpha7_PortOpts_To_v1alpha5_PortOpts(in, out, s)
213213
}
214214

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: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,36 @@ func restorev1alpha6MachineSpec(previous *OpenStackMachineSpec, dst *OpenStackMa
8888
dst.Subnet = previous.Subnet
8989
}
9090

91+
func restorev1alpha7MachineSpec(previous *infrav1.OpenStackMachineSpec, dst *infrav1.OpenStackMachineSpec) {
92+
// PropagateUplinkStatus has been added in v1alpha7.
93+
// We restore the whole Ports since they are anyway immutable.
94+
dst.Ports = previous.Ports
95+
}
96+
9197
func restorev1alpha7ClusterSpec(previous *infrav1.OpenStackClusterSpec, dst *infrav1.OpenStackClusterSpec) {
9298
// APIServerLoadBalancer.Provider is new in v1alpha7
9399
dst.APIServerLoadBalancer.Provider = previous.APIServerLoadBalancer.Provider
94100
dst.Router = previous.Router
101+
// PropagateUplinkStatus has been added in v1alpha7.
102+
// We restore the whole Ports since they are anyway immutable.
103+
if previous.Bastion != nil && previous.Bastion.Instance.Ports != nil {
104+
dst.Bastion.Instance.Ports = previous.Bastion.Instance.Ports
105+
}
106+
}
107+
108+
func restorev1alpha7ClusterStatus(previous *infrav1.OpenStackClusterStatus, dst *infrav1.OpenStackClusterStatus) {
109+
// PropagateUplinkStatus has been added in v1alpha7
110+
if previous.ExternalNetwork != nil && previous.ExternalNetwork.PortOpts != nil {
111+
dst.ExternalNetwork.PortOpts.PropagateUplinkStatus = previous.ExternalNetwork.PortOpts.PropagateUplinkStatus
112+
}
113+
if previous.Network != nil && previous.Network.PortOpts != nil {
114+
dst.Network.PortOpts.PropagateUplinkStatus = previous.Network.PortOpts.PropagateUplinkStatus
115+
}
116+
// PropagateUplinkStatus has been added in v1alpha7.
117+
// We restore the whole Networks since they are anyway immutable.
118+
if previous.Bastion != nil && previous.Bastion.Networks != nil {
119+
dst.Bastion.Networks = previous.Bastion.Networks
120+
}
95121
}
96122

97123
var _ ctrlconversion.Convertible = &OpenStackCluster{}
@@ -106,6 +132,7 @@ func (r *OpenStackCluster) ConvertTo(dstRaw ctrlconversion.Hub) error {
106132

107133
if restored {
108134
restorev1alpha7ClusterSpec(&previous.Spec, &dst.Spec)
135+
restorev1alpha7ClusterStatus(&previous.Status, &dst.Status)
109136
}
110137

111138
return nil
@@ -183,7 +210,12 @@ var _ ctrlconversion.Convertible = &OpenStackMachine{}
183210
func (r *OpenStackMachine) ConvertTo(dstRaw ctrlconversion.Hub) error {
184211
dst := dstRaw.(*infrav1.OpenStackMachine)
185212
var previous infrav1.OpenStackMachine
186-
_, err := convertAndRestore(r, dst, &previous, Convert_v1alpha6_OpenStackMachine_To_v1alpha7_OpenStackMachine)
213+
restored, err := convertAndRestore(r, dst, &previous, Convert_v1alpha6_OpenStackMachine_To_v1alpha7_OpenStackMachine)
214+
215+
if restored {
216+
restorev1alpha7MachineSpec(&previous.Spec, &dst.Spec)
217+
}
218+
187219
return err
188220
}
189221

@@ -219,7 +251,12 @@ var _ ctrlconversion.Convertible = &OpenStackMachineTemplate{}
219251
func (r *OpenStackMachineTemplate) ConvertTo(dstRaw ctrlconversion.Hub) error {
220252
dst := dstRaw.(*infrav1.OpenStackMachineTemplate)
221253
var previous infrav1.OpenStackMachineTemplate
222-
_, err := convertAndRestore(r, dst, &previous, Convert_v1alpha6_OpenStackMachineTemplate_To_v1alpha7_OpenStackMachineTemplate)
254+
restored, err := convertAndRestore(r, dst, &previous, Convert_v1alpha6_OpenStackMachineTemplate_To_v1alpha7_OpenStackMachineTemplate)
255+
256+
if restored {
257+
restorev1alpha7MachineSpec(&previous.Spec.Template.Spec, &dst.Spec.Template.Spec)
258+
}
259+
223260
return err
224261
}
225262

@@ -262,3 +299,28 @@ func Convert_v1alpha7_APIServerLoadBalancer_To_v1alpha6_APIServerLoadBalancer(in
262299
func Convert_v1alpha7_OpenStackClusterSpec_To_v1alpha6_OpenStackClusterSpec(in *infrav1.OpenStackClusterSpec, out *OpenStackClusterSpec, s conversion.Scope) error {
263300
return autoConvert_v1alpha7_OpenStackClusterSpec_To_v1alpha6_OpenStackClusterSpec(in, out, s)
264301
}
302+
303+
func Convert_Slice_v1alpha6_Network_To_Slice_v1alpha7_Network(in *[]Network, out *[]infrav1.Network, s conversion.Scope) error {
304+
*out = make([]infrav1.Network, len(*in))
305+
for i := range *in {
306+
if err := Convert_v1alpha6_Network_To_v1alpha7_Network(&(*in)[i], &(*out)[i], s); err != nil {
307+
return err
308+
}
309+
}
310+
return nil
311+
}
312+
313+
func Convert_Slice_v1alpha7_Network_To_Slice_v1alpha6_Network(in *[]infrav1.Network, out *[]Network, s conversion.Scope) error {
314+
*out = make([]Network, len(*in))
315+
for i := range *in {
316+
if err := Convert_v1alpha7_Network_To_v1alpha6_Network(&(*in)[i], &(*out)[i], s); err != nil {
317+
return err
318+
}
319+
}
320+
return nil
321+
}
322+
323+
func Convert_v1alpha7_PortOpts_To_v1alpha6_PortOpts(in *infrav1.PortOpts, out *PortOpts, s conversion.Scope) error {
324+
// value specs and propagate uplink status have been added in v1alpha7 but have no equivalent in v1alpha5
325+
return autoConvert_v1alpha7_PortOpts_To_v1alpha6_PortOpts(in, out, s)
326+
}

api/v1alpha6/zz_generated.conversion.go

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

api/v1alpha7/types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ type PortOpts struct {
152152
// When not set, it takes the value of the corresponding field at the network level.
153153
DisablePortSecurity *bool `json:"disablePortSecurity,omitempty"`
154154

155+
// PropageteUplinkStatus enables or disables the propagate uplink status on the port.
156+
PropagateUplinkStatus *bool `json:"propagateUplinkStatus,omitempty"`
157+
155158
// Tags applied to the port (and corresponding trunk, if a trunk is configured.)
156159
// These tags are applied in addition to the instance's tags, which will also be applied to the port.
157160
// +listType=set

0 commit comments

Comments
 (0)