Skip to content

Commit 2133bc0

Browse files
Adding delete timestamp check
1 parent a3f179b commit 2133bc0

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

cns/middlewares/k8sSwiftV2.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var (
2828
errGetMTPNC = errors.New(NetworkNotReadyErrorMsg + " - failed to get MTPNC")
2929
errInvalidSWIFTv2NICType = errors.New("invalid NIC type for SWIFT v2 scenario")
3030
errInvalidMTPNCPrefixLength = errors.New("invalid prefix length for MTPNC primaryIP, must be 32")
31+
errDeleteTimestampSet = errors.New("MTPNC deletion timestamp is set")
3132
)
3233

3334
type K8sSWIFTv2Middleware struct {
@@ -193,6 +194,9 @@ func (k *K8sSWIFTv2Middleware) getMTPNC(ctx context.Context, podInfo cns.PodInfo
193194
if err := k.Cli.Get(ctx, mtpncNamespacedName, &mtpnc); err != nil {
194195
return v1alpha1.MultitenantPodNetworkConfig{}, types.UnexpectedError, errors.Wrap(err, errGetMTPNC.Error()).Error()
195196
}
197+
if mtpnc.DeletionTimestamp != nil {
198+
return v1alpha1.MultitenantPodNetworkConfig{}, types.UnexpectedError, errDeleteTimestampSet.Error()
199+
}
196200
// Check if the MTPNC CRD is ready. If one of the fields is empty, return error
197201
if !mtpnc.IsReady() {
198202
return v1alpha1.MultitenantPodNetworkConfig{}, types.UnexpectedError, errMTPNCNotReady.Error()

0 commit comments

Comments
 (0)