diff --git a/cmd/legacy_main.go b/cmd/legacy_main.go index 62b34271d4..76ab793bfc 100644 --- a/cmd/legacy_main.go +++ b/cmd/legacy_main.go @@ -259,7 +259,6 @@ func runCLIApp(c *cli.Context) (err error) { return fmt.Errorf("error resolving flags and configs: %w", err) } - config.OverrideWithIgnoreInterruptsFlag(c, mountConfig, flags.IgnoreInterrupts) config.OverrideWithAnonymousAccessFlag(c, mountConfig, flags.AnonymousAccess) config.OverrideWithKernelListCacheTtlFlag(c, mountConfig, flags.KernelListCacheTtlSeconds) diff --git a/internal/config/config_util.go b/internal/config/config_util.go index 6e37c63339..efffe938ff 100644 --- a/internal/config/config_util.go +++ b/internal/config/config_util.go @@ -39,15 +39,6 @@ type cliContext interface { IsSet(string) bool } -// OverrideWithIgnoreInterruptsFlag overwrites the ignore-interrupts config with -// the ignore-interrupts flag value if the flag is set. -func OverrideWithIgnoreInterruptsFlag(c cliContext, mountConfig *MountConfig, ignoreInterruptsFlag bool) { - // If the ignore-interrupts flag is set, give it priority over the value in config file. - if c.IsSet(IgnoreInterruptsFlagName) { - mountConfig.FileSystemConfig.IgnoreInterrupts = ignoreInterruptsFlag - } -} - // OverrideWithAnonymousAccessFlag overwrites the anonymous-access config with // the anonymous-access flag value if the flag is set. func OverrideWithAnonymousAccessFlag(c cliContext, mountConfig *MountConfig, anonymousAccess bool) { diff --git a/internal/config/config_util_test.go b/internal/config/config_util_test.go index d2606aa85b..1dc3c36c2e 100644 --- a/internal/config/config_util_test.go +++ b/internal/config/config_util_test.go @@ -85,34 +85,6 @@ func (s *TestCliContext) IsSet(flag string) bool { return s.isSet } -func TestOverrideWithIgnoreInterruptsFlag(t *testing.T) { - var overrideWithIgnoreInterruptsFlagTests = []struct { - testName string - ignoreInterruptConfigValue bool - isFlagSet bool - ignoreInterruptFlagValue bool - expectedIgnoreInterrupt bool - }{ - {"ignore-interrupts config true and flag not set", true, false, false, true}, - {"ignore-interrupts config false and flag not set", false, false, false, false}, - {"ignore-interrupts config false and ignore-interrupts flag false", false, true, false, false}, - {"ignore-interrupts config false and ignore-interrupts flag true", false, true, true, true}, - {"ignore-interrupts config true and ignore-interrupts flag false", true, true, false, false}, - {"ignore-interrupts config true and ignore-interrupts flag true", true, true, true, true}, - } - - for _, tt := range overrideWithIgnoreInterruptsFlagTests { - t.Run(tt.testName, func(t *testing.T) { - testContext := &TestCliContext{isSet: tt.isFlagSet} - mountConfig := &MountConfig{FileSystemConfig: FileSystemConfig{IgnoreInterrupts: tt.ignoreInterruptConfigValue}} - - OverrideWithIgnoreInterruptsFlag(testContext, mountConfig, tt.ignoreInterruptFlagValue) - - assert.Equal(t, tt.expectedIgnoreInterrupt, mountConfig.FileSystemConfig.IgnoreInterrupts) - }) - } -} - func TestOverrideWithAnonymousAccessFlag(t *testing.T) { var overrideWithAnonymousAccessFlagTests = []struct { testName string diff --git a/internal/fs/fs.go b/internal/fs/fs.go index 2327e6aadb..686aa039bd 100644 --- a/internal/fs/fs.go +++ b/internal/fs/fs.go @@ -1335,7 +1335,7 @@ func (fs *fileSystem) StatFS( func (fs *fileSystem) LookUpInode( ctx context.Context, op *fuseops.LookUpInodeOp) (err error) { - if fs.mountConfig.FileSystemConfig.IgnoreInterrupts { + if fs.newConfig.FileSystem.IgnoreInterrupts { // When ignore interrupts config is set, we are creating a new context not // cancellable by parent context. var cancel context.CancelFunc @@ -1371,7 +1371,7 @@ func (fs *fileSystem) LookUpInode( func (fs *fileSystem) GetInodeAttributes( ctx context.Context, op *fuseops.GetInodeAttributesOp) (err error) { - if fs.mountConfig.FileSystemConfig.IgnoreInterrupts { + if fs.newConfig.FileSystem.IgnoreInterrupts { // When ignore interrupts config is set, we are creating a new context not // cancellable by parent context. var cancel context.CancelFunc @@ -1399,7 +1399,7 @@ func (fs *fileSystem) GetInodeAttributes( func (fs *fileSystem) SetInodeAttributes( ctx context.Context, op *fuseops.SetInodeAttributesOp) (err error) { - if fs.mountConfig.FileSystemConfig.IgnoreInterrupts { + if fs.newConfig.FileSystem.IgnoreInterrupts { // When ignore interrupts config is set, we are creating a new context not // cancellable by parent context. var cancel context.CancelFunc @@ -1465,7 +1465,7 @@ func (fs *fileSystem) ForgetInode( func (fs *fileSystem) MkDir( ctx context.Context, op *fuseops.MkDirOp) (err error) { - if fs.mountConfig.FileSystemConfig.IgnoreInterrupts { + if fs.newConfig.FileSystem.IgnoreInterrupts { // When ignore interrupts config is set, we are creating a new context not // cancellable by parent context. var cancel context.CancelFunc @@ -1524,7 +1524,7 @@ func (fs *fileSystem) MkDir( func (fs *fileSystem) MkNode( ctx context.Context, op *fuseops.MkNodeOp) (err error) { - if fs.mountConfig.FileSystemConfig.IgnoreInterrupts { + if fs.newConfig.FileSystem.IgnoreInterrupts { // When ignore interrupts config is set, we are creating a new context not // cancellable by parent context. var cancel context.CancelFunc @@ -1654,7 +1654,7 @@ func (fs *fileSystem) createLocalFile( func (fs *fileSystem) CreateFile( ctx context.Context, op *fuseops.CreateFileOp) (err error) { - if fs.mountConfig.FileSystemConfig.IgnoreInterrupts { + if fs.newConfig.FileSystem.IgnoreInterrupts { // When ignore interrupts config is set, we are creating a new context not // cancellable by parent context. var cancel context.CancelFunc @@ -1703,7 +1703,7 @@ func (fs *fileSystem) CreateFile( func (fs *fileSystem) CreateSymlink( ctx context.Context, op *fuseops.CreateSymlinkOp) (err error) { - if fs.mountConfig.FileSystemConfig.IgnoreInterrupts { + if fs.newConfig.FileSystem.IgnoreInterrupts { // When ignore interrupts config is set, we are creating a new context not // cancellable by parent context. var cancel context.CancelFunc @@ -1773,7 +1773,7 @@ func (fs *fileSystem) RmDir( ctx context.Context, op *fuseops.RmDirOp) (err error) { - if fs.mountConfig.FileSystemConfig.IgnoreInterrupts { + if fs.newConfig.FileSystem.IgnoreInterrupts { // When ignore interrupts config is set, we are creating a new context not // cancellable by parent context. var cancel context.CancelFunc @@ -1875,7 +1875,7 @@ func (fs *fileSystem) RmDir( func (fs *fileSystem) Rename( ctx context.Context, op *fuseops.RenameOp) (err error) { - if fs.mountConfig.FileSystemConfig.IgnoreInterrupts { + if fs.newConfig.FileSystem.IgnoreInterrupts { // When ignore interrupts config is set, we are creating a new context not // cancellable by parent context. var cancel context.CancelFunc @@ -2094,7 +2094,7 @@ func (fs *fileSystem) renameDir( func (fs *fileSystem) Unlink( ctx context.Context, op *fuseops.UnlinkOp) (err error) { - if fs.mountConfig.FileSystemConfig.IgnoreInterrupts { + if fs.newConfig.FileSystem.IgnoreInterrupts { // When ignore interrupts config is set, we are creating a new context not // cancellable by parent context. var cancel context.CancelFunc @@ -2182,7 +2182,7 @@ func (fs *fileSystem) OpenDir( func (fs *fileSystem) ReadDir( ctx context.Context, op *fuseops.ReadDirOp) (err error) { - if fs.mountConfig.FileSystemConfig.IgnoreInterrupts { + if fs.newConfig.FileSystem.IgnoreInterrupts { // When ignore interrupts config is set, we are creating a new context not // cancellable by parent context. var cancel context.CancelFunc @@ -2254,7 +2254,7 @@ func (fs *fileSystem) OpenFile( func (fs *fileSystem) ReadFile( ctx context.Context, op *fuseops.ReadFileOp) (err error) { - if fs.mountConfig.FileSystemConfig.IgnoreInterrupts { + if fs.newConfig.FileSystem.IgnoreInterrupts { // When ignore interrupts config is set, we are creating a new context not // cancellable by parent context. var cancel context.CancelFunc @@ -2305,7 +2305,7 @@ func (fs *fileSystem) ReadSymlink( func (fs *fileSystem) WriteFile( ctx context.Context, op *fuseops.WriteFileOp) (err error) { - if fs.mountConfig.FileSystemConfig.IgnoreInterrupts { + if fs.newConfig.FileSystem.IgnoreInterrupts { // When ignore interrupts config is set, we are creating a new context not // cancellable by parent context. var cancel context.CancelFunc @@ -2332,7 +2332,7 @@ func (fs *fileSystem) WriteFile( func (fs *fileSystem) SyncFile( ctx context.Context, op *fuseops.SyncFileOp) (err error) { - if fs.mountConfig.FileSystemConfig.IgnoreInterrupts { + if fs.newConfig.FileSystem.IgnoreInterrupts { // When ignore interrupts config is set, we are creating a new context not // cancellable by parent context. var cancel context.CancelFunc @@ -2365,7 +2365,7 @@ func (fs *fileSystem) SyncFile( func (fs *fileSystem) FlushFile( ctx context.Context, op *fuseops.FlushFileOp) (err error) { - if fs.mountConfig.FileSystemConfig.IgnoreInterrupts { + if fs.newConfig.FileSystem.IgnoreInterrupts { // When ignore interrupts config is set, we are creating a new context not // cancellable by parent context. var cancel context.CancelFunc diff --git a/internal/fs/fs_test.go b/internal/fs/fs_test.go index 8db78cf357..7725050983 100644 --- a/internal/fs/fs_test.go +++ b/internal/fs/fs_test.go @@ -30,6 +30,7 @@ import ( "time" "github.com/googlecloudplatform/gcsfuse/v2/cfg" + "github.com/googlecloudplatform/gcsfuse/v2/internal/config" "github.com/googlecloudplatform/gcsfuse/v2/internal/fs" "github.com/googlecloudplatform/gcsfuse/v2/internal/gcsx" "github.com/googlecloudplatform/gcsfuse/v2/internal/locker" @@ -138,6 +139,9 @@ func (t *fsTest) SetUpTestSuite() { } t.serverCfg.RenameDirLimit = RenameDirLimit t.serverCfg.SequentialReadSizeMb = SequentialReadSizeMb + if t.serverCfg.MountConfig == nil { + t.serverCfg.MountConfig = config.NewMountConfig() + } if t.serverCfg.NewConfig == nil { t.serverCfg.NewConfig = &cfg.DefaultConfig }