Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

Refactor Marked for Termination feature #213

Merged
merged 2 commits into from
Mar 12, 2020
Merged

Refactor Marked for Termination feature #213

merged 2 commits into from
Mar 12, 2020

Conversation

lrgar
Copy link
Contributor

@lrgar lrgar commented Mar 11, 2020

On this PR I'm refactoring when Marked for Termination events are going to be sent: rather than sending them when a node goes cordoned or deleted, we'll now only send them when deleted.

The reason is that a node being cordoned doesn't affect DaemonSets such as the OneAgent; they are still running, so the timings can be wrong.

So the idea here is to keep a cache of seen nodes in a ConfigMap on the dynatrace namespace (called it dynatrace-node-cache. I've modified the Nodes controller to run periodically every 5 minutes to check the current state and send events if a node on the cache doesn't exist anymore. I've also added the logic to recognize deletions from the Dynatrace API.

As for additional notes,

  • The usual Controller pattern from the the controller-runtime doesn't fit our purposes, so the Node Controller is now a "Runnable".
  • The cache ConfigMap is owned by the Operator Deployment, so will be removed on uninstallations, etc.
    • And to set this ownership, I need to query for ReplicaSet and Deployment objects, so I've added the permissions to the Roles.
  • In case of failures, unlike the standard Controller logic, I'm just logging the error and will try again on the next full reconciliation (so in 5 minutes.)

@lrgar lrgar requested a review from DTMad March 11, 2020 16:48
@lrgar lrgar merged commit 3fd0f5e into master Mar 12, 2020
@lrgar lrgar deleted the feature/mft-refactor branch March 12, 2020 09:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants