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

Feat/exclude workloads managed by scaled object #76

Conversation

samuel-esp
Copy link
Contributor

@samuel-esp samuel-esp commented Dec 21, 2024

Motivation

As stated in #64: workloads managed by ScaledObjects are currently also scaled by the Downscaler. This results in the ScaledObject and the downscaler fighting to downscale those workloads to (possibly) different Replicas.

This PRs solves this problem by excluding from downscaling all the workloads managed by a Keda ScaledObject. The solution works in this way:

Prerequisite: all ScaledObjects should be processed first by the algorithm

  • Inside the FilterExcluded function:
    • When the algorithm encounters a ScaledObject:
      • It computes a hash for the ScaledObject's targetRef, which is derived from the combination of (Kind+Name+Namespace):
      • The computed hash is stored in a hashMap for reference.
    • When the algorithm encounters every other workloads (Deployment, StatefulSet, ...):
      • The isManagedByKeda function computes a hash for the workload using (Kind+Name+Namespace)
      • It checks if the computed hash exists in the hashMap.
        • If a match is found in the hashMap, the workload is excluded from scaling as it is considered managed by KEDA.

Changes

  • Refactored FilterExcluded to implement the solution proposed
  • Introduced computeHash function to compute a Sum64 hash
  • Introduce OrderIncludeResourcesArgument function to enforce the order of submission for resources inside --include-resources argument
  • Introduced inside each Kubernetes Native class its GroupVersionKind

Tests done

  • Unit Tests
  • Live Tests

TODO

  • Check Native GroupVersionKind Existence for these CRDs (Rollout, Stack, Prometheus)
  • Add More Unit Tests

@jonathan-mayer
Copy link
Member

Ive took some inspiration from this and refactored it in #78 to be a bit less verbose and fit nicer in the preexisting structure. Nice work @samuel-esp.

@samuel-esp
Copy link
Contributor Author

That's perfect Jonathan, don't worry!

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.

2 participants