@@ -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
4954var (
@@ -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