Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge the list of resources from custom checks and the generated cont… #727

Conversation

staerion
Copy link
Contributor

…roller list before deduplicating them

This PR fixes #
Controllers being shown twice in the Polaris dashboard:

  1. Currently the logic used by the Polaris dashboard collects all existing pods of the live cluster. It will then keep check for the parent controller by checking the ownerrefences. Once the ultimate parent controller has been found that does not have any ownerreference it will be added to a list. Every pod will return a "ultimate" parent controller. Because multiple pods can belong to the same controller, this list of controllers will be "deduplicated" by an internal function. Finally this list will be added to the final list of the controllers to be shown in the dashboard.

  2. At the same time, Polaris dashboard allows for custom checks to be defined. We are using this functionality to perform custom checks on kubernetes custom resource definitions like elasticsearch. All these resources (which can also be controllers such as for example elasticsearch) will then be added to the final list of the controllers to be shown in the dashboard.

The controllers are only being deduplicated in case 1. This means that in the case of pods being created by operators that are watching crds we are ending up with duplicate controllers in the dashboard. First, polaris will find that the ultimate controller of the elasticsearch pods is the elasticsearch crd. Then, we also use custom checks to validate the contents of these elasticsearch crds, they will be added again. In this PR I propose to first merge the list of kubernetes resources from case 1 and case 2 and deduplicate the combined list.

Checklist

  • [X ] I have signed the CLA
  • [X ] I have updated/added any relevant documentation

Description

What's the goal of this PR?

Ensure that custom checks defined in Polaris against crds that create pods do not result in Polaris dashboard showing controllers twice.

What changes did you make?

  1. Define a new slice "kubernetesResources". This slice will hold both the dynamically retrieved controllers and the additional kubernetes resources (additionalKinds) that the custom checks are defined against.
  2. The additionalKinds are being added to this slice first instead of directly added to the provider.
  3. The LoadControllers() function will return the slice of controllers without calling the deduplication function.
  4. The controllers and additionalKinds resources are merged and deduplicated together and assigned back to kubernetesResources.
  5. Add the new deduplicated slice to the provider.

What alternative solution should we consider, if any?

Possibly rename of rethink some of the variables or function names.
duplicate_controllers

@CLAassistant
Copy link

CLAassistant commented Mar 17, 2022

CLA assistant check
All committers have signed the CLA.

staerion and others added 4 commits March 17, 2022 22:30
… deduplicate-controllers-from-both-custom-checks-and-loaded-controllers
… deduplicate-controllers-from-both-custom-checks-and-loaded-controllers
@staerion
Copy link
Contributor Author

staerion commented Apr 4, 2022

@rbren @makoscafee
Any comment on the proposed suggestion or any other ideas what would be a way this duplication can be circumvented in the dashboard? Currently any crd with custom polaris checks will appear twice in the dashboard if that crd is the final owner of running pods.

Copy link
Contributor

@rbren rbren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to me. Appreciate the fix!

@rbren rbren merged commit fd16fb9 into FairwindsOps:master Apr 7, 2022
@staerion staerion deleted the deduplicate-controllers-from-both-custom-checks-and-loaded-controllers branch April 7, 2022 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants