Skip to content

Commit 2163d66

Browse files
authored
Merge pull request #1594 from AlbeeSo/cleanup/ossfs2-metrics-bydefault
ossfs2: enable metrics by default
2 parents ce4ba4a + 194c84c commit 2163d66

File tree

2 files changed

+34
-23
lines changed

2 files changed

+34
-23
lines changed

pkg/mounter/fuse_pod_manager/oss/ossfs2/manager.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,7 @@ func (f *fuseOssfs) AddDefaultMountOptions(options []string) []string {
308308

309309
// set use_metrics to enabled monitoring by default
310310
if _, ok := tm["use_metrics"]; !ok {
311-
// TODO: After stabilization, change the default value to true
312-
// Currently, metrics collection is controlled by the MetricsMode configuration
313-
// Once the feature is stable, we should enable metrics by default
314-
if f.config.MetricsMode == fpm.MetricsModeEnabled {
311+
if f.config.MetricsMode != fpm.MetricsModeDisabled {
315312
options = append(options, "use_metrics=true")
316313
}
317314
}

pkg/mounter/fuse_pod_manager/oss/ossfs2/manager_test.go

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -306,52 +306,66 @@ func TestAddDefaultMountOptions_ossfs2(t *testing.T) {
306306
tests := []struct {
307307
name string
308308
options []string
309-
cfglevel string
309+
config *fpm.FuseContainerConfig
310310
defaultOpts string
311311
want []string
312312
}{
313313
{
314314
name: "empty option, empty config",
315315
options: []string{"others"},
316-
want: []string{"others", "log_level=info", "log_dir=/dev/stdout"},
316+
want: []string{"others", "log_level=info", "log_dir=/dev/stdout", "use_metrics=true"},
317317
},
318318
{
319319
name: "set option",
320-
options: []string{"others", "log_level=debug", "log_dir=/tmp/ossfs2", "others", "use_metrics=true"},
321-
want: []string{"others", "log_level=debug", "log_dir=/tmp/ossfs2", "others", "use_metrics=true"},
320+
options: []string{"others", "log_level=debug", "log_dir=/tmp/ossfs2", "others", "use_metrics=false"},
321+
want: []string{"others", "log_level=debug", "log_dir=/tmp/ossfs2", "others", "use_metrics=false"},
322322
},
323323
{
324-
name: "set option, set config",
325-
cfglevel: "info",
326-
options: []string{"others", "log_level=debug", "others"},
327-
want: []string{"others", "log_level=debug", "others", "log_dir=/dev/stdout"},
324+
name: "set option, set config",
325+
config: &fpm.FuseContainerConfig{
326+
Dbglevel: fpm.DebugLevelInfo,
327+
},
328+
options: []string{"others", "log_level=debug", "others"},
329+
want: []string{"others", "log_level=debug", "others", "log_dir=/dev/stdout", "use_metrics=true"},
328330
},
329331
{
330-
name: "empty option, set config",
331-
cfglevel: "debug",
332-
options: []string{"others"},
333-
want: []string{"others", "log_level=debug", "log_dir=/dev/stdout"},
332+
name: "empty option, set config",
333+
config: &fpm.FuseContainerConfig{
334+
Dbglevel: fpm.DebugLevelDebug,
335+
},
336+
options: []string{"others"},
337+
want: []string{"others", "log_level=debug", "log_dir=/dev/stdout", "use_metrics=true"},
334338
},
335339
{
336-
name: "empty option, invalid config",
337-
cfglevel: "invalid",
338-
options: []string{"others"},
339-
want: []string{"others", "log_level=info", "log_dir=/dev/stdout"},
340+
name: "empty option, invalid config",
341+
config: &fpm.FuseContainerConfig{
342+
Dbglevel: "invalid",
343+
},
344+
options: []string{"others"},
345+
want: []string{"others", "log_level=info", "log_dir=/dev/stdout", "use_metrics=true"},
340346
},
341347
{
342348
name: "default options",
343-
cfglevel: "",
344349
options: nil,
345350
defaultOpts: "others,log_dir=/tmp/ossfs2",
346-
want: []string{"others", "log_dir=/tmp/ossfs2", "log_level=info"},
351+
want: []string{"others", "log_dir=/tmp/ossfs2", "log_level=info", "use_metrics=true"},
352+
},
353+
{
354+
name: "set metrics mode to disabled",
355+
config: &fpm.FuseContainerConfig{
356+
MetricsMode: fpm.MetricsModeDisabled,
357+
},
358+
want: []string{"log_level=info", "log_dir=/dev/stdout"},
347359
},
348360
}
349361
for _, tt := range tests {
350362
t.Run(tt.name, func(t *testing.T) {
351363
if tt.defaultOpts != "" {
352364
t.Setenv("DEFAULT_OSSFS2_OPTIONS", tt.defaultOpts)
353365
}
354-
fakeOssfs.config.Dbglevel = tt.cfglevel
366+
if tt.config != nil {
367+
fakeOssfs.config = *tt.config
368+
}
355369
got := fakeOssfs.AddDefaultMountOptions(tt.options)
356370
assert.Equal(t, tt.want, got)
357371
})

0 commit comments

Comments
 (0)