From 89ca7f442e7212c8f7d8f5fd7d33da5dfed2239f Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 4 Aug 2021 14:20:38 +0200 Subject: [PATCH] Ignore context cancelled in operator (#27210) (#27221) (cherry picked from commit afe17b833cc2a73452eb8538e20f81b60a9d1a46) Co-authored-by: Michal Pristas --- .../elastic-agent/pkg/agent/operation/operator.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/x-pack/elastic-agent/pkg/agent/operation/operator.go b/x-pack/elastic-agent/pkg/agent/operation/operator.go index d4bfa33e6ae..df2f2b7cd99 100644 --- a/x-pack/elastic-agent/pkg/agent/operation/operator.go +++ b/x-pack/elastic-agent/pkg/agent/operation/operator.go @@ -144,7 +144,11 @@ func (o *Operator) Close() error { } // HandleConfig handles configuration for a pipeline and performs actions to achieve this configuration. -func (o *Operator) HandleConfig(cfg configrequest.Request) error { +func (o *Operator) HandleConfig(cfg configrequest.Request) (err error) { + defer func() { + err = filterContextCancelled(err) + }() + _, stateID, steps, ack, err := o.stateResolver.Resolve(cfg) if err != nil { o.statusReporter.Update(state.Failed, err.Error(), nil) @@ -352,3 +356,10 @@ func (o *Operator) deleteApp(p Descriptor) { o.logger.Debugf("operator is removing %s from app collection: %v", p.ID(), o.apps) delete(o.apps, id) } + +func filterContextCancelled(err error) error { + if errors.Is(err, context.Canceled) { + return nil + } + return err +}