8000 RawKeycloakDistribution exit code is always 0 · Issue #38161 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

RawKeycloakDistribution exit code is always 0 #38161

Closed

Description

@mhajas

Before reporting an issue

  • I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.

Area

testsuite

Describe the bug

When making a distribution run with non-zero exit in the testsuite the RawKeycloakDistribution does not provide correct exit code.

Version

main

Regression

  • The issue is a regression

Expected behavior

When running this distribution run:

var result = distribution.run(UpdateCompatibility.NAME, UpdateCompatibilityCheck.NAME, UpdateCompatibilityCheck.INPUT_OPTION_NAME, jsonFile.getAbsolutePath(), ENABLE_FEATURE);

the expected call to result.exitCode() should return non-zero exit code.

Actual behavior

The run return 0.

How to Reproduce?

Run the following test in debug mode:

public void testWrongVersions(KeycloakDistribution distribution) throws IOException {
var jsonFile = createTempFile("wrong-versions");
// incompatible keycloak version
var info = new ServerInfo();
info.setVersions(Map.of(CompatibilityManagerImpl.KEYCLOAK_VERSION_KEY, "0.0.0.Final",
CompatibilityManagerImpl.INFINISPAN_VERSION_KEY, org.infinispan.commons.util.Version.getVersion()));
JsonSerialization.mapper.writeValue(jsonFile, info);
var result = distribution.run(UpdateCompatibility.NAME, UpdateCompatibilityCheck.NAME, UpdateCompatibilityCheck.INPUT_OPTION_NAME, jsonFile.getAbsolutePath(), ENABLE_FEATURE);
result.assertError("[Versions] Rolling Upgrade is not available. 'keycloak' is incompatible: Old=0.0.0.Final, New=%s".formatted(Version.VERSION));
// incompatible infinispan version
info.setVersions(Map.of(
CompatibilityManagerImpl.KEYCLOAK_VERSION_KEY, Version.VERSION,
CompatibilityManagerImpl.INFINISPAN_VERSION_KEY, "0.0.0.Final"));
JsonSerialization.mapper.writeValue(jsonFile, info);
result = distribution.run(UpdateCompatibility.NAME, UpdateCompatibilityCheck.NAME, UpdateCompatibilityCheck.INPUT_OPTION_NAME, jsonFile.getAbsolutePath(), ENABLE_FEATURE);
result.assertError("[Versions] Rolling Upgrade is not available. 'infinispan' is incompatible: Old=0.0.0.Final, New=%s".formatted(org.infinispan.commons.util.Version.getVersion()));
}

The result on line 96 should have non-zero exit code, however, the exit code is 0.

Anything else?

No response

Activity

  1. shawkins commented on Apr 3, 2025

    @shawkins
    Contributor

    There are actually 3 issues highlighted here:

    • the RawKeycloakDistribution is using the launch mode option, but it should not be - that's only for in-process testing that wants to avoid System.exit calls. This is an easy fix.
    • reaug is not being avoided for the compatiblity checks. The current command is an update, not the parent - we've not been consistent with how to avoid these. There's a large fix as part of consolidating profile logic and moving reaug related logic #38514, but we can do something more targeted for 26.2 if needed. Captured as Update commands trigger build checks #38662
    • Finally, and worst of all, is that the use of eval in the bash script is squashing the exit code. Even if we address the above, the test will see an exit code of -1 / 255. Any upgrade logic in the operator currently relying upon non-zero exit codes won't work correctly. - nevermind, this seems to only be happening in the RawKeycloakDistribution. It works as expected from a shell. The problem was that I had initially updated the test to use manual stopping to workaround the launch mode issue, but that causes the exit code to always be -1

    cc @vmuzikar @pruivo

  2. self-assigned this
    on Apr 3, 2025
  3. keycloak-github-bot commented on Apr 3, 2025

    @keycloak-github-bot

    Due to the amount of issues reported by the community we are not able to prioritise resolving this issue at the moment.

    If you are affected by this issue, upvote it by adding a 👍 to the description. We would also welcome a contribution to fix the issue.

  4. added a commit that references this issue on Apr 15, 2025
    b8aae99
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    0