From 2133bc0966f4b3f7acfeb2e82f1ae6de0376215f Mon Sep 17 00:00:00 2001 From: Shreyas Date: Tue, 14 Oct 2025 14:18:36 -0700 Subject: [PATCH 1/9] Adding delete timestamp check --- cns/middlewares/k8sSwiftV2.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cns/middlewares/k8sSwiftV2.go b/cns/middlewares/k8sSwiftV2.go index 8805996060..27a7e5ae1d 100644 --- a/cns/middlewares/k8sSwiftV2.go +++ b/cns/middlewares/k8sSwiftV2.go @@ -28,6 +28,7 @@ var ( errGetMTPNC = errors.New(NetworkNotReadyErrorMsg + " - failed to get MTPNC") errInvalidSWIFTv2NICType = errors.New("invalid NIC type for SWIFT v2 scenario") errInvalidMTPNCPrefixLength = errors.New("invalid prefix length for MTPNC primaryIP, must be 32") + errDeleteTimestampSet = errors.New("MTPNC deletion timestamp is set") ) type K8sSWIFTv2Middleware struct { @@ -193,6 +194,9 @@ func (k *K8sSWIFTv2Middleware) getMTPNC(ctx context.Context, podInfo cns.PodInfo if err := k.Cli.Get(ctx, mtpncNamespacedName, &mtpnc); err != nil { return v1alpha1.MultitenantPodNetworkConfig{}, types.UnexpectedError, errors.Wrap(err, errGetMTPNC.Error()).Error() } + if mtpnc.DeletionTimestamp != nil { + return v1alpha1.MultitenantPodNetworkConfig{}, types.UnexpectedError, errDeleteTimestampSet.Error() + } // Check if the MTPNC CRD is ready. If one of the fields is empty, return error if !mtpnc.IsReady() { return v1alpha1.MultitenantPodNetworkConfig{}, types.UnexpectedError, errMTPNCNotReady.Error() From 371b8ab22842825bec4ae780abd971bc8204838a Mon Sep 17 00:00:00 2001 From: Shreyas Date: Thu, 16 Oct 2025 15:34:53 -0700 Subject: [PATCH 2/9] Adding status and removing deprecated fields from output --- .../api/v1alpha1/multitenantpodnetworkconfig.go | 4 +++- ...nancy.acn.azure.com_multitenantpodnetworkconfigs.yaml | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/crd/multitenancy/api/v1alpha1/multitenantpodnetworkconfig.go b/crd/multitenancy/api/v1alpha1/multitenantpodnetworkconfig.go index 099e510419..667ab0be54 100644 --- a/crd/multitenancy/api/v1alpha1/multitenantpodnetworkconfig.go +++ b/crd/multitenancy/api/v1alpha1/multitenantpodnetworkconfig.go @@ -17,8 +17,9 @@ import ( // +kubebuilder:metadata:labels=managed= // +kubebuilder:metadata:labels=owner= // +kubebuilder:printcolumn:name="PodNetworkInstance",type=string,JSONPath=`.spec.podNetworkInstance` -// +kubebuilder:printcolumn:name="PodNetwork",type=string,JSONPath=`.spec.podNetwork` // +kubebuilder:printcolumn:name="PodName",type=string,JSONPath=`.spec.podName` +// +kubebuilder:printcolumn:name="PodUID",type=string,JSONPath=`.spec.podUID` +// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.status` type MultitenantPodNetworkConfig struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -75,6 +76,7 @@ const ( MTPNCStatusPNINotReady MTPNCStatus = "PNINotReady" MTPNCStatusNodeCapacityExceeded MTPNCStatus = "NodeCapacityExceeded" MTPNCStatusIPsExhausted MTPNCStatus = "IPsExhausted" + MTPNCStatusDeleting MTPNCStatus = "Deleting" ) type InterfaceInfo struct { diff --git a/crd/multitenancy/manifests/multitenancy.acn.azure.com_multitenantpodnetworkconfigs.yaml b/crd/multitenancy/manifests/multitenancy.acn.azure.com_multitenantpodnetworkconfigs.yaml index e539ed4b24..7b0b71fdcf 100644 --- a/crd/multitenancy/manifests/multitenancy.acn.azure.com_multitenantpodnetworkconfigs.yaml +++ b/crd/multitenancy/manifests/multitenancy.acn.azure.com_multitenantpodnetworkconfigs.yaml @@ -23,12 +23,15 @@ spec: - jsonPath: .spec.podNetworkInstance name: PodNetworkInstance type: string - - jsonPath: .spec.podNetwork - name: PodNetwork - type: string - jsonPath: .spec.podName name: PodName type: string + - jsonPath: .spec.podUID + name: PodUID + type: string + - jsonPath: .status.status + name: Status + type: string name: v1alpha1 schema: openAPIV3Schema: From 423a320d5d5206b70750cbcfc1d468fb16a95d61 Mon Sep 17 00:00:00 2001 From: Shreyas Date: Fri, 17 Oct 2025 11:01:03 -0700 Subject: [PATCH 3/9] Revert MTPNC deletion timestamp check --- cns/middlewares/k8sSwiftV2.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cns/middlewares/k8sSwiftV2.go b/cns/middlewares/k8sSwiftV2.go index 27a7e5ae1d..8805996060 100644 --- a/cns/middlewares/k8sSwiftV2.go +++ b/cns/middlewares/k8sSwiftV2.go @@ -28,7 +28,6 @@ var ( errGetMTPNC = errors.New(NetworkNotReadyErrorMsg + " - failed to get MTPNC") errInvalidSWIFTv2NICType = errors.New("invalid NIC type for SWIFT v2 scenario") errInvalidMTPNCPrefixLength = errors.New("invalid prefix length for MTPNC primaryIP, must be 32") - errDeleteTimestampSet = errors.New("MTPNC deletion timestamp is set") ) type K8sSWIFTv2Middleware struct { @@ -194,9 +193,6 @@ func (k *K8sSWIFTv2Middleware) getMTPNC(ctx context.Context, podInfo cns.PodInfo if err := k.Cli.Get(ctx, mtpncNamespacedName, &mtpnc); err != nil { return v1alpha1.MultitenantPodNetworkConfig{}, types.UnexpectedError, errors.Wrap(err, errGetMTPNC.Error()).Error() } - if mtpnc.DeletionTimestamp != nil { - return v1alpha1.MultitenantPodNetworkConfig{}, types.UnexpectedError, errDeleteTimestampSet.Error() - } // Check if the MTPNC CRD is ready. If one of the fields is empty, return error if !mtpnc.IsReady() { return v1alpha1.MultitenantPodNetworkConfig{}, types.UnexpectedError, errMTPNCNotReady.Error() From 9745204ba3f1539ba43625abb49e32661b2afe1c Mon Sep 17 00:00:00 2001 From: Shreyas Date: Tue, 21 Oct 2025 13:40:53 -0700 Subject: [PATCH 4/9] fix: removing unused fields --- crd/multitenancy/api/v1alpha1/podnetwork.go | 2 +- crd/multitenancy/api/v1alpha1/podnetworkinstance.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crd/multitenancy/api/v1alpha1/podnetwork.go b/crd/multitenancy/api/v1alpha1/podnetwork.go index 4f21ccbe07..f2b23c7670 100644 --- a/crd/multitenancy/api/v1alpha1/podnetwork.go +++ b/crd/multitenancy/api/v1alpha1/podnetwork.go @@ -19,7 +19,7 @@ import ( // +kubebuilder:printcolumn:name="Network",type=string,priority=1,JSONPath=`.spec.networkID` // +kubebuilder:printcolumn:name="Subnet",type=string,priority=1,JSONPath=`.spec.subnetResourceID` // +kubebuilder:printcolumn:name="SubnetGUID",type=string,priority=1,JSONPath=`.spec.subnetGUID` -// +kubebuilder:printcolumn:name="DeviceType",type=string,priority=1,JSONPath=`.spec.subnetGUID` +// +kubebuilder:printcolumn:name="DeviceType",type=string,priority=1,JSONPath=`.spec.deviceType` type PodNetwork struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` diff --git a/crd/multitenancy/api/v1alpha1/podnetworkinstance.go b/crd/multitenancy/api/v1alpha1/podnetworkinstance.go index 0437bee57f..a075aa4811 100644 --- a/crd/multitenancy/api/v1alpha1/podnetworkinstance.go +++ b/crd/multitenancy/api/v1alpha1/podnetworkinstance.go @@ -17,7 +17,7 @@ import ( // +kubebuilder:metadata:labels=managed= // +kubebuilder:metadata:labels=owner= // +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.status` -// +kubebuilder:printcolumn:name="PodNetworks",priority=1,type=string,JSONPath=`.spec.podNetworks` +// +kubebuilder:printcolumn:name="PodNetworks",priority=1,type=string,JSONPath=`.spec.podNetworkConfigs[*].podNetwork` type PodNetworkInstance struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` From 2059816ec18327ec2acb6d9e4ca0033d425ebcf8 Mon Sep 17 00:00:00 2001 From: Shreyas Date: Tue, 21 Oct 2025 13:46:18 -0700 Subject: [PATCH 5/9] fix: removing unused fields --- .../multitenancy.acn.azure.com_podnetworkinstances.yaml | 2 +- .../manifests/multitenancy.acn.azure.com_podnetworks.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crd/multitenancy/manifests/multitenancy.acn.azure.com_podnetworkinstances.yaml b/crd/multitenancy/manifests/multitenancy.acn.azure.com_podnetworkinstances.yaml index 3f13488dbe..496c26a2ce 100644 --- a/crd/multitenancy/manifests/multitenancy.acn.azure.com_podnetworkinstances.yaml +++ b/crd/multitenancy/manifests/multitenancy.acn.azure.com_podnetworkinstances.yaml @@ -23,7 +23,7 @@ spec: - jsonPath: .status.status name: Status type: string - - jsonPath: .spec.podNetworks + - jsonPath: .spec.podNetworkConfigs[*].podNetwork name: PodNetworks priority: 1 type: string diff --git a/crd/multitenancy/manifests/multitenancy.acn.azure.com_podnetworks.yaml b/crd/multitenancy/manifests/multitenancy.acn.azure.com_podnetworks.yaml index 90ed5b698f..173174e771 100644 --- a/crd/multitenancy/manifests/multitenancy.acn.azure.com_podnetworks.yaml +++ b/crd/multitenancy/manifests/multitenancy.acn.azure.com_podnetworks.yaml @@ -37,7 +37,7 @@ spec: name: SubnetGUID priority: 1 type: string - - jsonPath: .spec.subnetGUID + - jsonPath: .spec.deviceType name: DeviceType priority: 1 type: string From b60a9d15628f45ba01bc8ac74809b5564a0df5ec Mon Sep 17 00:00:00 2001 From: Shreyas Date: Tue, 21 Oct 2025 15:53:03 -0700 Subject: [PATCH 6/9] Adding documentation for the status --- .../api/v1alpha1/multitenantpodnetworkconfig.go | 10 +++++++++- crd/multitenancy/api/v1alpha1/podnetworkinstance.go | 1 - ...ncy.acn.azure.com_multitenantpodnetworkconfigs.yaml | 1 + ...multitenancy.acn.azure.com_podnetworkinstances.yaml | 4 ---- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/crd/multitenancy/api/v1alpha1/multitenantpodnetworkconfig.go b/crd/multitenancy/api/v1alpha1/multitenantpodnetworkconfig.go index 667ab0be54..8b3b622ecc 100644 --- a/crd/multitenancy/api/v1alpha1/multitenantpodnetworkconfig.go +++ b/crd/multitenancy/api/v1alpha1/multitenantpodnetworkconfig.go @@ -65,17 +65,25 @@ const ( ) // MTPNCStatus indicates the high-level status of MultitenantPodNetworkConfig -// +kubebuilder:validation:Enum=Ready;Pending;InternalError;PNINotFound;PNINotReady;NodeCapacityExceeded;IPsExhausted +// +kubebuilder:validation:Enum=Ready;Pending;InternalError;PNINotFound;PNINotReady;NodeCapacityExceeded;IPsExhausted;Deleting type MTPNCStatus string const ( + // MTPNCStatusReady indicates the MTPNC has been successfully programmed and is ready for use MTPNCStatusReady MTPNCStatus = "Ready" + // MTPNCStatusPending indicates the MTPNC is awaiting processing MTPNCStatusPending MTPNCStatus = "Pending" + // MTPNCStatusInternalError indicates an internal error occurred while processing the MTPNC MTPNCStatusInternalError MTPNCStatus = "InternalError" + // MTPNCStatusPNINotFound indicates the referenced PodNetworkInstance was not found MTPNCStatusPNINotFound MTPNCStatus = "PNINotFound" + // MTPNCStatusPNINotReady indicates the referenced PodNetworkInstance is not yet ready MTPNCStatusPNINotReady MTPNCStatus = "PNINotReady" + // MTPNCStatusNodeCapacityExceeded indicates the node has exceeded its capacity for network resources MTPNCStatusNodeCapacityExceeded MTPNCStatus = "NodeCapacityExceeded" + // MTPNCStatusIPsExhausted indicates no IP addresses are available for allocation MTPNCStatusIPsExhausted MTPNCStatus = "IPsExhausted" + // MTPNCStatusDeleting indicates MTPNC is being deleted. DNC-RC sets this status during the finalizer removal process MTPNCStatusDeleting MTPNCStatus = "Deleting" ) diff --git a/crd/multitenancy/api/v1alpha1/podnetworkinstance.go b/crd/multitenancy/api/v1alpha1/podnetworkinstance.go index a075aa4811..3f78dd58e5 100644 --- a/crd/multitenancy/api/v1alpha1/podnetworkinstance.go +++ b/crd/multitenancy/api/v1alpha1/podnetworkinstance.go @@ -17,7 +17,6 @@ import ( // +kubebuilder:metadata:labels=managed= // +kubebuilder:metadata:labels=owner= // +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.status` -// +kubebuilder:printcolumn:name="PodNetworks",priority=1,type=string,JSONPath=`.spec.podNetworkConfigs[*].podNetwork` type PodNetworkInstance struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` diff --git a/crd/multitenancy/manifests/multitenancy.acn.azure.com_multitenantpodnetworkconfigs.yaml b/crd/multitenancy/manifests/multitenancy.acn.azure.com_multitenantpodnetworkconfigs.yaml index 7b0b71fdcf..db8c1de9ba 100644 --- a/crd/multitenancy/manifests/multitenancy.acn.azure.com_multitenantpodnetworkconfigs.yaml +++ b/crd/multitenancy/manifests/multitenancy.acn.azure.com_multitenantpodnetworkconfigs.yaml @@ -157,6 +157,7 @@ spec: - PNINotReady - NodeCapacityExceeded - IPsExhausted + - Deleting type: string type: object type: object diff --git a/crd/multitenancy/manifests/multitenancy.acn.azure.com_podnetworkinstances.yaml b/crd/multitenancy/manifests/multitenancy.acn.azure.com_podnetworkinstances.yaml index 496c26a2ce..432cb5a222 100644 --- a/crd/multitenancy/manifests/multitenancy.acn.azure.com_podnetworkinstances.yaml +++ b/crd/multitenancy/manifests/multitenancy.acn.azure.com_podnetworkinstances.yaml @@ -23,10 +23,6 @@ spec: - jsonPath: .status.status name: Status type: string - - jsonPath: .spec.podNetworkConfigs[*].podNetwork - name: PodNetworks - priority: 1 - type: string name: v1alpha1 schema: openAPIV3Schema: From c1258152f1b2cb1755a673dd29141ee9a21d3c2e Mon Sep 17 00:00:00 2001 From: Shreyas Date: Tue, 21 Oct 2025 16:39:38 -0700 Subject: [PATCH 7/9] Formatting the config file --- .../api/v1alpha1/multitenantpodnetworkconfig.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/crd/multitenancy/api/v1alpha1/multitenantpodnetworkconfig.go b/crd/multitenancy/api/v1alpha1/multitenantpodnetworkconfig.go index 8b3b622ecc..83e5159048 100644 --- a/crd/multitenancy/api/v1alpha1/multitenantpodnetworkconfig.go +++ b/crd/multitenancy/api/v1alpha1/multitenantpodnetworkconfig.go @@ -70,21 +70,22 @@ type MTPNCStatus string const ( // MTPNCStatusReady indicates the MTPNC has been successfully programmed and is ready for use - MTPNCStatusReady MTPNCStatus = "Ready" + MTPNCStatusReady MTPNCStatus = "Ready" // MTPNCStatusPending indicates the MTPNC is awaiting processing - MTPNCStatusPending MTPNCStatus = "Pending" + MTPNCStatusPending MTPNCStatus = "Pending" // MTPNCStatusInternalError indicates an internal error occurred while processing the MTPNC - MTPNCStatusInternalError MTPNCStatus = "InternalError" + MTPNCStatusInternalError MTPNCStatus = "InternalError" // MTPNCStatusPNINotFound indicates the referenced PodNetworkInstance was not found - MTPNCStatusPNINotFound MTPNCStatus = "PNINotFound" + MTPNCStatusPNINotFound MTPNCStatus = "PNINotFound" // MTPNCStatusPNINotReady indicates the referenced PodNetworkInstance is not yet ready - MTPNCStatusPNINotReady MTPNCStatus = "PNINotReady" + MTPNCStatusPNINotReady MTPNCStatus = "PNINotReady" // MTPNCStatusNodeCapacityExceeded indicates the node has exceeded its capacity for network resources MTPNCStatusNodeCapacityExceeded MTPNCStatus = "NodeCapacityExceeded" // MTPNCStatusIPsExhausted indicates no IP addresses are available for allocation - MTPNCStatusIPsExhausted MTPNCStatus = "IPsExhausted" - // MTPNCStatusDeleting indicates MTPNC is being deleted. DNC-RC sets this status during the finalizer removal process - MTPNCStatusDeleting MTPNCStatus = "Deleting" + MTPNCStatusIPsExhausted MTPNCStatus = "IPsExhausted" + // MTPNCStatusDeleting indicates MTPNC is being deleted. DNC-RC sets this status during the finalizer removal process. + // Note: Do not take a programmatic dependency on this status as the status update may fail for various reasons. + MTPNCStatusDeleting MTPNCStatus = "Deleting" ) type InterfaceInfo struct { From 7ddb56b36b9bdbb94e75af2086ed6df3ea9dd430 Mon Sep 17 00:00:00 2001 From: Shreyas Date: Wed, 22 Oct 2025 10:45:19 -0700 Subject: [PATCH 8/9] Addressing PR comments --- crd/multitenancy/api/v1alpha1/multitenantpodnetworkconfig.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crd/multitenancy/api/v1alpha1/multitenantpodnetworkconfig.go b/crd/multitenancy/api/v1alpha1/multitenantpodnetworkconfig.go index 83e5159048..4f9ba3420a 100644 --- a/crd/multitenancy/api/v1alpha1/multitenantpodnetworkconfig.go +++ b/crd/multitenancy/api/v1alpha1/multitenantpodnetworkconfig.go @@ -83,8 +83,7 @@ const ( MTPNCStatusNodeCapacityExceeded MTPNCStatus = "NodeCapacityExceeded" // MTPNCStatusIPsExhausted indicates no IP addresses are available for allocation MTPNCStatusIPsExhausted MTPNCStatus = "IPsExhausted" - // MTPNCStatusDeleting indicates MTPNC is being deleted. DNC-RC sets this status during the finalizer removal process. - // Note: Do not take a programmatic dependency on this status as the status update may fail for various reasons. + // MTPNCStatusDeleting indicates MTPNC is being deleted, status may not be set at the same time as deletionTimestamp. MTPNCStatusDeleting MTPNCStatus = "Deleting" ) From 43fb4d0b6c91a4e595e0a86385eacb30d85e7079 Mon Sep 17 00:00:00 2001 From: Shreyas Date: Wed, 22 Oct 2025 16:13:03 -0700 Subject: [PATCH 9/9] Changing type for pod uid --- crd/multitenancy/api/v1alpha1/multitenantpodnetworkconfig.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crd/multitenancy/api/v1alpha1/multitenantpodnetworkconfig.go b/crd/multitenancy/api/v1alpha1/multitenantpodnetworkconfig.go index 4f9ba3420a..198b990415 100644 --- a/crd/multitenancy/api/v1alpha1/multitenantpodnetworkconfig.go +++ b/crd/multitenancy/api/v1alpha1/multitenantpodnetworkconfig.go @@ -5,6 +5,7 @@ package v1alpha1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" ) // Important: Run "make" to regenerate code after modifying this file @@ -50,7 +51,7 @@ type MultitenantPodNetworkConfigSpec struct { // +kubebuilder:validation:Optional IBMACAddresses []string `json:"IBMACAddresses,omitempty"` // PodUID is the UID of the pod - PodUID string `json:"podUID,omitempty"` + PodUID types.UID `json:"podUID,omitempty"` } // +kubebuilder:validation:Enum=Unprogrammed;Programming;Programmed;Unprogramming;Failed