Skip to content

Commit

Permalink
Stop getting the K8s version of target cluster in uninstall mode
Browse files Browse the repository at this point in the history
The target Kubernetes cluster may not be up and running at the time of
uninstall, so don't bother getting cluster version information.

Relates:
https://issues.redhat.com/browse/ACM-8826

Signed-off-by: mprahl <mprahl@users.noreply.github.com>
  • Loading branch information
mprahl committed Dec 6, 2023
1 parent 2476d97 commit 94a3769
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ func main() {
instanceName, _ := os.Hostname() // on an error, instanceName will be empty, which is ok

var nsSelReconciler common.NamespaceSelectorReconciler
var dryRunSupported bool

if !beingUninstalled {
nsSelReconciler = common.NamespaceSelectorReconciler{
Expand All @@ -366,24 +367,24 @@ func main() {
log.Error(err, "Unable to create controller", "controller", "NamespaceSelector")
os.Exit(1)
}
}

discoveryClient := discovery.NewDiscoveryClientForConfigOrDie(targetK8sConfig)
discoveryClient := discovery.NewDiscoveryClientForConfigOrDie(targetK8sConfig)

serverVersion, err := discoveryClient.ServerVersion()
if err != nil {
log.Error(err, "unable to detect the managed cluster's Kubernetes version")
os.Exit(1)
}
serverVersion, err := discoveryClient.ServerVersion()
if err != nil {
log.Error(err, "unable to detect the managed cluster's Kubernetes version")
os.Exit(1)
}

dryRunSupported := semver.Compare(serverVersion.GitVersion, "v1.18.0") >= 0
if dryRunSupported {
log.Info("The managed cluster supports dry run API requests")
} else {
log.Info(
"The managed cluster does not support dry run API requests. Will assume that empty values are equal to " +
"not being set.",
)
dryRunSupported = semver.Compare(serverVersion.GitVersion, "v1.18.0") >= 0
if dryRunSupported {
log.Info("The managed cluster supports dry run API requests")
} else {
log.Info(
"The managed cluster does not support dry run API requests. Will assume that empty values are equal " +
"to not being set.",
)
}
}

reconciler := controllers.ConfigurationPolicyReconciler{
Expand Down

0 comments on commit 94a3769

Please sign in to comment.