Skip to content

Commit 5f40590

Browse files
committed
Enable XFS selectively for GKE clusters with proper COS support
1 parent ff0b719 commit 5f40590

File tree

3 files changed

+116
-84
lines changed

3 files changed

+116
-84
lines changed

test/k8s-integration/driver-config.go

+22-13
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 testParams.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:
92-
return "", fmt.Errorf("got unknown deployment strat %s, expected gce or gke", deploymentStrat)
101+
return "", fmt.Errorf("got unknown deployment strat %s, expected gce or gke", testParams.deploymentStrategy)
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

+13-13
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,11 +34,11 @@ 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
}
@@ -61,9 +61,9 @@ func installDriver(platform, goPath, pkgDir, stagingImage, stagingVersion, deplo
6161
}
6262

6363
// deploy driver
64-
deployCmd := exec.Command(filepath.Join(pkgDir, "deploy", "kubernetes", "deploy-driver.sh"), "--skip-sa-check")
64+
deployCmd := exec.Command(filepath.Join(testParams.pkgDir, "deploy", "kubernetes", "deploy-driver.sh"), "--skip-sa-check")
6565
deployEnv = append(deployEnv,
66-
fmt.Sprintf("GOPATH=%s", goPath),
66+
fmt.Sprintf("GOPATH=%s", testParams.goPath),
6767
fmt.Sprintf("GCE_PD_DRIVER_VERSION=%s", deployOverlayName))
6868
deployEnv = append(os.Environ(), deployEnv...)
6969
deployCmd.Env = deployEnv
@@ -72,14 +72,14 @@ func installDriver(platform, goPath, pkgDir, stagingImage, stagingVersion, deplo
7272
return fmt.Errorf("failed to deploy driver: %w", err)
7373
}
7474

75-
waitScript := filepath.Join(pkgDir, "deploy", "kubernetes", "wait-for-driver.sh")
75+
waitScript := filepath.Join(testParams.pkgDir, "deploy", "kubernetes", "wait-for-driver.sh")
7676
waitCmd := exec.Command(waitScript)
7777
waitCmd.Env = deployEnv
7878
err = runCommand("Waiting for driver to start", waitCmd)
7979
if err != nil {
8080
return fmt.Errorf("driver failed to come up: %w", err)
8181
}
82-
if platform == "windows" {
82+
if testParams.platform == "windows" {
8383
waitCmd = exec.Command(waitScript, "--windows")
8484
waitCmd.Env = deployEnv
8585
err = runCommand("Waiting for windows deployment to start", waitCmd)
@@ -91,15 +91,15 @@ func installDriver(platform, goPath, pkgDir, stagingImage, stagingVersion, deplo
9191
klog.Infof("describe pods \n %s", string(out))
9292

9393
if err != nil {
94-
return fmt.Errorf("failed to describe pods: %v", err)
94+
return fmt.Errorf("failed to describe pods: %w", err)
9595
}
9696
return nil
9797
}
9898

99-
func deleteDriver(goPath, pkgDir, deployOverlayName string) error {
100-
deleteCmd := exec.Command(filepath.Join(pkgDir, "deploy", "kubernetes", "delete-driver.sh"))
99+
func deleteDriver(testParams *testParameters, deployOverlayName string) error {
100+
deleteCmd := exec.Command(filepath.Join(testParams.pkgDir, "deploy", "kubernetes", "delete-driver.sh"))
101101
deleteCmd.Env = append(os.Environ(),
102-
fmt.Sprintf("GOPATH=%s", goPath),
102+
fmt.Sprintf("GOPATH=%s", testParams.goPath),
103103
fmt.Sprintf("GCE_PD_DRIVER_VERSION=%s", deployOverlayName),
104104
)
105105
err := runCommand("Deleting driver", deleteCmd)

0 commit comments

Comments
 (0)