Skip to content

Commit c543865

Browse files
committed
Dual-stack: Fix conversion restore with multiple subnets
1 parent e98b7f5 commit c543865

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

api/v1alpha6/conversion.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ func restorev1alpha8Bastion(previous **infrav1.Bastion, dst **infrav1.Bastion) {
7575
}
7676
}
7777

78+
func restorev1alpha8Subnets(previous *[]infrav1.SubnetFilter, dst *[]infrav1.SubnetFilter) {
79+
if len(*previous) > 1 {
80+
*dst = append(*dst, (*previous)[1:]...)
81+
}
82+
}
83+
7884
func restorev1alpha8ClusterStatus(previous *infrav1.OpenStackClusterStatus, dst *infrav1.OpenStackClusterStatus) {
7985
// It's (theoretically) possible in v1alpha8 to have Network nil but
8086
// Router or APIServerLoadBalancer not nil. In hub-spoke-hub conversion this will
@@ -154,6 +160,12 @@ var v1alpha8OpenStackClusterRestorer = conversion.RestorerFor[*infrav1.OpenStack
154160
},
155161
restorev1alpha8Bastion,
156162
),
163+
"subnets": conversion.HashedFieldRestorer(
164+
func(c *infrav1.OpenStackCluster) *[]infrav1.SubnetFilter {
165+
return &c.Spec.Subnets
166+
},
167+
restorev1alpha8Subnets,
168+
),
157169
"status": conversion.HashedFieldRestorer(
158170
func(c *infrav1.OpenStackCluster) *infrav1.OpenStackClusterStatus {
159171
return &c.Status
@@ -234,6 +246,12 @@ var v1alpha8OpenStackClusterTemplateRestorer = conversion.RestorerFor[*infrav1.O
234246
},
235247
restorev1alpha8Bastion,
236248
),
249+
"subnets": conversion.HashedFieldRestorer(
250+
func(c *infrav1.OpenStackClusterTemplate) *[]infrav1.SubnetFilter {
251+
return &c.Spec.Template.Spec.Subnets
252+
},
253+
restorev1alpha8Subnets,
254+
),
237255
}
238256

239257
func (r *OpenStackClusterTemplate) ConvertTo(dstRaw ctrlconversion.Hub) error {

api/v1alpha7/conversion.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ func restorev1alpha8ClusterSpec(previous *infrav1.OpenStackClusterSpec, dst *inf
9797
dst.ExternalNetwork.NotTagsAny = previous.ExternalNetwork.NotTagsAny
9898

9999
dst.DisableExternalNetwork = previous.DisableExternalNetwork
100+
101+
if len(previous.Subnets) > 1 {
102+
dst.Subnets = append(dst.Subnets, previous.Subnets[1:]...)
103+
}
100104
}
101105

102106
func (r *OpenStackCluster) ConvertTo(dstRaw ctrlconversion.Hub) error {

0 commit comments

Comments
 (0)