diff --git a/crd/multitenancy/api/v1alpha1/multitenantpodnetworkconfig.go b/crd/multitenancy/api/v1alpha1/multitenantpodnetworkconfig.go index f1f76b5d4c..099e510419 100644 --- a/crd/multitenancy/api/v1alpha1/multitenantpodnetworkconfig.go +++ b/crd/multitenancy/api/v1alpha1/multitenantpodnetworkconfig.go @@ -63,6 +63,20 @@ const ( Failed InfinibandStatus = "Failed" ) +// MTPNCStatus indicates the high-level status of MultitenantPodNetworkConfig +// +kubebuilder:validation:Enum=Ready;Pending;InternalError;PNINotFound;PNINotReady;NodeCapacityExceeded;IPsExhausted +type MTPNCStatus string + +const ( + MTPNCStatusReady MTPNCStatus = "Ready" + MTPNCStatusPending MTPNCStatus = "Pending" + MTPNCStatusInternalError MTPNCStatus = "InternalError" + MTPNCStatusPNINotFound MTPNCStatus = "PNINotFound" + MTPNCStatusPNINotReady MTPNCStatus = "PNINotReady" + MTPNCStatusNodeCapacityExceeded MTPNCStatus = "NodeCapacityExceeded" + MTPNCStatusIPsExhausted MTPNCStatus = "IPsExhausted" +) + type InterfaceInfo struct { // NCID is the network container id NCID string `json:"ncID,omitempty"` @@ -110,6 +124,9 @@ type MultitenantPodNetworkConfigStatus struct { // NodeName is the name of the node where the pod is scheduled // +kubebuilder:validation:Optional NodeName string `json:"nodeName,omitempty"` + // Status represents the overall status of the MTPNC + // +kubebuilder:validation:Optional + Status MTPNCStatus `json:"status,omitempty"` } func init() { diff --git a/crd/multitenancy/embed_test.go b/crd/multitenancy/embed_test.go index d0ccc93841..d22ed35826 100644 --- a/crd/multitenancy/embed_test.go +++ b/crd/multitenancy/embed_test.go @@ -12,7 +12,7 @@ const mtpncFilename = "manifests/multitenancy.acn.azure.com_multitenantpodnetwor func TestEmbedMTPNC(t *testing.T) { b, err := os.ReadFile(mtpncFilename) assert.NoError(t, err) - assert.Equal(t, b, MultitenantPodNetworkConfigsYAML) + assert.YAMLEq(t, string(b), string(MultitenantPodNetworkConfigsYAML)) } func TestGetMultitenantPodNetworkConfigs(t *testing.T) { @@ -25,7 +25,7 @@ const nodeinfoFilename = "manifests/multitenancy.acn.azure.com_nodeinfo.yaml" func TestEmbedNodeInfo(t *testing.T) { b, err := os.ReadFile(nodeinfoFilename) assert.NoError(t, err) - assert.Equal(t, b, NodeInfoYAML) + assert.YAMLEq(t, string(b), string(NodeInfoYAML)) } func TestGetNodeInfo(t *testing.T) { @@ -38,7 +38,7 @@ const podNetworkFilename = "manifests/multitenancy.acn.azure.com_podnetworks.yam func TestEmbedPodNetwork(t *testing.T) { b, err := os.ReadFile(podNetworkFilename) assert.NoError(t, err) - assert.Equal(t, b, PodNetworkYAML) + assert.YAMLEq(t, string(b), string(PodNetworkYAML)) } func TestGetPodNetworks(t *testing.T) { @@ -51,7 +51,7 @@ const podNetworkInstanceFilename = "manifests/multitenancy.acn.azure.com_podnetw func TestEmbedPodNetworkInstance(t *testing.T) { b, err := os.ReadFile(podNetworkInstanceFilename) assert.NoError(t, err) - assert.Equal(t, b, PodNetworkInstanceYAML) + assert.YAMLEq(t, string(b), string(PodNetworkInstanceYAML)) } func TestGetPodNetworkInstances(t *testing.T) { diff --git a/crd/multitenancy/manifests/multitenancy.acn.azure.com_multitenantpodnetworkconfigs.yaml b/crd/multitenancy/manifests/multitenancy.acn.azure.com_multitenantpodnetworkconfigs.yaml index 9d754a9773..e539ed4b24 100644 --- a/crd/multitenancy/manifests/multitenancy.acn.azure.com_multitenantpodnetworkconfigs.yaml +++ b/crd/multitenancy/manifests/multitenancy.acn.azure.com_multitenantpodnetworkconfigs.yaml @@ -144,6 +144,17 @@ spec: primaryIP: description: Deprecated - use InterfaceInfos type: string + status: + description: Status represents the overall status of the MTPNC + enum: + - Ready + - Pending + - InternalError + - PNINotFound + - PNINotReady + - NodeCapacityExceeded + - IPsExhausted + type: string type: object type: object served: true