Skip subnet config get while --airgap mode of license register (#4479)

Signed-off-by: Shubhendu Ram Tripathi <shubhendu@minio.io>
This commit is contained in:
Shubhendu
2023-03-08 00:26:24 -08:00
committed by GitHub
parent bf4a825530
commit aaed62cdd8
2 changed files with 21 additions and 19 deletions
+15 -15
View File
@@ -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:")
+6 -4
View File
@@ -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)
}