Skip to content

Commit

Permalink
Ask for confirmation before disabling OpenShift CVO
Browse files Browse the repository at this point in the history
When subctl join is run against an OpenShift cluster with a deployed
cluster version operator, and service discovery is enabled, we now ask
for confirmation before continuing, because installing service
discovery will disable the CVO.

Fixes: submariner-io#167
Signed-off-by: Stephen Kitt <skitt@redhat.com>
  • Loading branch information
skitt committed Mar 2, 2020
1 parent ee217e6 commit fc7091b
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions pkg/subctl/cmd/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,21 @@ func joinSubmarinerCluster(config *rest.Config, subctlData *datafile.SubctlData)
// Missing information
var qs = []*survey.Question{}

if subctlData.ServiceDiscovery {
cvoEnabled, err := isOpenShiftCVOEnabled(config)
exitOnError("Unable to check for the OpenShift CVO", err)
if cvoEnabled {
// Out of sequence question so we can abort early
disable := false
survey.AskOne(&survey.Confirm{
Message: "Enabling service discovery on OpenShift will disable OpenShift updates, do you want to continue?",
}, &disable)
if !disable {
return
}
}
}

if valid, _ := isValidClusterID(clusterID); !valid {
qs = append(qs, &survey.Question{
Name: "clusterID",
Expand Down Expand Up @@ -327,6 +342,22 @@ func isValidClusterID(clusterID string) (bool, error) {
return true, nil
}

func isOpenShiftCVOEnabled(config *rest.Config) (bool, error) {
_, clientSet, err := getClients(config)
if err != nil {
return false, err
}
deployments := clientSet.AppsV1().Deployments("openshift-cluster-version")
scale, err := deployments.GetScale("cluster-version-operator", metav1.GetOptions{})
if err != nil {
if k8serrs.IsNotFound(err) {
return false, nil
}
return false, err
}
return scale.Spec.Replicas > 0, nil
}

func populateSubmarinerSpec(subctlData *datafile.SubctlData) submariner.SubmarinerSpec {
brokerURL := subctlData.BrokerURL
if idx := strings.Index(brokerURL, "://"); idx >= 0 {
Expand Down

0 comments on commit fc7091b

Please sign in to comment.