feat: add automatic deploy dependency detection for KEDA ScaledObjects#631
Merged
ilya-lesikov merged 3 commits intoJun 15, 2026
Merged
Conversation
1fffaab to
d79d614
Compare
nelm now automatically deploys a KEDA `ScaledObject` after the workload referenced by its `spec.scaleTargetRef`, so the ordering no longer has to be declared by hand. Previously, when a `ScaledObject` and its target workload (e.g. a `Deployment`) belonged to the same release, nelm put both in the same deploy stage with no ordering between them. If the `ScaledObject` reached the API server before its target existed, the install broke in one of two ways: - with a `cpu`/`memory` trigger, KEDA's validating webhook resolves the target and denies the request (the error reported in werf#456): `admission webhook "vscaledobject.kb.io" denied the request: Deployment.apps "app" not found` - with any other trigger the object is admitted, but the KEDA controller cannot reconcile it and it stays `Ready=False` with `reason=ScaledObjectCheckFailed` The only way around it was a manual dependency annotation: ```yaml werf.io/deploy-dependency-app: state=present,kind=Deployment,name=app ``` `internalDeployDependencies` already derives implicit dependencies for built-in workloads, RBAC bindings and others. This adds a `keda.sh/ScaledObject` case that reads `spec.scaleTargetRef` and emits a `present` dependency on the referenced workload: - `name` - required; if it is missing the `ScaledObject` is left untouched - `kind` - defaults to `Deployment` - `apiVersion` - defaults to `apps/v1`, and the group is parsed from it The dependency is `present`, not `ready`: nelm waits only for the target to exist, which is all KEDA needs, instead of blocking on its readiness. `ScaledJob` is intentionally left out — it uses `jobTargetRef` and creates its own Jobs, so it has no such dependency. Verified against a live cluster running KEDA: with the change the `ScaledObject` is always created after its target and reconciles cleanly, and the werf#456 webhook denial reproduces without it. Closes werf#456 Signed-off-by: Alexey Gorovenko <sharvashinho@gmail.com>
f03eb31 to
799c021
Compare
Member
|
Hi, please, resolve conflicts, but don't force-push anymore, otherwise I need to look at all the commits again. |
…loy-dependency Signed-off-by: Alexey Gorovenko <sharvashinho@gmail.com>
Member
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
nelm now automatically deploys a KEDA
ScaledObjectafter the workload referenced by itsspec.scaleTargetRef, so the ordering no longer has to be declared by hand.Previously, when a
ScaledObjectand its target workload (e.g. aDeployment) belonged to the same release, nelm put both in the same deploy stage with no ordering between them. If theScaledObjectreached the API server before its target existed, the install broke in one of two ways:cpu/memorytrigger, KEDA's validating webhook resolves the target and denies the request (the error reported in KEDA ScaledObject is trying to be deployed before deployment #456):admission webhook "vscaledobject.kb.io" denied the request: Deployment.apps "app" not foundReady=Falsewithreason=ScaledObjectCheckFailedThe only way around it was a manual dependency annotation:
internalDeployDependenciesalready derives implicit dependencies for built-in workloads, RBAC bindings and others. This adds akeda.sh/ScaledObjectcase that readsspec.scaleTargetRefand emits apresentdependency on the referenced workload:name- required; if it is missing theScaledObjectis left untouchedkind- defaults toDeploymentapiVersion- defaults toapps/v1, and the group is parsed from itThe dependency is
present, notready: nelm waits only for the target to exist, which is all KEDA needs, instead of blocking on its readiness.ScaledJobis intentionally left out — it usesjobTargetRefand creates its own Jobs, so it has no such dependency.Verified against a live cluster running KEDA: with the change the
ScaledObjectis always created after its target and reconciles cleanly, and the #456 webhook denial reproduces without it.Closes #456