Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support configuration of default compatibility matrix if matrix is not configured before configuring drivers #118

Merged
merged 7 commits into from
Dec 23, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/vmware-tanzu/vsphere-kubernetes-drivers-operator
go 1.16

require (
github.com/fatih/color v1.7.0
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/go-logr/logr v0.3.0
github.com/hashicorp/go-version v1.3.0
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7
github.com/evanphx/json-patch v4.5.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
github.com/evanphx/json-patch v4.9.0+incompatible h1:kLcOMZeuLAJvL2BPWLMIj5oaZQobrkAqrL+WFZwQses=
github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/form3tech-oss/jwt-go v3.2.2+incompatible h1:TcekIExNqud5crz4xD2pavyTgWiPvpYe4Xau31I0PRk=
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
Expand Down
2 changes: 1 addition & 1 deletion vdoctl/cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Currently the command supports deployment on vanilla k8s cluster`,
cobra.CheckErr(applyErr)
}

fmt.Println("Tip: now that you have deployed VDO, you might want to try 'vdoctl configure drivers' to configure vsphere drivers")
fmt.Println("Tip: now that you have deployed VDO, you might want to try 'vdoctl configure compatibility-matrix' to configure compatibility matrix")
},
}

Expand Down
33 changes: 30 additions & 3 deletions vdoctl/cmd/drivers.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"context"
"errors"
"fmt"
"github.com/fatih/color"
"k8s.io/apimachinery/pkg/types"
"regexp"
"strings"
Expand Down Expand Up @@ -59,6 +60,7 @@ const (
vdoConfigName = "vdo-config"
secretType = "kubernetes.io/basic-auth"
ClusterDistribution = "OpenShift"
defaultMatrixPath = "https://github.com/vmware-tanzu/vsphere-kubernetes-drivers-operator/releases/download/{VERSION}/compatibility.yaml"
)

// driversCmd represents the drivers command
Expand All @@ -73,13 +75,28 @@ var driversCmd = &cobra.Command{
// Check the vdoDeployment Namespace and confirm if VDO operator is running in the env
getVdoNamespace(ctx)

err, _ := IsVDODeployed(ctx)
var isConfigRequired bool
configKey := types.NamespacedName{
Namespace: VdoCurrentNamespace,
Name: CompatMatrixConfigMap,
}
cm := v1.ConfigMap{}

_ = K8sClient.Get(ctx, configKey, &cm)
if len(cm.Data) == 0 {
isConfigRequired = true
color.Yellow("VDO will use the default compatibility matrix to determine the versions. If you wish to configure compatibility matrix please run 'vdoctl configure compatibility matrix'")
}

err, deployment := IsVDODeployed(ctx)
if err != nil {
if apierrors.IsNotFound(err) {
fmt.Println(VDO_NOT_DEPLOYED)
return
} else {
cobra.CheckErr(err)
if !isConfigRequired {
ridaz-zz marked this conversation as resolved.
Show resolved Hide resolved
cobra.CheckErr(err)
}
}
}

Expand All @@ -106,7 +123,7 @@ var driversCmd = &cobra.Command{
labels := credentials{
username: "Username",
password: "Password",
vcIp: "VC IP",
vcIp: "VC IP/ FQDN",
topology: v1alpha1.TopologyInfo{
Zone: "Zones",
Region: "Regions",
Expand All @@ -116,6 +133,16 @@ var driversCmd = &cobra.Command{

isCPIRequired := utils.PromptGetInput("Do you want to configure CloudProvider? (Y/N)", errors.New("invalid input"), utils.IsString)

// Configure compatibility matrix , if not configured
if isConfigRequired {
vdoVersion := getVdoVersion(deployment)
currentMatrixPath := strings.Replace(defaultMatrixPath, "{VERSION}", vdoVersion, 1)
err = CreateConfigMap(currentMatrixPath, K8sClient, ctx, utils.IsURL)
if err != nil {
cobra.CheckErr(err)
}
}

if strings.EqualFold(isCPIRequired, "Y") {
fmt.Printf("Please provide the vcenter IP for configuring CloudProvider \n")

Expand Down
2 changes: 1 addition & 1 deletion vdoctl/cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func IsVDODeployed(ctx context.Context) (error, *v12.Deployment) {
ns := types.NamespacedName{Namespace: VdoCurrentNamespace, Name: VdoDeploymentName}
err := K8sClient.Get(ctx, ns, deployment)
if deployment.Status.Replicas != deployment.Status.AvailableReplicas {
return fmt.Errorf("not enough replicas of VDO"), nil
return fmt.Errorf("not enough replicas of VDO"), deployment
}
return err, deployment
}
Expand Down