Skip to content

Commit aed4596

Browse files
[NX-OS] Add defaults for VPCDomain resource (#156)
The default values are taken from the DME reference.
1 parent 212868a commit aed4596

7 files changed

Lines changed: 59 additions & 66 deletions

File tree

api/cisco/nx/v1alpha1/vpcdomain_types.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,31 +36,36 @@ type VPCDomainSpec struct {
3636
// +optional
3737
// +kubebuilder:validation:Minimum=1
3838
// +kubebuilder:validation:Maximum=65535
39+
// +kubebuilder:default=32667
3940
RolePriority int32 `json:"rolePriority"`
4041

4142
// SystemPriority is the system priority for this vPC domain (1-65535).
4243
// Used to ensure that the vPC domain devices are primary devices on LACP. Must match on both peers.
4344
// +optional
4445
// +kubebuilder:validation:Minimum=1
4546
// +kubebuilder:validation:Maximum=65535
47+
// +kubebuilder:default=32667
4648
SystemPriority int32 `json:"systemPriority"`
4749

4850
// DelayRestoreSVI is the delay in seconds (1-3600) before bringing up interface-vlan (SVI) after peer-link comes up.
4951
// This prevents traffic blackholing during convergence.
5052
// +optional
5153
// +kubebuilder:validation:Minimum=1
5254
// +kubebuilder:validation:Maximum=3600
55+
// +kubebuilder:default=10
5356
DelayRestoreSVI int16 `json:"delayRestoreSVI"`
5457

5558
// DelayRestoreVPC is the delay in seconds (1-3600) before bringing up the member ports after the peer-link is restored.
5659
// +optional
5760
// +kubebuilder:validation:Minimum=1
5861
// +kubebuilder:validation:Maximum=3600
62+
// +kubebuilder:default=30
5963
DelayRestoreVPC int16 `json:"delayRestoreVPC"`
6064

6165
// FastConvergence ensures that both SVIs and member ports are shut down simultaneously when the peer-link goes down.
6266
// This synchronization helps prevent traffic loss.
6367
// +optional
68+
// +kubebuilder:default={enabled:false}
6469
FastConvergence Enabled `json:"fastConvergence"`
6570

6671
// Peer contains the vPC's domain peer configuration including peer-link, keepalive.
@@ -86,15 +91,15 @@ type Peer struct {
8691
// This interface carries control and data traffic between the two vPC domain peers.
8792
// It is usually dedicated port-channel, but it can also be a single physical interface.
8893
// +required
89-
InterfaceRef v1alpha1.LocalObjectReference `json:"interfaceRef,omitempty"`
94+
InterfaceRef v1alpha1.LocalObjectReference `json:"interfaceRef"`
9095

9196
// KeepAlive defines the out-of-band keepalive configuration.
9297
// +required
9398
KeepAlive KeepAlive `json:"keepalive"`
9499

95100
// AutoRecovery defines auto-recovery settings for restoring vPC domain after peer failure.
96101
// +optional
97-
AutoRecovery *AutoRecovery `json:"autoRecovery,omitempty"`
102+
AutoRecovery *AutoRecovery `json:"autoRecovery"`
98103

99104
// Switch enables peer-switch functionality on this peer.
100105
// When enabled, both vPC domain peers use the same spanning-tree bridge ID, allowing both
@@ -147,14 +152,15 @@ type AutoRecovery struct {
147152
// When enabled, the switch will wait for ReloadDelay seconds after peer failure
148153
// before assuming the peer is dead and restoring the vPC's domain functionality.
149154
// +required
150-
Enabled bool `json:"enabled,omitempty"`
155+
Enabled bool `json:"enabled"`
151156

152157
// ReloadDelay is the time in seconds (60-3600) to wait before assuming the peer is dead
153158
// and automatically attempting to restore the communication with the peer.
154159
// +optional
155160
// +kubebuilder:validation:Minimum=60
156161
// +kubebuilder:validation:Maximum=3600
157-
ReloadDelay int16 `json:"reloadDelay,omitempty"`
162+
// +kubebuilder:default=240
163+
ReloadDelay int16 `json:"reloadDelay"`
158164
}
159165

160166
// VPCDomainStatus defines the observed state of VPCDomain.
@@ -179,10 +185,6 @@ type VPCDomainStatus struct {
179185
//+optional
180186
Conditions []metav1.Condition `json:"conditions,omitempty"`
181187

182-
// DomainID is the vPC domain ID as reported by the device.
183-
// +optional
184-
DomainID uint16 `json:"domainId,omitempty"`
185-
186188
// Role indicates the current operational role of this vPC domain peer.
187189
// +optional
188190
Role VPCDomainRole `json:"role,omitempty"`
@@ -207,7 +209,7 @@ type VPCDomainStatus struct {
207209

208210
// PeerUptime indicates how long the vPC domain peer has been up and reachable via keepalive.
209211
// +optional
210-
PeerUptime metav1.Duration `json:"peerUptime,omitempty"`
212+
PeerUptime metav1.Duration `json:"peerUptime,omitempty,omitzero"`
211213

212214
// PeerLinkIf is the name of the interface used as the vPC domain peer-link.
213215
// +optional

charts/network-operator/templates/crd/nx.cisco.networking.metal.ironcore.dev_vpcdomains.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,15 @@ spec:
105105
- Down
106106
type: string
107107
delayRestoreSVI:
108+
default: 10
108109
description: |-
109110
DelayRestoreSVI is the delay in seconds (1-3600) before bringing up interface-vlan (SVI) after peer-link comes up.
110111
This prevents traffic blackholing during convergence.
111112
maximum: 3600
112113
minimum: 1
113114
type: integer
114115
delayRestoreVPC:
116+
default: 30
115117
description: DelayRestoreVPC is the delay in seconds (1-3600) before
116118
bringing up the member ports after the peer-link is restored.
117119
maximum: 3600
@@ -145,6 +147,8 @@ spec:
145147
minimum: 1
146148
type: integer
147149
fastConvergence:
150+
default:
151+
enabled: false
148152
description: |-
149153
FastConvergence ensures that both SVIs and member ports are shut down simultaneously when the peer-link goes down.
150154
This synchronization helps prevent traffic loss.
@@ -179,6 +183,7 @@ spec:
179183
before assuming the peer is dead and restoring the vPC's domain functionality.
180184
type: boolean
181185
reloadDelay:
186+
default: 240
182187
description: |-
183188
ReloadDelay is the time in seconds (60-3600) to wait before assuming the peer is dead
184189
and automatically attempting to restore the communication with the peer.
@@ -293,6 +298,7 @@ spec:
293298
- keepalive
294299
type: object
295300
rolePriority:
301+
default: 32667
296302
description: |-
297303
RolePriority is the role priority for this vPC domain (1-65535).
298304
The switch with the lower role priority becomes the operational primary.
@@ -301,6 +307,7 @@ spec:
301307
minimum: 1
302308
type: integer
303309
systemPriority:
310+
default: 32667
304311
description: |-
305312
SystemPriority is the system priority for this vPC domain (1-65535).
306313
Used to ensure that the vPC domain devices are primary devices on LACP. Must match on both peers.
@@ -388,9 +395,6 @@ spec:
388395
x-kubernetes-list-map-keys:
389396
- type
390397
x-kubernetes-list-type: map
391-
domainId:
392-
description: DomainID is the vPC domain ID as reported by the device.
393-
type: integer
394398
keepaliveStatus:
395399
description: KeepAliveStatus indicates the status of the peer via
396400
the keepalive link.

config/crd/bases/nx.cisco.networking.metal.ironcore.dev_vpcdomains.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,15 @@ spec:
9999
- Down
100100
type: string
101101
delayRestoreSVI:
102+
default: 10
102103
description: |-
103104
DelayRestoreSVI is the delay in seconds (1-3600) before bringing up interface-vlan (SVI) after peer-link comes up.
104105
This prevents traffic blackholing during convergence.
105106
maximum: 3600
106107
minimum: 1
107108
type: integer
108109
delayRestoreVPC:
110+
default: 30
109111
description: DelayRestoreVPC is the delay in seconds (1-3600) before
110112
bringing up the member ports after the peer-link is restored.
111113
maximum: 3600
@@ -139,6 +141,8 @@ spec:
139141
minimum: 1
140142
type: integer
141143
fastConvergence:
144+
default:
145+
enabled: false
142146
description: |-
143147
FastConvergence ensures that both SVIs and member ports are shut down simultaneously when the peer-link goes down.
144148
This synchronization helps prevent traffic loss.
@@ -173,6 +177,7 @@ spec:
173177
before assuming the peer is dead and restoring the vPC's domain functionality.
174178
type: boolean
175179
reloadDelay:
180+
default: 240
176181
description: |-
177182
ReloadDelay is the time in seconds (60-3600) to wait before assuming the peer is dead
178183
and automatically attempting to restore the communication with the peer.
@@ -287,6 +292,7 @@ spec:
287292
- keepalive
288293
type: object
289294
rolePriority:
295+
default: 32667
290296
description: |-
291297
RolePriority is the role priority for this vPC domain (1-65535).
292298
The switch with the lower role priority becomes the operational primary.
@@ -295,6 +301,7 @@ spec:
295301
minimum: 1
296302
type: integer
297303
systemPriority:
304+
default: 32667
298305
description: |-
299306
SystemPriority is the system priority for this vPC domain (1-65535).
300307
Used to ensure that the vPC domain devices are primary devices on LACP. Must match on both peers.
@@ -382,9 +389,6 @@ spec:
382389
x-kubernetes-list-map-keys:
383390
- type
384391
x-kubernetes-list-type: map
385-
domainId:
386-
description: DomainID is the vPC domain ID as reported by the device.
387-
type: integer
388392
keepaliveStatus:
389393
description: KeepAliveStatus indicates the status of the peer via
390394
the keepalive link.

config/samples/cisco/nx/v1alpha1_vpcdomain.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ spec:
124124
delayRestoreSVI: 140
125125
delayRestoreVPC: 150
126126
peer:
127-
vpcId: 1
128127
adminState: Up
129128
interfaceRef:
130129
name: po1

internal/provider/cisco/nxos/provider.go

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2167,7 +2167,7 @@ type VPCDomainStatus struct {
21672167
Role nxv1alpha1.VPCDomainRole
21682168
}
21692169

2170-
// EnsureVPC applies the vPC configuration on the device. It also ensures that the vPC feature
2170+
// EnsureVPCDomain applies the vPC configuration on the device. It also ensures that the vPC feature
21712171
// is enabled on the device.
21722172
// `vrf` is a resource referencing the VRF to use in the keep-alive link configuration, can be nil.
21732173
// `pc` is a resource referencing a port-channel interface to use as vPC peer-link, must not be nil.
@@ -2177,32 +2177,20 @@ func (p *Provider) EnsureVPCDomain(ctx context.Context, vpcdomain *nxv1alpha1.VP
21772177
f.AdminSt = AdminStEnabled
21782178

21792179
v := new(VPCDomain)
2180-
v.Id = uint16(vpcdomain.Spec.DomainID) // #nosec G115 -- kubebuilder
2180+
v.ID = vpcdomain.Spec.DomainID
2181+
v.RolePrio = vpcdomain.Spec.RolePriority
2182+
v.SysPrio = vpcdomain.Spec.SystemPriority
2183+
v.DelayRestoreSVI = vpcdomain.Spec.DelayRestoreSVI
2184+
v.DelayRestoreVPC = vpcdomain.Spec.DelayRestoreVPC
21812185

21822186
v.AdminSt = AdminStEnabled
21832187
if vpcdomain.Spec.AdminState == v1alpha1.AdminStateDown {
21842188
v.AdminSt = AdminStDisabled
21852189
}
21862190

2187-
if vpcdomain.Spec.RolePriority > 0 {
2188-
v.RolePrio = NewOption(uint16(vpcdomain.Spec.RolePriority)) // #nosec G115 -- kubebuilder validation
2189-
}
2190-
2191-
if vpcdomain.Spec.SystemPriority > 0 {
2192-
v.SysPrio = NewOption(uint16(vpcdomain.Spec.SystemPriority)) // #nosec G115 -- kubebuilder validation
2193-
}
2194-
2195-
if vpcdomain.Spec.DelayRestoreSVI > 0 {
2196-
v.DelayRestoreSVI = NewOption(uint16(vpcdomain.Spec.DelayRestoreSVI)) // #nosec G115 -- kubebuilder validation
2197-
}
2198-
2199-
if vpcdomain.Spec.DelayRestoreVPC > 0 {
2200-
v.DelayRestoreVPC = NewOption(uint16(vpcdomain.Spec.DelayRestoreVPC)) // #nosec G115 -- kubebuilder validation
2201-
}
2202-
2203-
v.FastConvergence = NewOption(AdminStDisabled)
2191+
v.FastConvergence = AdminStDisabled
22042192
if vpcdomain.Spec.FastConvergence.Enabled {
2205-
v.FastConvergence = NewOption(AdminStEnabled)
2193+
v.FastConvergence = AdminStEnabled
22062194
}
22072195

22082196
v.PeerSwitch = AdminStDisabled
@@ -2220,18 +2208,14 @@ func (p *Provider) EnsureVPCDomain(ctx context.Context, vpcdomain *nxv1alpha1.VP
22202208
v.L3PeerRouter = AdminStEnabled
22212209
}
22222210

2223-
if vpcdomain.Spec.Peer.AutoRecovery != nil {
2224-
v.AutoRecovery = NewOption(AdminStDisabled)
2225-
if vpcdomain.Spec.Peer.AutoRecovery.Enabled {
2226-
v.AutoRecovery = NewOption(AdminStEnabled)
2227-
}
2228-
if vpcdomain.Spec.Peer.AutoRecovery.ReloadDelay > 0 {
2229-
v.AutoRecoveryReloadDelay = NewOption(uint16(vpcdomain.Spec.Peer.AutoRecovery.ReloadDelay)) // #nosec G115 -- kubebuilder validation
2230-
}
2211+
v.AutoRecovery = AdminStDisabled
2212+
v.AutoRecoveryReloadDelay = 240
2213+
if vpcdomain.Spec.Peer.AutoRecovery != nil && vpcdomain.Spec.Peer.AutoRecovery.Enabled {
2214+
v.AutoRecovery = AdminStEnabled
2215+
v.AutoRecoveryReloadDelay = vpcdomain.Spec.Peer.AutoRecovery.ReloadDelay
22312216
}
22322217

22332218
v.KeepAliveItems.DestIP = vpcdomain.Spec.Peer.KeepAlive.Destination
2234-
22352219
v.KeepAliveItems.SrcIP = vpcdomain.Spec.Peer.KeepAlive.Source
22362220

22372221
if vrf != nil {
@@ -2242,8 +2226,8 @@ func (p *Provider) EnsureVPCDomain(ctx context.Context, vpcdomain *nxv1alpha1.VP
22422226
if err != nil {
22432227
return fmt.Errorf("vpc: failed to get short name for the port-channel interface %q: %w", pc.Spec.Name, err)
22442228
}
2245-
v.KeepAliveItems.PeerLinkItems.Id = pcName
22462229

2230+
v.KeepAliveItems.PeerLinkItems.Id = pcName
22472231
v.KeepAliveItems.PeerLinkItems.AdminSt = AdminStEnabled
22482232
if vpcdomain.Spec.Peer.AdminState == v1alpha1.AdminStateDown {
22492233
v.KeepAliveItems.PeerLinkItems.AdminSt = AdminStDisabled

internal/provider/cisco/nxos/vpc.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ var (
2121

2222
// VPCDomain represents the domain of a virtual Port Channel (vPC)
2323
type VPCDomain struct {
24-
AdminSt AdminSt `json:"adminSt"`
25-
AutoRecovery Option[AdminSt] `json:"autoRecovery"`
26-
AutoRecoveryReloadDelay Option[uint16] `json:"autoRecoveryIntvl"`
27-
DelayRestoreSVI Option[uint16] `json:"delayRestoreSVI"`
28-
DelayRestoreVPC Option[uint16] `json:"delayRestoreVPC"`
29-
FastConvergence Option[AdminSt] `json:"fastConvergence"`
30-
Id uint16 `json:"id"`
31-
L3PeerRouter AdminSt `json:"l3PeerRouter"`
32-
PeerGateway AdminSt `json:"peerGw"`
33-
PeerSwitch AdminSt `json:"peerSwitch"`
34-
RolePrio Option[uint16] `json:"rolePrio"`
35-
SysPrio Option[uint16] `json:"sysPrio"`
24+
AdminSt AdminSt `json:"adminSt"`
25+
AutoRecovery AdminSt `json:"autoRecovery"`
26+
AutoRecoveryReloadDelay int16 `json:"autoRecoveryIntvl"`
27+
DelayRestoreSVI int16 `json:"delayRestoreSVI"`
28+
DelayRestoreVPC int16 `json:"delayRestoreVPC"`
29+
FastConvergence AdminSt `json:"fastConvergence"`
30+
ID int16 `json:"id"`
31+
L3PeerRouter AdminSt `json:"l3PeerRouter"`
32+
PeerGateway AdminSt `json:"peerGw"`
33+
PeerSwitch AdminSt `json:"peerSwitch"`
34+
RolePrio int32 `json:"rolePrio"`
35+
SysPrio int32 `json:"sysPrio"`
3636
KeepAliveItems struct {
3737
DestIP string `json:"destIp"`
3838
SrcIP string `json:"srcIp"`

internal/provider/cisco/nxos/vpc_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ package nxos
66
func init() {
77
vd := &VPCDomain{
88
AdminSt: AdminStEnabled,
9-
AutoRecovery: NewOption(AdminStEnabled),
10-
AutoRecoveryReloadDelay: NewOption[uint16](360),
11-
DelayRestoreSVI: NewOption[uint16](45),
12-
DelayRestoreVPC: NewOption[uint16](150),
13-
FastConvergence: NewOption(AdminStEnabled),
14-
Id: 2,
9+
AutoRecovery: AdminStEnabled,
10+
AutoRecoveryReloadDelay: 360,
11+
DelayRestoreSVI: 45,
12+
DelayRestoreVPC: 150,
13+
FastConvergence: AdminStEnabled,
14+
ID: 2,
1515
L3PeerRouter: AdminStEnabled,
1616
PeerGateway: AdminStEnabled,
1717
PeerSwitch: AdminStEnabled,
18-
RolePrio: NewOption[uint16](100),
19-
SysPrio: NewOption[uint16](10),
18+
RolePrio: 100,
19+
SysPrio: 10,
2020
}
2121
vd.KeepAliveItems.DestIP = "10.114.235.156"
2222
vd.KeepAliveItems.SrcIP = "10.114.235.155"

0 commit comments

Comments
 (0)