@@ -43,7 +43,7 @@ import (
4343const (
4444 DefaultNamespace = "default"
4545 MinGCSFuseKernelParamsVersion = "v3.7.0-gke.0"
46- MinGCSFuseTestConfigVersion = "v3.5 .0-gke.0"
46+ MinGCSFuseTestConfigVersion = "v3.7 .0-gke.0"
4747
4848 GcsfuseVersionVarName = "gcsfuse-version"
4949
@@ -190,7 +190,7 @@ func ParseTestConfig(body []byte) (TestPackages, error) {
190190}
191191
192192func IsParallelDownloadsEnabled (flag string ) bool {
193- return strings .Contains (flag , "file-cache-enable-parallel-downloads" ) && ! strings .Contains (flag , "file-cache-enable-parallel-downloads =false" )
193+ return strings .Contains (flag , flagFileCacheEnableParallelDownloads ) && ! strings .Contains (flag , flagFileCacheEnableParallelDownloads + " =false" )
194194}
195195
196196func IsFileCacheEnabled (testName string ) bool {
@@ -234,7 +234,6 @@ func ParseConfigFlags(flagStr string) ParsedConfig {
234234 // See: https://github.com/GoogleCloudPlatform/gcs-fuse-csi-driver/blob/main/pkg/sidecar_mounter/sidecar_mounter_config.go#L83
235235
236236 // Group 1: Flags that are parsed manually and should not be passed to mountOptions.
237-
238237 // file-cache:max-size-mb is used by the CSI driver to enable the file cache feature and configure the cache volume.
239238 // If not provided or set to 0, the cache directory will not be created.
240239 // See: https://github.com/GoogleCloudPlatform/gcs-fuse-csi-driver/blob/main/pkg/sidecar_mounter/sidecar_mounter_config.go#L237-L241
@@ -262,14 +261,11 @@ func ParseConfigFlags(flagStr string) ParsedConfig {
262261 continue
263262 }
264263
265- // Group 2: The following flags are translated to config file representation and passed to mountOptions.
266-
267- // "log-file" is disallowed. The gcsfuse e2e tests hardcoded the log file in their test config.s
268- // We parse this to configure the test pod to align with the gcsfuse test config.
269- if strings .HasPrefix (f , flagLogFile ) {
270- parsed .LogFilePath = strings .TrimPrefix (f , flagLogFile )
271- f = "logging:file-path:" + parsed .LogFilePath
272- } else if f == flagFileCacheEnableParallelDownloads || strings .HasPrefix (f , flagFileCacheEnableParallelDownloads + "=" ) {
264+ // TODO: Remove this block after boolean flags formatting bug is fixed.
265+ // Group 2: The following flags are booleans but not in boolFlags map in sidecar_mounter_config.go.
266+ // They will be parsed as "x y" which is not a valid format in gcsfuse
267+ // They need to be translated into config file representation x:y
268+ if f == flagFileCacheEnableParallelDownloads || strings .HasPrefix (f , flagFileCacheEnableParallelDownloads + "=" ) {
273269 val := "true"
274270 if strings .Contains (f , "=" ) {
275271 val = strings .SplitN (f , "=" , 2 )[1 ]
@@ -287,9 +283,14 @@ func ParseConfigFlags(flagStr string) ParsedConfig {
287283 val = strings .SplitN (f , "=" , 2 )[1 ]
288284 }
289285 f = "file-system:enable-kernel-reader:" + val
290- } else if strings .HasPrefix (f , flagLogFormat ) {
291- // "log-format" is disallowed so we need to format it to config file format
286+ }
287+
288+ // log-format and log-file are in the disallowedFlags map, so we need to parse them and set them manually.
289+ if strings .HasPrefix (f , flagLogFormat ) {
292290 f = "logging:format:" + strings .TrimPrefix (f , flagLogFormat )
291+ } else if strings .HasPrefix (f , flagLogFile ) {
292+ parsed .LogFilePath = strings .TrimPrefix (f , flagLogFile )
293+ f = "logging:file-path:" + parsed .LogFilePath
293294 }
294295
295296 parsed .MountOptions = append (parsed .MountOptions , f )
@@ -342,6 +343,7 @@ func FetchGCSFuseVersion(ctx context.Context, cl clientset.Interface) (string, e
342343 return "" , fmt .Errorf ("expected data for key `sidecar-image` in the config map `gcsfusecsi-image-config`" )
343344 }
344345
346+ // Deploy a temporary Pod to run the gcsfuse binary and fetch its version.
345347 pod := & corev1.Pod {
346348 ObjectMeta : metav1.ObjectMeta {
347349 GenerateName : "gcsfuse-version-fetcher-" ,
@@ -395,6 +397,8 @@ func FetchGCSFuseVersion(ctx context.Context, cl clientset.Interface) (string, e
395397 klog .Infof ("Pod %s is running, waiting 60s before fetching GCSFuse version from logs" , createdPod .Name )
396398 time .Sleep (60 * time .Second )
397399
400+ // Fetch logs from the specific container running the gcsfuse binary.
401+ // We retry reading logs because it might take time for the logs to propagate to the apiserver.
398402 var logs []byte
399403 req := cl .CoreV1 ().Pods (DefaultNamespace ).GetLogs (createdPod .Name , & corev1.PodLogOptions {Container : webhook .GcsFuseSidecarName })
400404 err = wait .PollUntilContextTimeout (ctx , 30 * time .Second , time .Minute * 10 , true , func (ctx context.Context ) (bool , error ) {
@@ -411,7 +415,7 @@ func FetchGCSFuseVersion(ctx context.Context, cl clientset.Interface) (string, e
411415
412416 output := string (logs )
413417
414- // Parse: "gcsfuse version 3.7.1-gke.0 ..."
418+ // Parse the version string from the standard format : "gcsfuse version 3.7.1-gke.0 ..."
415419 l := strings .Split (strings .TrimSpace (output ), " " )
416420 if len (l ) <= 2 {
417421 return "" , fmt .Errorf ("unexpected version output format: %s" , output )
0 commit comments