From 5d50c9beb91db3227f129618367cff3c3daabae5 Mon Sep 17 00:00:00 2001 From: Shireesh Anjal <355479+anjalshireesh@users.noreply.github.com> Date: Fri, 11 Feb 2022 22:58:15 +0530 Subject: [PATCH] Error out from `support diag` if cluster not registered (#3970) If user tries to run `mc support diag` for a cluster that is not yet registered, error out asking the user to register the cluster first. --- cmd/support-callhome-set.go | 2 +- cmd/support-diag.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/support-callhome-set.go b/cmd/support-callhome-set.go index 99c85268..26595b4c 100644 --- a/cmd/support-callhome-set.go +++ b/cmd/support-callhome-set.go @@ -113,7 +113,7 @@ func configureSubnetWebhook(aliasedURL string, enable bool) { apiKey := getSubnetAPIKeyFromConfig(alias) if len(apiKey) == 0 { - e := fmt.Errorf("Please register the cluster first by running 'mc admin subnet register %s'", alias) + e := fmt.Errorf("Please register the cluster first by running 'mc support register %s'", alias) fatalIf(probe.NewError(e), "Cluster not registered.") } diff --git a/cmd/support-diag.go b/cmd/support-diag.go index 265a81e1..eda52e62 100644 --- a/cmd/support-diag.go +++ b/cmd/support-diag.go @@ -299,6 +299,11 @@ func prepareDiagUploadURL(alias string, clusterName string, filename string, lic if len(apiKey) == 0 { license = getSubnetLicenseFromConfig(alias) + if len(license) == 0 { + // Both api key and license not available. Ask user to register the cluster first + e := fmt.Errorf("Please register the cluster first by running 'mc support register %s', or use --airgap flag", alias) + fatalIf(probe.NewError(e), "Cluster not registered.") + } } }