Skip to content

Commit b9c4467

Browse files
authored
Merge pull request #632 from mattcary/gke-xfs
Enable XFS selectively for GKE clusters with proper COS support
2 parents ac63d0f + 6002e11 commit b9c4467

File tree

3 files changed

+119
-86
lines changed

3 files changed

+119
-86
lines changed

test/k8s-integration/driver-config.go

+23-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
@@ -55,9 +55,11 @@ func generateDriverConfigFile(platform, pkgDir, storageClassFile, snapshotClassF
5555
"exec",
5656
"multipods",
5757
"topology",
58+
"controllerExpansion",
59+
"nodeExpansion",
5860
}
5961
var fsTypes []string
60-
if platform == "windows" {
62+
if testParams.platform == "windows" {
6163
fsTypes = []string{"ntfs"}
6264
caps = []string{
6365
"persistence",
@@ -70,7 +72,6 @@ func generateDriverConfigFile(platform, pkgDir, storageClassFile, snapshotClassF
7072
"ext2",
7173
"ext3",
7274
"ext4",
73-
"xfs",
7475
}
7576
}
7677

@@ -82,22 +83,31 @@ func generateDriverConfigFile(platform, pkgDir, storageClassFile, snapshotClassF
8283
dataSource
8384
*/
8485

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

95105
var absSnapshotClassFilePath string
96106
// If snapshot class is passed in as argument, include snapshot specific driver capabiltiites.
97-
if snapshotClassFile != "" {
107+
if testParams.snapshotClassFile != "" {
98108
caps = append(caps, "snapshotDataSource")
99109
// 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)
110+
absSnapshotClassFilePath = filepath.Join(testParams.pkgDir, testConfigDir, testParams.snapshotClassFile)
101111
}
102112

103113
minimumVolumeSize := "5Gi"
@@ -107,7 +117,7 @@ func generateDriverConfigFile(platform, pkgDir, storageClassFile, snapshotClassF
107117
numAllowedTopologies = 2
108118
}
109119
params := driverConfig{
110-
StorageClassFile: filepath.Join(pkgDir, testConfigDir, storageClassFile),
120+
StorageClassFile: filepath.Join(testParams.pkgDir, testConfigDir, storageClassFile),
111121
StorageClass: storageClassFile[:strings.LastIndex(storageClassFile, ".")],
112122
SnapshotClassFile: absSnapshotClassFilePath,
113123
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)