*: fix code style issue

1. it's easy to check wrong input if using drain_exec_sync_io_timeout in error
2. avoid to use full error message, as part of error generated by go
   stdlib would be changed in the future
3. delete the extra empty line

Signed-off-by: Wei Fu <fuweid89@gmail.com>
This commit is contained in:
Wei Fu 2023-03-03 17:51:03 +08:00
parent 98cb6d7eb8
commit 5946c1051e
4 changed files with 2 additions and 4 deletions

View File

@ -522,7 +522,7 @@ func ValidatePluginConfig(ctx context.Context, c *PluginConfig) error {
// Validation for drain_exec_sync_io_timeout
if c.DrainExecSyncIOTimeout != "" {
if _, err := time.ParseDuration(c.DrainExecSyncIOTimeout); err != nil {
return fmt.Errorf("invalid drain exec sync io timeout: %w", err)
return fmt.Errorf("invalid `drain_exec_sync_io_timeout`: %w", err)
}
}
return nil

View File

@ -395,7 +395,7 @@ func TestValidateConfig(t *testing.T) {
},
DrainExecSyncIOTimeout: "10",
},
expectedErr: "invalid drain exec sync io timeout: time: missing unit in duration \"10\"",
expectedErr: "invalid `drain_exec_sync_io_timeout`",
},
} {
t.Run(desc, func(t *testing.T) {

View File

@ -290,7 +290,6 @@ func drainExecSyncIO(ctx context.Context, execProcess containerd.Process, drainE
select {
case <-timerCh:
case <-attachDone:
log.G(ctx).Debugf("Stream pipe for exec process %q done", execProcess.ID())
return nil

View File

@ -290,7 +290,6 @@ func drainExecSyncIO(ctx context.Context, execProcess containerd.Process, drainE
select {
case <-timerCh:
case <-attachDone:
log.G(ctx).Debugf("Stream pipe for exec process %q done", execProcess.ID())
return nil