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

fix: add Keycloak workaround for Kernels 6.12+ #1218

Merged
merged 20 commits into from
Feb 7, 2025
Merged

Conversation

slaskawi
Copy link
Contributor

@slaskawi slaskawi commented Jan 23, 2025

Description

This Pull Request introduces a new env setting for Keycloak that enables Mission Heroes to specify additional Environment Variables. This setting can be used for Kernel 6.12+ workaround.

More context

Linux Kernel 6.12 changed the way the missing CGroups v1 are reported. This caused any Java applications to interpret container limits incorrectly (more on this in #1212).

As clarified in Cloud Native Slack with the Keycloak Team, the Red Hat JVM Team will backport all required fixes into lower Java versions. However, the timeline for this remains unknown and it is very likely that we may need this workaround at some point.

Once a patched JVM is out there and used in Keycloak container images, we will revert this change.

Related Issue

Relates to #1212

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Other (security config, docs update, etc)

Steps to Validate

The easiest way to test this feature is to add this part of the override to the k3d-slim-dev/uds-bundle.yaml:

            - path: env
              value:
                - name: JAVA_OPTS_KC_HEAP
                  value: "-XX:MaxRAMPercentage=70 -XX:MinRAMPercentage=70 -XX:InitialRAMPercentage=50 -XX:MaxRAM=1G"

Then, call uds run slim-dev. Once Keycloak is up and running, check its Pod and the JAVA_OPTS_KC_HEAP Environment Variable should be there.

This Pull Request has been checked against regressions in this Github Actions run. This patch contained hardcoded JAVA_OPTS_KC_HEAP set to -XX:MaxRAMPercentage=70 -XX:MinRAMPercentage=70 -XX:InitialRAMPercentage=50 -XX:MaxRAM=1G and it didn't cause any test failures.

Checklist before merging

@slaskawi slaskawi changed the title fix: Add Keycloak workaround for Kernels 6.12+ fix: add Keycloak workaround for Kernels 6.12+ Jan 23, 2025
@slaskawi slaskawi marked this pull request as ready for review January 28, 2025 07:42
@slaskawi slaskawi requested a review from a team as a code owner January 28, 2025 07:42
Copy link
Member

@eddiezane eddiezane left a comment

Choose a reason for hiding this comment

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

Thanks for adding this!

I manually tested this and confirmed it worked.

src/keycloak/chart/templates/statefulset.yaml Outdated Show resolved Hide resolved
Copy link
Contributor

@mjnagel mjnagel left a comment

Choose a reason for hiding this comment

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

Appreciate the work on this! Just have one small comment on the docs note + a suggestion/thought on @eddiezane's comment.

src/keycloak/chart/templates/statefulset.yaml Outdated Show resolved Hide resolved
@slaskawi
Copy link
Contributor Author

slaskawi commented Feb 6, 2025

@mjnagel @eddiezane Thanks for the review!

I decided to change the approach and introduce a way to introduce non-standard environment variables in the Keycloak Helm Template - it's called env. With the new setting, you can leverage the Bundle Overrides and pass the JAVA_OPTS_KC_HEAP. I find this approach much more flexible and we could potentially leverage it for doing non-standard things.

In the documentation, I described how to properly use this setting to bypass the Kernel 6.12+ issue.

@slaskawi slaskawi marked this pull request as draft February 6, 2025 11:23
@slaskawi slaskawi marked this pull request as ready for review February 6, 2025 12:10
mjnagel
mjnagel previously approved these changes Feb 7, 2025
Copy link
Contributor

@mjnagel mjnagel left a comment

Choose a reason for hiding this comment

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

LGTM at this point! Last question - should we maybe add the override of env by default to the dev/demo bundles? I think since we don't expose resources as configurable to the end user in those bundles we could just hardcode the 1G override you had initially. That would allow @eddiezane and others to deploy those bundles without needing to think about the values.

@slaskawi
Copy link
Contributor Author

slaskawi commented Feb 7, 2025

LGTM at this point! Last question - should we maybe add the override of env by default to the dev/demo bundles? I think since we don't expose resources as configurable to the end user in those bundles we could just hardcode the 1G override you had initially. That would allow @eddiezane and others to deploy those bundles without needing to think about the values.

Done! Thanks for suggesting this!

@slaskawi slaskawi merged commit bb634a6 into main Feb 7, 2025
25 checks passed
@slaskawi slaskawi deleted the 1212-keycloak-oom-issue branch February 7, 2025 20:05
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