Skip to content

Commit 006727c

Browse files
committed
Enable XFS selectively for GKE clusters with proper COS support
1 parent 12ea362 commit 006727c

File tree

4 files changed

+123
-93
lines changed

4 files changed

+123
-93
lines changed

test/k8s-integration/driver-config.go

+21-12
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ const (
2727

2828
// generateDriverConfigFile loads a testdriver config template and creates a file
2929
// with the test-specific configuration
30-
func generateDriverConfigFile(platform, pkgDir, storageClassFile, snapshotClassFile, deploymentStrat string) (string, error) {
30+
func generateDriverConfigFile(testParams *testParameters, storageClassFile string) (string, error) {
3131
// Load template
32-
t, err := template.ParseFiles(filepath.Join(pkgDir, testConfigDir, configTemplateFile))
32+
t, err := template.ParseFiles(filepath.Join(testParams.pkgDir, testConfigDir, configTemplateFile))
3333
if err != nil {
3434
return "", err
3535
}
3636

3737
// Create destination
38-
configFilePath := filepath.Join(pkgDir, testConfigDir, configFile)
38+
configFilePath := filepath.Join(testParams.pkgDir, testConfigDir, configFile)
3939
f, err := os.Create(configFilePath)
4040
if err != nil {
4141
return "", err
@@ -57,7 +57,7 @@ func generateDriverConfigFile(platform, pkgDir, storageClassFile, snapshotClassF
5757
"topology",
5858
}
5959
var fsTypes []string
60-
if platform == "windows" {
60+
if testParams.platform == "windows" {
6161
fsTypes = []string{"ntfs"}
6262
caps = []string{
6363
"persistence",
@@ -70,7 +70,6 @@ func generateDriverConfigFile(platform, pkgDir, storageClassFile, snapshotClassF
7070
"ext2",
7171
"ext3",
7272
"ext4",
73-
"xfs",
7473
}
7574
}
7675

@@ -82,22 +81,32 @@ func generateDriverConfigFile(platform, pkgDir, storageClassFile, snapshotClassF
8281
dataSource
8382
*/
8483

85-
// TODO: Support adding/removing capabilities based on Kubernetes version.
86-
switch deploymentStrat {
84+
switch testParams.deploymentStrategy {
8785
case "gke":
88-
fallthrough
89-
case "gce":
9086
caps = append(caps, "controllerExpansion", "nodeExpansion")
87+
if *imageType == "cos" {
88+
gkeVer := mustParseVersion(testParams.clusterVersion)
89+
if gkeVer.lessThan(mustParseVersion("1.18.0")) {
90+
// XFS is not supported on COS before 1.18.0
91+
} else {
92+
fsTypes = append(fsTypes, "xfs")
93+
}
94+
} else {
95+
// XFS is supported on all non-COS images.
96+
fsTypes = append(fsTypes, "xfs")
97+
}
98+
case "gce":
99+
fsTypes = append(fsTypes, "xfs")
91100
default:
92101
return "", fmt.Errorf("got unknown deployment strat %s, expected gce or gke", deploymentStrat)
93102
}
94103

95104
var absSnapshotClassFilePath string
96105
// If snapshot class is passed in as argument, include snapshot specific driver capabiltiites.
97-
if snapshotClassFile != "" {
106+
if testParams.snapshotClassFile != "" {
98107
caps = append(caps, "snapshotDataSource")
99108
// Update the absolute file path pointing to the snapshot class file, if it is provided as an argument.
100-
absSnapshotClassFilePath = filepath.Join(pkgDir, testConfigDir, snapshotClassFile)
109+
absSnapshotClassFilePath = filepath.Join(testParams.pkgDir, testConfigDir, testParams.snapshotClassFile)
101110
}
102111

103112
minimumVolumeSize := "5Gi"
@@ -107,7 +116,7 @@ func generateDriverConfigFile(platform, pkgDir, storageClassFile, snapshotClassF
107116
numAllowedTopologies = 2
108117
}
109118
params := driverConfig{
110-
StorageClassFile: filepath.Join(pkgDir, testConfigDir, storageClassFile),
119+
StorageClassFile: filepath.Join(testParams.pkgDir, testConfigDir, storageClassFile),
111120
StorageClass: storageClassFile[:strings.LastIndex(storageClassFile, ".")],
112121
SnapshotClassFile: absSnapshotClassFilePath,
113122
SupportedFsType: fsTypes,

test/k8s-integration/driver.go

+15-15
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ func getOverlayDir(pkgDir, deployOverlayName string) string {
1515
return filepath.Join(pkgDir, "deploy", "kubernetes", "overlays", deployOverlayName)
1616
}
1717

18-
func installDriver(platform, goPath, pkgDir, stagingImage, stagingVersion, deployOverlayName string, doDriverBuild bool) error {
18+
func installDriver(testParams *testParameters, stagingImage, deployOverlayName string, doDriverBuild bool) error {
1919
if doDriverBuild {
2020
// Install kustomize
2121
klog.Infof("Installing kustomize")
22-
out, err := exec.Command(filepath.Join(pkgDir, "deploy", "kubernetes", "install-kustomize.sh")).CombinedOutput()
22+
out, err := exec.Command(filepath.Join(testParams.pkgDir, "deploy", "kubernetes", "install-kustomize.sh")).CombinedOutput()
2323
if err != nil {
2424
return fmt.Errorf("failed to install kustomize: %s, err: %v", out, err)
2525
}
2626

2727
// Edit ci kustomization to use given image tag
28-
overlayDir := getOverlayDir(pkgDir, deployOverlayName)
28+
overlayDir := getOverlayDir(testParams.pkgDir, deployOverlayName)
2929
err = os.Chdir(overlayDir)
3030
if err != nil {
3131
return fmt.Errorf("failed to change to overlay directory: %s, err: %v", out, err)
@@ -34,21 +34,21 @@ func installDriver(platform, goPath, pkgDir, stagingImage, stagingVersion, deplo
3434
// TODO (#138): in a local environment this is going to modify the actual kustomize files.
3535
// maybe a copy should be made instead
3636
out, err = exec.Command(
37-
filepath.Join(pkgDir, "bin", "kustomize"),
37+
filepath.Join(testParams.pkgDir, "bin", "kustomize"),
3838
"edit",
3939
"set",
4040
"image",
41-
fmt.Sprintf("%s=%s:%s", pdImagePlaceholder, stagingImage, stagingVersion)).CombinedOutput()
41+
fmt.Sprintf("%s=%s:%s", pdImagePlaceholder, stagingImage, testParams.stagingVersion)).CombinedOutput()
4242
if err != nil {
4343
return fmt.Errorf("failed to edit kustomize: %s, err: %v", out, err)
4444
}
45-
if platform == "windows" {
45+
if testParams.platform == "windows" {
4646
out, err = exec.Command(
47-
filepath.Join(pkgDir, "bin", "kustomize"),
47+
filepath.Join(testParams.pkgDir, "bin", "kustomize"),
4848
"edit",
4949
"set",
5050
"image",
51-
fmt.Sprintf("%s-win=%s-win:%s", pdImagePlaceholder, stagingImage, stagingVersion)).CombinedOutput()
51+
fmt.Sprintf("%s-win=%s-win:%s", pdImagePlaceholder, stagingImage, testParams.stagingVersion)).CombinedOutput()
5252
if err != nil {
5353
return fmt.Errorf("failed to edit kustomize: %s, err: %v", out, err)
5454
}
@@ -72,9 +72,9 @@ func installDriver(platform, goPath, pkgDir, stagingImage, stagingVersion, deplo
7272
}
7373

7474
// deploy driver
75-
deployCmd := exec.Command(filepath.Join(pkgDir, "deploy", "kubernetes", "deploy-driver.sh"), "--skip-sa-check")
75+
deployCmd := exec.Command(filepath.Join(testParams.pkgDir, "deploy", "kubernetes", "deploy-driver.sh"), "--skip-sa-check")
7676
deployEnv = append(deployEnv,
77-
fmt.Sprintf("GOPATH=%s", goPath),
77+
fmt.Sprintf("GOPATH=%s", testParams.goPath),
7878
fmt.Sprintf("GCE_PD_DRIVER_VERSION=%s", deployOverlayName))
7979
deployEnv = append(os.Environ(), deployEnv...)
8080
deployCmd.Env = deployEnv
@@ -83,14 +83,14 @@ func installDriver(platform, goPath, pkgDir, stagingImage, stagingVersion, deplo
8383
return fmt.Errorf("failed to deploy driver: %w", err)
8484
}
8585

86-
waitScript := filepath.Join(pkgDir, "deploy", "kubernetes", "wait-for-driver.sh")
86+
waitScript := filepath.Join(testParams.pkgDir, "deploy", "kubernetes", "wait-for-driver.sh")
8787
waitCmd := exec.Command(waitScript)
8888
waitCmd.Env = deployEnv
8989
err = runCommand("Waiting for driver to start", waitCmd)
9090
if err != nil {
9191
return fmt.Errorf("driver failed to come up: %w", err)
9292
}
93-
if platform == "windows" {
93+
if testParams.platform == "windows" {
9494
waitCmd = exec.Command(waitScript, "--windows")
9595
waitCmd.Env = deployEnv
9696
err = runCommand("Waiting for windows deployment to start", waitCmd)
@@ -107,10 +107,10 @@ func installDriver(platform, goPath, pkgDir, stagingImage, stagingVersion, deplo
107107
return nil
108108
}
109109

110-
func deleteDriver(goPath, pkgDir, deployOverlayName string) error {
111-
deleteCmd := exec.Command(filepath.Join(pkgDir, "deploy", "kubernetes", "delete-driver.sh"))
110+
func deleteDriver(testParams *testParameters, deployOverlayName string) error {
111+
deleteCmd := exec.Command(filepath.Join(testParams.pkgDir, "deploy", "kubernetes", "delete-driver.sh"))
112112
deleteCmd.Env = append(os.Environ(),
113-
fmt.Sprintf("GOPATH=%s", goPath),
113+
fmt.Sprintf("GOPATH=%s", testParams.goPath),
114114
fmt.Sprintf("GCE_PD_DRIVER_VERSION=%s", deployOverlayName),
115115
)
116116
err := runCommand("Deleting driver", deleteCmd)

0 commit comments

Comments
 (0)