Skip to content

Commit a3f179b

Browse files
authored
Add status to mtpnc crd (#4070)
* add status to mtpnc crd * update mtpnc status * update mtpnc status only * fix lint formating errs * add crd manifest * update mtpnc statuses * fix status enum * address pr feedback * fix lint * add missing file
1 parent 73f6733 commit a3f179b

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

crd/multitenancy/api/v1alpha1/multitenantpodnetworkconfig.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,20 @@ const (
6363
Failed InfinibandStatus = "Failed"
6464
)
6565

66+
// MTPNCStatus indicates the high-level status of MultitenantPodNetworkConfig
67+
// +kubebuilder:validation:Enum=Ready;Pending;InternalError;PNINotFound;PNINotReady;NodeCapacityExceeded;IPsExhausted
68+
type MTPNCStatus string
69+
70+
const (
71+
MTPNCStatusReady MTPNCStatus = "Ready"
72+
MTPNCStatusPending MTPNCStatus = "Pending"
73+
MTPNCStatusInternalError MTPNCStatus = "InternalError"
74+
MTPNCStatusPNINotFound MTPNCStatus = "PNINotFound"
75+
MTPNCStatusPNINotReady MTPNCStatus = "PNINotReady"
76+
MTPNCStatusNodeCapacityExceeded MTPNCStatus = "NodeCapacityExceeded"
77+
MTPNCStatusIPsExhausted MTPNCStatus = "IPsExhausted"
78+
)
79+
6680
type InterfaceInfo struct {
6781
// NCID is the network container id
6882
NCID string `json:"ncID,omitempty"`
@@ -110,6 +124,9 @@ type MultitenantPodNetworkConfigStatus struct {
110124
// NodeName is the name of the node where the pod is scheduled
111125
// +kubebuilder:validation:Optional
112126
NodeName string `json:"nodeName,omitempty"`
127+
// Status represents the overall status of the MTPNC
128+
// +kubebuilder:validation:Optional
129+
Status MTPNCStatus `json:"status,omitempty"`
113130
}
114131

115132
func init() {

crd/multitenancy/embed_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const mtpncFilename = "manifests/multitenancy.acn.azure.com_multitenantpodnetwor
1212
func TestEmbedMTPNC(t *testing.T) {
1313
b, err := os.ReadFile(mtpncFilename)
1414
assert.NoError(t, err)
15-
assert.Equal(t, b, MultitenantPodNetworkConfigsYAML)
15+
assert.YAMLEq(t, string(b), string(MultitenantPodNetworkConfigsYAML))
1616
}
1717

1818
func TestGetMultitenantPodNetworkConfigs(t *testing.T) {
@@ -25,7 +25,7 @@ const nodeinfoFilename = "manifests/multitenancy.acn.azure.com_nodeinfo.yaml"
2525
func TestEmbedNodeInfo(t *testing.T) {
2626
b, err := os.ReadFile(nodeinfoFilename)
2727
assert.NoError(t, err)
28-
assert.Equal(t, b, NodeInfoYAML)
28+
assert.YAMLEq(t, string(b), string(NodeInfoYAML))
2929
}
3030

3131
func TestGetNodeInfo(t *testing.T) {
@@ -38,7 +38,7 @@ const podNetworkFilename = "manifests/multitenancy.acn.azure.com_podnetworks.yam
3838
func TestEmbedPodNetwork(t *testing.T) {
3939
b, err := os.ReadFile(podNetworkFilename)
4040
assert.NoError(t, err)
41-
assert.Equal(t, b, PodNetworkYAML)
41+
assert.YAMLEq(t, string(b), string(PodNetworkYAML))
4242
}
4343

4444
func TestGetPodNetworks(t *testing.T) {
@@ -51,7 +51,7 @@ const podNetworkInstanceFilename = "manifests/multitenancy.acn.azure.com_podnetw
5151
func TestEmbedPodNetworkInstance(t *testing.T) {
5252
b, err := os.ReadFile(podNetworkInstanceFilename)
5353
assert.NoError(t, err)
54-
assert.Equal(t, b, PodNetworkInstanceYAML)
54+
assert.YAMLEq(t, string(b), string(PodNetworkInstanceYAML))
5555
}
5656

5757
func TestGetPodNetworkInstances(t *testing.T) {

crd/multitenancy/manifests/multitenancy.acn.azure.com_multitenantpodnetworkconfigs.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,17 @@ spec:
144144
primaryIP:
145145
description: Deprecated - use InterfaceInfos
146146
type: string
147+
status:
148+
description: Status represents the overall status of the MTPNC
149+
enum:
150+
- Ready
151+
- Pending
152+
- InternalError
153+
- PNINotFound
154+
- PNINotReady
155+
- NodeCapacityExceeded
156+
- IPsExhausted
157+
type: string
147158
type: object
148159
type: object
149160
served: true

0 commit comments

Comments
 (0)