[profiles] Do not error if pod needing deletion is not found #1608
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Occasionally, when we need to delete existing agent pods that don't match a node's affinity, there's a chance that some pods are already deleted between the time the cached list of pods the operator queries is updated and the operator sends the deletion request. When that happens, the operator receives a pod not found error from the deletion request. Instead of causing a reconciler error, this PR ignores the not found error.
Motivation
CECO-1383
Additional Notes
Anything else we should know when reviewing?
Minimum Agent Versions
Are there minimum versions of the Datadog Agent and/or Cluster Agent required?
Describe your test plan
This PR is difficult to test since the issue only happens sporadically. It was reported when a new DatadogAgentProfile was created that triggered the operator to delete existing agent pods for not meeting the updated nodeaffinity requirements and affected approximately 1 out of 8 agent pods in that instance.
One way to test could be to create a DatadogAgentProfile in staging and ensuring you don't see a reconcile error log similar to the following during rollout of the profile:
Checklist
bug
,enhancement
,refactoring
,documentation
,tooling
, and/ordependencies
qa/skip-qa
label