From 5946c1051ed84b4bc3a5e3bb98f516b1dd648f3d Mon Sep 17 00:00:00 2001 From: Wei Fu Date: Fri, 3 Mar 2023 17:51:03 +0800 Subject: [PATCH] *: 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 --- pkg/cri/config/config.go | 2 +- pkg/cri/config/config_test.go | 2 +- pkg/cri/sbserver/container_execsync.go | 1 - pkg/cri/server/container_execsync.go | 1 - 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/pkg/cri/config/config.go b/pkg/cri/config/config.go index 7f0403c30..ad16bbe20 100644 --- a/pkg/cri/config/config.go +++ b/pkg/cri/config/config.go @@ -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 diff --git a/pkg/cri/config/config_test.go b/pkg/cri/config/config_test.go index 620d4906c..4c2a80419 100644 --- a/pkg/cri/config/config_test.go +++ b/pkg/cri/config/config_test.go @@ -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) { diff --git a/pkg/cri/sbserver/container_execsync.go b/pkg/cri/sbserver/container_execsync.go index cd67037ac..3e4090f3e 100644 --- a/pkg/cri/sbserver/container_execsync.go +++ b/pkg/cri/sbserver/container_execsync.go @@ -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 diff --git a/pkg/cri/server/container_execsync.go b/pkg/cri/server/container_execsync.go index 63ba72512..23885471e 100644 --- a/pkg/cri/server/container_execsync.go +++ b/pkg/cri/server/container_execsync.go @@ -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