Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Move KernelListCacheTtlSecs to List #2083

Merged
merged 2 commits into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cmd/legacy_main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,12 @@ func (t *MainTest) TestStringifyShouldReturnAllFlagsPassedInMountConfigAsMarshal
`"TypeCacheMaxSizeMB":0`,
`"StatCacheMaxSizeMB":0`,
`"EnableEmptyManagedFolders":false`,
`"KernelListCacheTtlSeconds":0`,
`"GRPCConnPoolSize":0`,
`"AnonymousAccess":false`,
`"EnableHNS":true`,
`"IgnoreInterrupts":false`,
`"DisableParallelDirops":false}`,
`"DisableParallelDirops":false`,
`"KernelListCacheTtlSeconds":0}`,
}, ",")
assert.Equal(t.T(), expected, actual)
}
Expand Down Expand Up @@ -250,12 +250,12 @@ func (t *MainTest) TestEnableHNSFlagFalse() {
`"TypeCacheMaxSizeMB":0`,
`"StatCacheMaxSizeMB":0`,
`"EnableEmptyManagedFolders":false`,
`"KernelListCacheTtlSeconds":0`,
`"GRPCConnPoolSize":0`,
`"AnonymousAccess":false`,
`"EnableHNS":false`,
`"IgnoreInterrupts":false`,
`"DisableParallelDirops":false}`,
`"DisableParallelDirops":false`,
`"KernelListCacheTtlSeconds":0}`,
}, ",")
assert.Equal(t.T(), expected, actual)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/config/config_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func OverrideWithAnonymousAccessFlag(c cliContext, mountConfig *MountConfig, ano
// with the kernel-list-cache-ttl-secs cli-flag value if the cli-flag is set by user.
func OverrideWithKernelListCacheTtlFlag(c cliContext, mountConfig *MountConfig, ttl int64) {
if c.IsSet(KernelListCacheTtlFlagName) {
mountConfig.ListConfig.KernelListCacheTtlSeconds = ttl
mountConfig.FileSystemConfig.KernelListCacheTtlSeconds = ttl
}
}

Expand Down
4 changes: 2 additions & 2 deletions internal/config/config_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@ func Test_OverrideWithKernelListCacheTtlFlag(t *testing.T) {
for index, tt := range testCases {
t.Run(fmt.Sprintf("Test case: %d", index), func(t *testing.T) {
testContext := &TestCliContext{isSet: tt.isFlagSet}
mountConfig := &MountConfig{ListConfig: ListConfig{KernelListCacheTtlSeconds: tt.configValue}}
mountConfig := &MountConfig{FileSystemConfig: FileSystemConfig{KernelListCacheTtlSeconds: tt.configValue}}

OverrideWithKernelListCacheTtlFlag(testContext, mountConfig, tt.flagValue)

assert.Equal(t, tt.expectedValue, mountConfig.ListConfig.KernelListCacheTtlSeconds)
assert.Equal(t, tt.expectedValue, mountConfig.FileSystemConfig.KernelListCacheTtlSeconds)
})
}
}
Expand Down
9 changes: 4 additions & 5 deletions internal/config/mount_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ type ListConfig struct {
// (b) If both ImplicitDirectories and EnableEmptyManagedFolders are true, then all the managed folders are listed including the above-mentioned corner case.
// (c) If ImplicitDirectories is false then no managed folders are listed irrespective of EnableEmptyManagedFolders flag.
EnableEmptyManagedFolders bool `yaml:"enable-empty-managed-folders"`

KernelListCacheTtlSeconds int64 `yaml:"kernel-list-cache-ttl-secs"`
}

type GCSConnection struct {
Expand All @@ -105,8 +103,9 @@ type EnableHNS bool
type CacheDir string

type FileSystemConfig struct {
IgnoreInterrupts bool `yaml:"ignore-interrupts"`
DisableParallelDirops bool `yaml:"disable-parallel-dirops"`
IgnoreInterrupts bool `yaml:"ignore-interrupts"`
DisableParallelDirops bool `yaml:"disable-parallel-dirops"`
KernelListCacheTtlSeconds int64 `yaml:"kernel-list-cache-ttl-secs"`
}

type FileCacheConfig struct {
Expand Down Expand Up @@ -207,7 +206,7 @@ func NewMountConfig() *MountConfig {
}
mountConfig.EnableHNS = DefaultEnableHNS

mountConfig.ListConfig = ListConfig{
mountConfig.FileSystemConfig = FileSystemConfig{
KernelListCacheTtlSeconds: DefaultKernelListCacheTtlSeconds,
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
list:
file-system:
kernel-list-cache-ttl-secs: -2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
file-system:
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
list:
file-system:
kernel-list-cache-ttl-secs: 88888888888888888
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
list:
file-system:
kernel-list-cache-ttl-secs: 10

This file was deleted.

8 changes: 4 additions & 4 deletions internal/config/yaml_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ func (grpcClientConfig *GCSConnection) validate() error {
return nil
}

func (listConfig *ListConfig) validate() error {
err := IsTtlInSecsValid(listConfig.KernelListCacheTtlSeconds)
func (fileSystemConfig *FileSystemConfig) validate() error {
err := IsTtlInSecsValid(fileSystemConfig.KernelListCacheTtlSeconds)
if err != nil {
return fmt.Errorf("invalid kernelListCacheTtlSecs: %w", err)
}
Expand Down Expand Up @@ -182,8 +182,8 @@ func ParseConfigFile(fileName string) (mountConfig *MountConfig, err error) {
return mountConfig, fmt.Errorf("error parsing gcs-connection configs: %w", err)
}

if err = mountConfig.ListConfig.validate(); err != nil {
return mountConfig, fmt.Errorf("error parsing list config: %w", err)
if err = mountConfig.FileSystemConfig.validate(); err != nil {
return mountConfig, fmt.Errorf("error parsing file-system config: %w", err)
}

return
Expand Down
20 changes: 10 additions & 10 deletions internal/config/yaml_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,30 +302,30 @@ func (t *YamlParserTest) TestReadConfigFile_FileSystemConfig_UnsetDisableParalle
assert.False(t.T(), mountConfig.FileSystemConfig.DisableParallelDirops)
}

func (t *YamlParserTest) TestReadConfigFile_ListConfig_InvalidKernelListCacheTtl() {
_, err := ParseConfigFile("testdata/list_config/invalid_kernel_list_cache_ttl.yaml")
func (t *YamlParserTest) TestReadConfigFile_FileSystemConfig_InvalidKernelListCacheTtl() {
_, err := ParseConfigFile("testdata/file_system_config/invalid_kernel_list_cache_ttl.yaml")

assert.ErrorContains(t.T(), err, fmt.Sprintf("invalid kernelListCacheTtlSecs: %s", TtlInSecsInvalidValueError))
}

func (t *YamlParserTest) TestReadConfigFile_ListConfig_UnsupportedLargeKernelListCacheTtl() {
_, err := ParseConfigFile("testdata/list_config/unsupported_large_kernel_list_cache_ttl.yaml")
func (t *YamlParserTest) TestReadConfigFile_FileSystemConfig_UnsupportedLargeKernelListCacheTtl() {
_, err := ParseConfigFile("testdata/file_system_config/unsupported_large_kernel_list_cache_ttl.yaml")

assert.ErrorContains(t.T(), err, fmt.Sprintf("invalid kernelListCacheTtlSecs: %s", TtlInSecsTooHighError))
}

func (t *YamlParserTest) TestReadConfigFile_ListConfig_UnsetKernelListCacheTtl() {
mountConfig, err := ParseConfigFile("testdata/list_config/unset_kernel_list_cache_ttl.yaml")
func (t *YamlParserTest) TestReadConfigFile_FileSystemConfig_UnsetKernelListCacheTtl() {
mountConfig, err := ParseConfigFile("testdata/file_system_config/unset_kernel_list_cache_ttl.yaml")

assert.NoError(t.T(), err)
assert.NotNil(t.T(), mountConfig)
assert.Equal(t.T(), DefaultKernelListCacheTtlSeconds, mountConfig.ListConfig.KernelListCacheTtlSeconds)
assert.Equal(t.T(), DefaultKernelListCacheTtlSeconds, mountConfig.FileSystemConfig.KernelListCacheTtlSeconds)
}

func (t *YamlParserTest) TestReadConfigFile_ListConfig_ValidKernelListCacheTtl() {
mountConfig, err := ParseConfigFile("testdata/list_config/valid_kernel_list_cache_ttl.yaml")
func (t *YamlParserTest) TestReadConfigFile_FileSystemConfig_ValidKernelListCacheTtl() {
mountConfig, err := ParseConfigFile("testdata/file_system_config/valid_kernel_list_cache_ttl.yaml")

assert.NoError(t.T(), err)
assert.NotNil(t.T(), mountConfig)
assert.Equal(t.T(), int64(10), mountConfig.ListConfig.KernelListCacheTtlSeconds)
assert.Equal(t.T(), int64(10), mountConfig.FileSystemConfig.KernelListCacheTtlSeconds)
}
Loading