From 268a9960c6b70ddbf6fd751fe6eae6ebb24f4077 Mon Sep 17 00:00:00 2001 From: Vishal Thapar <5137689+vthapar@users.noreply.github.com> Date: Mon, 23 Sep 2024 10:56:58 +0530 Subject: [PATCH] Fix validations in ValidateClustersetIP ...which give false negative when there is a conflict with another cluster. 1. Don't check if allocation size and ClustersetIPCIDR are both configured. This check is not required coz user can't set size and is auto-allocated. This check causes a false negative when we have to retry CIDR allocation due to conflict with another cluster. 2. On conflict, reset netconfig.ClustersetIPCIDR to user configured CIDR before retrying. This avoids failing validation with CIDR that already conflicted. Signed-off-by: Vishal Thapar <5137689+vthapar@users.noreply.github.com> --- pkg/discovery/clustersetip/clustersetip.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pkg/discovery/clustersetip/clustersetip.go b/pkg/discovery/clustersetip/clustersetip.go index f87a6d0de..f2c20e4d0 100644 --- a/pkg/discovery/clustersetip/clustersetip.go +++ b/pkg/discovery/clustersetip/clustersetip.go @@ -63,12 +63,6 @@ func ValidateClustersetIPConfiguration(clustersetIPInfo *Info, netconfig Config, clustersetIPInfo.AllocationSize = clusterSize } - if clustersetIPCIDR != "" && clustersetIPClusterSize != 0 { - status.Failure("Only one of cluster size and clustersetip CIDR can be specified") - - return "", errors.New("only one of cluster size and clustersetip CIDR can be specified") - } - if clustersetIPCIDR != "" { err := cidr.IsValid(clustersetIPCIDR) if err != nil { @@ -178,6 +172,7 @@ func AllocateCIDRFromConfigMap(ctx context.Context, brokerAdminClient controller netconfig.AllocationSize = DefaultAllocationSize } + userClustersetIPCIDR := netconfig.ClustersetIPCIDR retryErr := retry.RetryOnConflict(retry.DefaultRetry, func() error { status.Start("Retrieving ClustersetIP information from the Broker") defer status.End() @@ -209,6 +204,8 @@ func AllocateCIDRFromConfigMap(ctx context.Context, brokerAdminClient controller err = updateConfigMap(ctx, brokerAdminClient, clustersetIPConfigMap, newClusterInfo) if apierrors.IsConflict(err) { status.Warning("Conflict occurred updating the ClustersetIP ConfigMap - retrying") + // Conflict with allocation, retry with user given CIDR to try reallocation + netconfig.ClustersetIPCIDR = userClustersetIPCIDR } else { return status.Error(err, "error updating the ClustersetIP ConfigMap") }