Skip to content

Commit dbd7ebc

Browse files
jaredledvinaHadrienPatte
authored andcommitted
azure: remove deprecated CIDR and Subnet status fields
The AzureInterface.CIDR and AzureAddress.Subnet fields on CiliumNode.Status.Azure were deprecated in favor of the shared AzureInterface.Subnet object (Subnet.ID and Subnet.CIDR). They were retained for one release (1.20) as populated mirrors so agent/operator rolling upgrades work in either order and external consumers could migrate off them. The migration window has now closed, so remove the deprecated fields. The transitional dual-writes in parseInterface() and the mock are dropped, the only remaining reader in pkg/ipam now reads Subnet.CIDR directly (the azureInterfaceCIDR fallback helper is removed), and the generated deepcopy/deepequal code and the CiliumNode CRD manifest are regenerated to match. Fixes: cilium#46074 Signed-off-by: Jared Ledvina <jared.ledvina@datadoghq.com>
1 parent b58e7af commit dbd7ebc

9 files changed

Lines changed: 4 additions & 106 deletions

File tree

pkg/azure/api/api.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,6 @@ func parseInterface(logger *slog.Logger, iface *armnetwork.Interface, subnets ip
352352
if subnet, ok := subnets[i.Subnet.ID]; ok {
353353
if subnet.CIDR.IsValid() {
354354
i.Subnet.CIDR = iputil.PrefixFrom(subnet.CIDR)
355-
i.CIDR = i.Subnet.CIDR //nolint:staticcheck // transitional, see https://github.com/cilium/cilium/issues/46074
356355
}
357356
i.Gateway = deriveGatewayIP(subnet.CIDR.Addr())
358357
}
@@ -380,9 +379,6 @@ func parseInterface(logger *slog.Logger, iface *armnetwork.Interface, subnets ip
380379
IP: iputil.AddrFrom(parsedIP),
381380
State: strings.ToLower(string(*ip.Properties.ProvisioningState)),
382381
}
383-
if ip.Properties.Subnet != nil {
384-
addr.Subnet = *ip.Properties.Subnet.ID //nolint:staticcheck // transitional, see https://github.com/cilium/cilium/issues/46074
385-
}
386382
i.Addresses = append(i.Addresses, addr)
387383
}
388384
}

pkg/azure/api/api_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,11 @@ func TestParseInterface(t *testing.T) {
159159
require.Equal(t, tt.expectedIP, got.IP)
160160
require.Equal(t, tt.expectedSubnetID, got.Subnet.ID)
161161
require.Equal(t, tt.expectedCIDR, got.Subnet.CIDR)
162-
require.Equal(t, tt.expectedCIDR, got.CIDR) //nolint:staticcheck // verifies the deprecated mirror still tracks Subnet.CIDR
163162
require.Equal(t, tt.expectedGateway, got.Gateway)
164163

165164
gotAddrs := make([]iputil.Addr, 0, len(got.Addresses))
166165
for _, a := range got.Addresses {
167166
gotAddrs = append(gotAddrs, a.IP)
168-
require.Equal(t, tt.expectedSubnetID, a.Subnet) //nolint:staticcheck // exercises the deprecated mirror
169167
}
170168
if tt.expectedAddrs == nil {
171169
require.Empty(t, gotAddrs)

pkg/azure/api/mock/mock.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,8 @@ func (a *API) AssignPrivateIpAddressesVMSS(ctx context.Context, vmName, vmssName
192192
panic("Unable to allocate IP from allocator")
193193
}
194194
intf.Addresses = append(intf.Addresses, types.AzureAddress{
195-
IP: iputil.AddrFrom(ip),
196-
Subnet: subnetID, //nolint:staticcheck // deprecated mirror; matches parseInterface, see https://github.com/cilium/cilium/issues/46074
197-
State: types.StateSucceeded,
195+
IP: iputil.AddrFrom(ip),
196+
State: types.StateSucceeded,
198197
})
199198
}
200199

pkg/azure/types/types.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,6 @@ type AzureAddress struct {
5555
// +optional
5656
IP iputil.Addr `json:"ip,omitzero"`
5757

58-
// Subnet is the subnet the address belongs to.
59-
//
60-
// Deprecated: use AzureInterface.Subnet.ID. Populated as a mirror for one
61-
// release so external consumers of CiliumNode.Status.Azure can migrate.
62-
// TODO(https://github.com/cilium/cilium/issues/46074): remove once the migration window closes.
63-
Subnet string `json:"subnet,omitempty"`
64-
6558
// State is the provisioning state of the address
6659
State string `json:"state,omitempty"`
6760
}
@@ -129,15 +122,6 @@ type AzureInterface struct {
129122
// +optional
130123
Gateway iputil.Addr `json:"gateway"`
131124

132-
// CIDR is the range that the interface belongs to.
133-
//
134-
// Deprecated: use Subnet.CIDR. Retained for one release so agent/operator
135-
// rolling upgrades work in either order.
136-
// TODO(https://github.com/cilium/cilium/issues/46074): remove once the migration window closes.
137-
//
138-
// +optional
139-
CIDR iputil.Prefix `json:"cidr,omitzero"`
140-
141125
// vmssName is the name of the virtual machine scale set. This field is
142126
// set by extractIDs()
143127
vmssName string `json:"-"`

pkg/azure/types/zz_generated.deepcopy.go

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

pkg/azure/types/zz_generated.deepequal.go

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

pkg/ipam/crd.go

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"k8s.io/client-go/tools/cache"
2525

2626
alibabaCloudTypes "github.com/cilium/cilium/pkg/alibabacloud/types"
27-
azureTypes "github.com/cilium/cilium/pkg/azure/types"
2827
"github.com/cilium/cilium/pkg/cidr"
2928
"github.com/cilium/cilium/pkg/datapath/linux/sysctl"
3029
"github.com/cilium/cilium/pkg/ip"
@@ -252,7 +251,7 @@ func deriveVpcCIDRs(node *ciliumv2.CiliumNode) (primaryCIDR *cidr.CIDR, secondar
252251
}
253252
}
254253
for _, azif := range node.Status.Azure.Interfaces {
255-
if p := azureInterfaceCIDR(azif); p.IsValid() {
254+
if p := azif.Subnet.CIDR.Prefix; p.IsValid() {
256255
primaryCIDR = cidr.NewCIDR(netipx.PrefixIPNet(p.Masked()))
257256
return
258257
}
@@ -722,7 +721,7 @@ func (a *crdAllocator) buildAllocationResult(addr netip.Addr, ipInfo *ipamTypes.
722721
if iface.Gateway.IsValid() {
723722
result.GatewayIP = iface.Gateway.Addr
724723
}
725-
if p := azureInterfaceCIDR(iface); p.IsValid() {
724+
if p := iface.Subnet.CIDR.Prefix; p.IsValid() {
726725
result.CIDRs = append(result.CIDRs, p)
727726
}
728727
// Add manually configured Native Routing CIDR
@@ -969,16 +968,3 @@ func (e *ErrIPNotAvailableInPool) Is(target error) bool {
969968
}
970969
return t.addr == e.addr
971970
}
972-
973-
// azureInterfaceCIDR returns Subnet.CIDR, falling back to the deprecated
974-
// AzureInterface.CIDR for CiliumNodes written by operators predating the
975-
// Subnet.CIDR migration.
976-
//
977-
// TODO(https://github.com/cilium/cilium/issues/46074): remove once
978-
// AzureInterface.CIDR is deleted.
979-
func azureInterfaceCIDR(iface azureTypes.AzureInterface) netip.Prefix {
980-
if iface.Subnet.CIDR.IsValid() {
981-
return iface.Subnet.CIDR.Prefix
982-
}
983-
return iface.CIDR.Prefix //nolint:staticcheck // fallback for operators predating the Subnet.CIDR migration
984-
}

pkg/ipam/crd_test.go

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -28,48 +28,6 @@ import (
2828
"github.com/cilium/cilium/pkg/trigger"
2929
)
3030

31-
func TestAzureInterfaceCIDR(t *testing.T) {
32-
tests := []struct {
33-
name string
34-
iface azureTypes.AzureInterface
35-
want netip.Prefix
36-
}{
37-
{
38-
name: "new operator: Subnet.CIDR populated, flat CIDR mirrored",
39-
iface: azureTypes.AzureInterface{
40-
Subnet: azureTypes.AzureSubnet{CIDR: iputil.PrefixFrom(netip.MustParsePrefix("10.0.0.0/24"))},
41-
CIDR: iputil.PrefixFrom(netip.MustParsePrefix("10.0.0.0/24")), //nolint:staticcheck // exercises the dual-write path
42-
},
43-
want: netip.MustParsePrefix("10.0.0.0/24"),
44-
},
45-
{
46-
name: "old operator: only flat CIDR set, fallback used",
47-
iface: azureTypes.AzureInterface{
48-
CIDR: iputil.PrefixFrom(netip.MustParsePrefix("10.0.0.0/24")), //nolint:staticcheck // exercises the legacy-only path
49-
},
50-
want: netip.MustParsePrefix("10.0.0.0/24"),
51-
},
52-
{
53-
name: "Subnet.CIDR wins when fields disagree",
54-
iface: azureTypes.AzureInterface{
55-
Subnet: azureTypes.AzureSubnet{CIDR: iputil.PrefixFrom(netip.MustParsePrefix("10.0.1.0/24"))},
56-
CIDR: iputil.PrefixFrom(netip.MustParsePrefix("10.0.0.0/24")), //nolint:staticcheck // exercises preference order
57-
},
58-
want: netip.MustParsePrefix("10.0.1.0/24"),
59-
},
60-
{
61-
name: "neither field set: zero Prefix",
62-
iface: azureTypes.AzureInterface{},
63-
want: netip.Prefix{},
64-
},
65-
}
66-
for _, tt := range tests {
67-
t.Run(tt.name, func(t *testing.T) {
68-
assert.Equal(t, tt.want, azureInterfaceCIDR(tt.iface))
69-
})
70-
}
71-
}
72-
7331
func TestIPNotAvailableInPoolError(t *testing.T) {
7432
err := NewIPNotAvailableInPoolError(netip.MustParseAddr("1.1.1.1"))
7533
err2 := NewIPNotAvailableInPoolError(netip.MustParseAddr("1.1.1.1"))

pkg/k8s/apis/cilium.io/client/crds/v2/ciliumnodes.yaml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -556,23 +556,8 @@ spec:
556556
description: State is the provisioning state of the
557557
address
558558
type: string
559-
subnet:
560-
description: |-
561-
Subnet is the subnet the address belongs to.
562-
563-
Deprecated: use AzureInterface.Subnet.ID. Populated as a mirror for one
564-
release so external consumers of CiliumNode.Status.Azure can migrate.
565-
type: string
566559
type: object
567560
type: array
568-
cidr:
569-
description: |-
570-
CIDR is the range that the interface belongs to.
571-
572-
Deprecated: use Subnet.CIDR. Retained for one release so agent/operator
573-
rolling upgrades work in either order.
574-
format: cidr
575-
type: string
576561
gateway:
577562
description: Gateway is the interface's subnet's default
578563
route

0 commit comments

Comments
 (0)