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

OADP-823: Address oadp-1.0.z with ocp 4.11 csi compatibility issue #848

Merged
Merged
Changes from all 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
25 changes: 25 additions & 0 deletions controllers/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package controllers
import (
"errors"
"fmt"
"k8s.io/apimachinery/pkg/version"
"k8s.io/client-go/kubernetes"
"sigs.k8s.io/controller-runtime/pkg/client/config"

"github.com/go-logr/logr"
oadpv1alpha1 "github.com/openshift/oadp-operator/api/v1alpha1"
Expand Down Expand Up @@ -85,6 +88,19 @@ func (r *DPAReconciler) ValidateVeleroPlugins(log logr.Logger) (bool, error) {
var defaultPlugin oadpv1alpha1.DefaultPlugin
for _, plugin := range dpa.Spec.Configuration.Velero.DefaultPlugins {

// check csi compatibility with cluster version
// velero version <1.9 expects API group snapshot.storage.k8s.io/v1beta1, while OCP 4.11 (k8s 1.24) has only snapshot.storage.k8s.io/v1
if plugin == oadpv1alpha1.DefaultPluginCSI {
clusterVersion, err := getClusterVersion()
if err != nil {
return false, err
}

if clusterVersion.Major == "1" && clusterVersion.Minor >= "24" {
return false, errors.New("csi plugin on OADP 1.0 (velero <1.9) requires API snapshot.storage.k8s.io/v1beta1. On OCP 4.11+ (k8s 1.24+), to use CSI, upgrade to OADP 1.1+")
}
}

pluginSpecificMap, ok := credentials.PluginSpecificFields[plugin]
pluginNeedsCheck, foundInBSLorVSL := providerNeedsDefaultCreds[string(plugin)]

Expand All @@ -103,3 +119,12 @@ func (r *DPAReconciler) ValidateVeleroPlugins(log logr.Logger) (bool, error) {
}
return true, nil
}

func getClusterVersion() (*version.Info, error) {
kubeConf := config.GetConfigOrDie()
clientset, err := kubernetes.NewForConfig(kubeConf)
if err != nil {
return nil, err
}
return clientset.Discovery().ServerVersion()
}