Skip to content

Commit 4b09dac

Browse files
committed
Fix leading comma issue for mount option when enable only-dir
1 parent a2cfe3d commit 4b09dac

6 files changed

Lines changed: 42 additions & 34 deletions

File tree

test/e2e/specs/specs.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,21 +1106,16 @@ func deployGCSFuseVersionFetcherPod(ctx context.Context, clientset clientset.Int
11061106
configMaps, err := clientset.CoreV1().ConfigMaps("").List(ctx, metav1.ListOptions{
11071107
FieldSelector: "metadata.name=gcsfusecsi-image-config",
11081108
})
1109-
if err != nil {
1110-
klog.Errorf("Expected no error when list configmaps, but found: %v", err)
1111-
return ""
1112-
}
1109+
framework.ExpectNoError(err)
11131110
if len(configMaps.Items) != 1 {
1114-
klog.Errorf("Expected 1 gcsfusecsi-image-config ConfigMap, found %d", len(configMaps.Items))
1115-
return ""
1111+
framework.Failf("expected one config map `gcsfusecsi-image-config` but found %d", len(configMaps.Items))
11161112
}
11171113

11181114
sidecarImageConfig := configMaps.Items[0]
11191115

11201116
image := sidecarImageConfig.Data["sidecar-image"]
11211117
if image == "" {
1122-
klog.Errorf("sidecar-image data is empty in configmap")
1123-
return ""
1118+
framework.Failf("expected data for key `sidecar-image` in the config map `gcsfusecsi-image-config`")
11241119
}
11251120

11261121
pod := &corev1.Pod{

test/e2e/testsuites/failed_mount.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ func (t *gcsFuseCSIFailedMountTestSuite) DefineTests(driver storageframework.Tes
196196
ginkgo.By("Checking that the pod has failed mount error")
197197

198198
if GCSFuseVersionStr == "" {
199-
GCSFuseVersionStr = specs.GetGCSFuseVersion(ctx, f)
199+
GCSFuseVersionStr = specs.GetGCSFuseVersion(ctx)
200200
}
201201
v, err := version.ParseSemantic(GCSFuseVersionStr)
202202
if configPrefix == specs.SkipCSIBucketAccessCheckAndInvalidVolumePrefix && (err != nil || v.AtLeast(version.MustParseSemantic("v2.9.0-gke.0"))) {

test/e2e/testsuites/gcsfuse_integration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ func (t *gcsFuseCSIGCSFuseIntegrationTestSuite) DefineTests(driver storageframew
246246
// Check if the GCSFuseVersion is already set, if not, we should set it.
247247
// This is for the case that we run this test suite individually.
248248
if GCSFuseVersionStr == "" {
249-
GCSFuseVersionStr = specs.GetGCSFuseVersion(ctx, f)
249+
GCSFuseVersionStr = specs.GetGCSFuseVersion(ctx)
250250
}
251251
gcsfuseVersion := version.MustParseSemantic(GCSFuseVersionStr)
252252

test/e2e/testsuites/gcsfuse_integration_file_cache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func (t *gcsFuseCSIGCSFuseIntegrationFileCacheTestSuite) DefineTests(driver stor
113113
gcsfuseIntegrationFileCacheTest := func(testName string, readOnly bool, fileCacheCapacity, fileCacheForRangeRead, metadataCacheTTLSeconds string, mountOptions ...string) {
114114
ginkgo.By("Checking GCSFuse version and skip test if needed")
115115
if GCSFuseVersionStr == "" {
116-
GCSFuseVersionStr = specs.GetGCSFuseVersion(ctx, f)
116+
GCSFuseVersionStr = specs.GetGCSFuseVersion(ctx)
117117
}
118118
ginkgo.By(fmt.Sprintf("Running integration test %v with GCSFuse version %v", testName, GCSFuseVersionStr))
119119
gcsfuseTestBranch := skipTestOrProceedWithBranch(GCSFuseVersionStr, testName)

test/e2e/testsuites/gcsfuse_integration_file_cache_parallel_downloads.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,7 @@ func (t *gcsFuseCSIGCSFuseIntegrationFileCacheParallelDownloadsTestSuite) Define
219219

220220
// Filter out duplicate logging:severity:info from testdriver set up
221221
mo := l.volumeResource.VolSource.CSI.VolumeAttributes["mountOptions"]
222-
mo = strings.ReplaceAll(mo, "logging:severity:info", "")
223-
mo = strings.TrimPrefix(mo, ",") // Remove leading comma because of ,onlyDir
222+
mo = strings.ReplaceAll(mo, "logging:severity:info", fmt.Sprintf("logging:severity:%v", config.LogSeverity))
224223
l.volumeResource.VolSource.CSI.VolumeAttributes["mountOptions"] = mo
225224

226225
tPod.SetupVolume(l.volumeResource, volumeName, mountPath, config.ReadOnly, config.MountOptions...)

test/e2e/utils/utils.go

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,16 @@ const (
3939
MinGCSFuseKernelParamsVersion = "v3.7.0-gke.0"
4040
MinGCSFuseTestConfigVersion = "v3.5.0-gke.0"
4141

42-
testConfigUrlFormat = "https://raw.githubusercontent.com/GoogleCloudPlatform/gcsfuse/%s/tools/integration_tests/test_config.yaml"
43-
flagFileCacheCapacity = "file-cache-max-size-mb="
44-
flagReadOnly = "o=ro"
45-
flagLogFile = "log-file="
46-
flagCacheDir = "cache-dir="
42+
testConfigUrlFormat = "https://raw.githubusercontent.com/GoogleCloudPlatform/gcsfuse/%s/tools/integration_tests/test_config.yaml"
43+
flagFileCacheCapacity = "file-cache-max-size-mb="
44+
flagReadOnly = "o=ro"
45+
flagLogFile = "log-file="
46+
flagCacheDir = "cache-dir="
47+
flagLogSeverity = "log-severity="
48+
flagLogFormat = "log-format="
49+
flagFileCacheEnableParallelDownloads = "file-cache-enable-parallel-downloads"
50+
flagFileCacheEnableODirect = "file-cache-enable-o-direct"
51+
flagEnableKernelReader = "enable-kernel-reader"
4752
)
4853

4954
var (
@@ -192,6 +197,7 @@ type ParsedConfig struct {
192197
FileCacheCapacity string
193198
ReadOnly bool
194199
LogFilePath string
200+
LogSeverity string
195201
CacheDir string
196202
MountOptions []string
197203
}
@@ -203,6 +209,7 @@ func ParseConfigFlags(flagStr string) ParsedConfig {
203209
FileCacheCapacity: "50Mi",
204210
ReadOnly: false,
205211
LogFilePath: "",
212+
LogSeverity: "info",
206213
CacheDir: "",
207214
MountOptions: []string{},
208215
}
@@ -218,56 +225,63 @@ func ParseConfigFlags(flagStr string) ParsedConfig {
218225
// They cannot be passed via mountOptions and must be parsed to configure the test environment manually.
219226
// See: https://github.com/GoogleCloudPlatform/gcs-fuse-csi-driver/blob/main/pkg/sidecar_mounter/sidecar_mounter_config.go#L83
220227

228+
// Group 1: Flags that are parsed manually and should not be passed to mountOptions.
229+
221230
// file-cache:max-size-mb is used by the CSI driver to enable the file cache feature and configure the cache volume.
222231
// If not provided or set to 0, the cache directory will not be created.
223232
// See: https://github.com/GoogleCloudPlatform/gcs-fuse-csi-driver/blob/main/pkg/sidecar_mounter/sidecar_mounter_config.go#L237-L241
224233
if strings.HasPrefix(f, flagFileCacheCapacity) {
225234
parsed.FileCacheCapacity = strings.TrimPrefix(f, flagFileCacheCapacity) + "Mi"
235+
continue
226236
}
227237

228238
// "o" is disallowed and will be used in SetupVolume to set the readOnly flag for test pod.
229239
if f == flagReadOnly {
230240
parsed.ReadOnly = true
231-
}
232-
233-
// "log-file" is disallowed. The gcsfuse e2e tests hardcoded the log file in their test config.s
234-
// We parse this to configure the test pod to align with the gcsfuse test config.
235-
if strings.HasPrefix(f, flagLogFile) {
236-
parsed.LogFilePath = strings.TrimPrefix(f, flagLogFile)
237-
f = "logging:file-path:" + parsed.LogFilePath
241+
continue
238242
}
239243

240244
// "cache-dir" is disallowed to prevent storage exhaustion. The gcsfuse e2e tests hardcoded the cache dir in their test config.
241245
// We parse this to manually set up the cache volume in the test pod to align with the gcsfuse test config.
242246
if strings.HasPrefix(f, flagCacheDir) {
243247
parsed.CacheDir = strings.TrimPrefix(f, flagCacheDir)
248+
continue
244249
}
245250

246-
// Translate legacy CLI flags to config file representation
247-
if f == "file-cache-enable-parallel-downloads" || strings.HasPrefix(f, "file-cache-enable-parallel-downloads=") {
251+
// "log-severity" is disallowed so we parse it into the test pod configuration.
252+
if strings.HasPrefix(f, flagLogSeverity) {
253+
parsed.LogSeverity = strings.TrimPrefix(f, flagLogSeverity)
254+
continue
255+
}
256+
257+
// Group 2: The following flags are translated to config file representation and passed to mountOptions.
258+
259+
// "log-file" is disallowed. The gcsfuse e2e tests hardcoded the log file in their test config.s
260+
// We parse this to configure the test pod to align with the gcsfuse test config.
261+
if strings.HasPrefix(f, flagLogFile) {
262+
parsed.LogFilePath = strings.TrimPrefix(f, flagLogFile)
263+
f = "logging:file-path:" + parsed.LogFilePath
264+
} else if f == flagFileCacheEnableParallelDownloads || strings.HasPrefix(f, flagFileCacheEnableParallelDownloads+"=") {
248265
val := "true"
249266
if strings.Contains(f, "=") {
250267
val = strings.SplitN(f, "=", 2)[1]
251268
}
252269
f = "file-cache:enable-parallel-downloads:" + val
253-
} else if f == "file-cache-enable-o-direct" || strings.HasPrefix(f, "file-cache-enable-o-direct=") {
270+
} else if f == flagFileCacheEnableODirect || strings.HasPrefix(f, flagFileCacheEnableODirect+"=") {
254271
val := "true"
255272
if strings.Contains(f, "=") {
256273
val = strings.SplitN(f, "=", 2)[1]
257274
}
258275
f = "file-cache:enable-o-direct:" + val
259-
} else if f == "enable-kernel-reader" || strings.HasPrefix(f, "enable-kernel-reader=") {
276+
} else if f == flagEnableKernelReader || strings.HasPrefix(f, flagEnableKernelReader+"=") {
260277
val := "true"
261278
if strings.Contains(f, "=") {
262279
val = strings.SplitN(f, "=", 2)[1]
263280
}
264281
f = "file-system:enable-kernel-reader:" + val
265-
} else if strings.HasPrefix(f, "log-severity=") {
266-
// "log-severity" is disallowed so we need to format it to config file format
267-
f = "logging:severity:" + strings.TrimPrefix(f, "log-severity=")
268-
} else if strings.HasPrefix(f, "log-format=") {
282+
} else if strings.HasPrefix(f, flagLogFormat) {
269283
// "log-format" is disallowed so we need to format it to config file format
270-
f = "logging:format:" + strings.TrimPrefix(f, "log-format=")
284+
f = "logging:format:" + strings.TrimPrefix(f, flagLogFormat)
271285
}
272286

273287
parsed.MountOptions = append(parsed.MountOptions, f)

0 commit comments

Comments
 (0)