diff --git a/charts/vald/values.yaml b/charts/vald/values.yaml index bd16c485b3..09770d3f14 100644 --- a/charts/vald/values.yaml +++ b/charts/vald/values.yaml @@ -1374,7 +1374,7 @@ agent: auto_backup_duration: 10m # @schema {"name": "agent.sidecar.config.post_stop_timeout", "type": "string"} # agent.sidecar.config.post_stop_timeout -- timeout duration for file changing during post stop - post_stop_timeout: 10s + post_stop_timeout: 20s # @schema {"name": "agent.sidecar.config.filename", "type": "string"} # agent.sidecar.config.filename -- backup filename filename: _MY_POD_NAME_ diff --git a/pkg/agent/sidecar/service/observer/observer.go b/pkg/agent/sidecar/service/observer/observer.go index 3fa16ef46a..3f15ac1626 100644 --- a/pkg/agent/sidecar/service/observer/observer.go +++ b/pkg/agent/sidecar/service/observer/observer.go @@ -159,10 +159,19 @@ func (o *observer) PostStop(ctx context.Context) (err error) { return err } - _, err = o.w.Start(ctx) + wctx, cancel := context.WithCancel(ctx) + defer cancel() + + _, err = o.w.Start(wctx) if err != nil { return err } + defer func() { + e := o.w.Stop(wctx) + if e != nil { + log.Error("an error occurred when watcher stopped:", e) + } + }() for { select { diff --git a/pkg/agent/sidecar/service/observer/option.go b/pkg/agent/sidecar/service/observer/option.go index 04c36e9ccd..61ebe56b09 100644 --- a/pkg/agent/sidecar/service/observer/option.go +++ b/pkg/agent/sidecar/service/observer/option.go @@ -29,7 +29,7 @@ var ( defaultOpts = []Option{ WithErrGroup(errgroup.Get()), WithBackupDuration("10m"), - WithPostStopTimeout("10s"), + WithPostStopTimeout("20s"), } )