From aaed62cdd86122fad66bb67fe302b8cd4dd991bc Mon Sep 17 00:00:00 2001 From: Shubhendu Date: Wed, 8 Mar 2023 13:56:24 +0530 Subject: [PATCH] Skip subnet config get while `--airgap` mode of license register (#4479) Signed-off-by: Shubhendu Ram Tripathi --- cmd/license-register.go | 30 +++++++++++++++--------------- cmd/subnet-utils.go | 10 ++++++---- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/cmd/license-register.go b/cmd/license-register.go index 76a5faf4..0eea93af 100644 --- a/cmd/license-register.go +++ b/cmd/license-register.go @@ -169,21 +169,6 @@ func mainLicenseRegister(ctx *cli.Context) error { regInfo := getClusterRegInfo(getAdminInfo(aliasedURL), clusterName) - alreadyRegistered := false - if len(accAPIKey) == 0 { - apiKey, _, e := getSubnetCreds(alias) - fatalIf(probe.NewError(e), "Error in fetching subnet API Key") - if len(apiKey) > 0 { - alreadyRegistered = true - accAPIKey = apiKey - } - } else { - apiKey := getSubnetAPIKeyFromConfig(alias) - if len(apiKey) > 0 { - alreadyRegistered = true - } - } - lrm := licRegisterMessage{Status: "success", Alias: alias} if globalAirgapped { lrm.Type = "offline" @@ -193,6 +178,21 @@ func mainLicenseRegister(ctx *cli.Context) error { lrm.URL = subnetOfflineRegisterURL(regToken) } else { + alreadyRegistered := false + if len(accAPIKey) == 0 { + apiKey, _, e := getSubnetCreds(alias) + fatalIf(probe.NewError(e), "Error in fetching subnet API Key") + if len(apiKey) > 0 { + alreadyRegistered = true + accAPIKey = apiKey + } + } else { + apiKey := getSubnetAPIKeyFromConfig(alias) + if len(apiKey) > 0 { + alreadyRegistered = true + } + } + lrm.Type = "online" _, _, e := registerClusterOnSubnet(regInfo, alias, accAPIKey) fatalIf(probe.NewError(e), "Could not register cluster with SUBNET:") diff --git a/cmd/subnet-utils.go b/cmd/subnet-utils.go index 0dace216..8fb6a12f 100644 --- a/cmd/subnet-utils.go +++ b/cmd/subnet-utils.go @@ -253,7 +253,9 @@ func getMinIOSubnetConfig(alias string) []madmin.SubsysConfig { var e error globalSubnetConfig, e = getMinIOSubSysConfig(client, madmin.SubnetSubSys) - fatalIf(probe.NewError(e), "Unable to get server config for subnet") + if e != nil && e.Error() != "unknown sub-system subnet" { + fatal(probe.NewError(e), "Unable to get server config for subnet") + } return globalSubnetConfig } @@ -779,14 +781,14 @@ func initSubnetConnectivity(ctx *cli.Context, aliasedURL string, forUpload bool) alias, _ := url2Alias(aliasedURL) - e = setGlobalSubnetProxyFromConfig(alias) - fatalIf(probe.NewError(e), "Error in setting SUBNET proxy:") - apiKey, e := getAPIKeyFlag(ctx) fatalIf(probe.NewError(e), "Error in reading --api-key flag:") // if `--airgap` is provided no need to test SUBNET connectivity. if !globalAirgapped { + e = setGlobalSubnetProxyFromConfig(alias) + fatalIf(probe.NewError(e), "Error in setting SUBNET proxy:") + sbu := subnetBaseURL() fatalIf(checkURLReachable(sbu).Trace(aliasedURL), "Unable to reach %s, please use --airgap if there is no connectivity to SUBNET", sbu) }