fix(maxprocs): gracefully handle cgroup permission errors#7659
Closed
SAY-5 wants to merge 2 commits intokedacore:mainfrom
Closed
fix(maxprocs): gracefully handle cgroup permission errors#7659SAY-5 wants to merge 2 commits intokedacore:mainfrom
SAY-5 wants to merge 2 commits intokedacore:mainfrom
Conversation
When KEDA pods run in environments where cgroup files are not readable (for example, a restricted SecurityContext or a non-standard cgroup mount), go.uber.org/automaxprocs returns a permission error from maxprocs.Set. Today all three callers (operator, webhooks, adapter) treat that as fatal and os.Exit(1), producing a CrashLoopBackOff with no way to start KEDA at all. This change handles fs.ErrPermission in ConfigureMaxProcs by logging a warning and returning nil. GOMAXPROCS is already left at the Go runtime default (NumCPU) when maxprocs.Set fails, so the process can continue to start and serve traffic. Non-permission errors are still propagated unchanged. Fixes #7653 Signed-off-by: SAY-5 <SAY-5@users.noreply.github.com>
Signed-off-by: SAY-5 <SAY-5@users.noreply.github.com>
|
Thank you for your contribution! 🙏 Please understand that we will do our best to review your PR and give you feedback as soon as possible, but please bear with us if it takes a little longer as expected. While you are waiting, make sure to:
Once the initial tests are successful, a KEDA member will ensure that the e2e tests are run. Once the e2e tests have been successfully completed, the PR may be merged at a later date. Please be patient. Learn more about our contribution guide. |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Member
|
duplicate (#7655) |
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.
What does this PR do?
Fixes #7653.
When KEDA pods run in an environment where the cgroup CPU files are not readable (for example, under a restricted
SecurityContextthat denies access to/sys/fs/cgroup/cpu.max, or on certain managed Kubernetes offerings that mount cgroups read-only),go.uber.org/automaxprocs'smaxprocs.Setreturns a permission error:Today all three callers —
cmd/operator/main.go,cmd/webhooks/main.go, andcmd/adapter/main.go— treat that error as fatal and callos.Exit(1). The result is aCrashLoopBackOffwith no way to bring KEDA up at all, even though the only consequence of the failure is thatGOMAXPROCScannot be derived from cgroup quota. Go's runtime default (runtime.NumCPU()) is already a safe fallback.Fix
pkg/util/maxprocs.gonow:maxprocs.Set.fs.ErrPermission, logs a warning via the sameklog.Logger(so it is still visible in pod logs) and returnsnil.This lets KEDA start in locked-down environments while still surfacing the misconfiguration in logs. Non-permission errors (malformed cgroup data, I/O errors, etc.) remain fatal as before.
Which issue(s) this PR fixes
Fixes #7653
Checklist