Skip to content

Backport operator secret sequencing fix - #23705

Closed
Jamstah wants to merge 2 commits into
keycloak:release/22.0from
Jamstah:backport-reconcile-fix
Closed

Backport operator secret sequencing fix#23705
Jamstah wants to merge 2 commits into
keycloak:release/22.0from
Jamstah:backport-reconcile-fix

Conversation

@Jamstah

@Jamstah Jamstah commented Oct 4, 2023

Copy link
Copy Markdown
Contributor

This bug makes scenarios where applying the Keycloak CR at the same time as the Certificate CR that is expected to generate the secret used by Keycloak will, more often than not, end up in a bad state. This forces bad behaviour like sequencing CRs onto the cluster.

We are expecting to use 22.0 with our customers, so would like to backport the fix from #22404 (and #21162 as a dependency)

Fixes #22170

@Jamstah
Jamstah requested review from a team as code owners October 4, 2023 13:20
@ghost ghost added team/cloud-native labels Oct 4, 2023

@vmuzikar vmuzikar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Jamstah Thanks for the PR.

I'm afraid we can't backport changes that significantly alter functionality. If there's a need for fixing #22170 in a 22 micro (I'm not 100% sure it's affected), I'd rather have a smaller targeted fix while keeping current implementation.

@Jamstah

Jamstah commented Oct 4, 2023

Copy link
Copy Markdown
Contributor Author

Its definitely affected, we've been testing with it.

I'm happy to look at a more targeted fix, but it would be a different fix to the one in 23.x. I thought it would be cleaner to apply the same fix.

I guess its the WatchedSecretsController that you want to avoid bringing in? That's only there to know when to apply the missing secrets annotation used to trigger the scheduled reconcile. I could have a go at applying the label with based on the previous WatchedSecretsStore implementation, if that suits?

@vmuzikar

vmuzikar commented Oct 4, 2023

Copy link
Copy Markdown
Contributor

I'm happy to look at a more targeted fix, but it would be a different fix to the one in 23.x. I thought it would be cleaner to apply the same fix.

That's generarly true backports should be 1:1. However, in 23 we did more major changes to Operator implementation we want to avoid dragging in back to 22 to limit the risk of regressions in a micro.

In this case, I think we need a tailored fix for 22 to keep previous implementation.

@shawkins WDYT?

@shawkins

shawkins commented Oct 4, 2023

Copy link
Copy Markdown
Contributor

Other than some additional risk, probably the biggest issue for a point release is that this will trigger a rolling restart of the keycloak instance.

As long as we're okay with that, then I think the additional risk is worth not having a skew in the implementations.

@vmuzikar

vmuzikar commented Oct 4, 2023

Copy link
Copy Markdown
Contributor

the biggest issue for a point release is that this will trigger a rolling restart of the keycloak instance.

You mean upgrading to the micro will cause the restart? It will trigger a restart in any case to roll the new image.

I'm not really comfortable with backporting anything this big, especially not now before prod release. I'd rather have a different fix implementation.

@Jamstah

Jamstah commented Oct 4, 2023

Copy link
Copy Markdown
Contributor Author

OK. I need to fix the tests anyway (I only ran the unit tests, whoops!), so shall I go for an alternative implementation?

@vmuzikar

vmuzikar commented Oct 4, 2023

Copy link
Copy Markdown
Contributor

shall I go for an alternative implementation?

+1 from me

@shawkins

shawkins commented Oct 4, 2023

Copy link
Copy Markdown
Contributor

You mean upgrading to the micro will cause the restart? It will trigger a restart in any case to roll the new image.

Just to make sure I'm following you, are you saying that every release of the operator will be accompanied by a different keycloak image?

@pgodowski

pgodowski commented Oct 4, 2023

Copy link
Copy Markdown

You mean upgrading to the micro will cause the restart? It will trigger a restart in any case to roll the new image.

Just to make sure I'm following you, are you saying that every release of the operator will be accompanied by a different keycloak image?

Let me ask a question - I thought that the operator <-> operand is 1:1 currently, and every time there is (even a security update) of the operator, it means that there is also updated operand image. For example, UBI9 security updates are there in both operator and operands.

So, isn't it that ALWAYS when operator is updated, operand also will be updated, thru the rolling update?

Otherwise, the Keycloak CR would need to have something like .spec.version indicating the exact version of the operand image to use. Currently I see that operator can cope with single operand image.

Having said that, what is wrong with the direct backport, i.e. is the only concern due to the rolling update of the operand?
(I do understand the motivation to lower the risk of introducing regression in the last runaway before the release - but can we assess where the risks are perhaps?)

@Jamstah
Jamstah force-pushed the backport-reconcile-fix branch from c70531f to 78821d1 Compare October 4, 2023 21:47
@vmuzikar

vmuzikar commented Oct 5, 2023

Copy link
Copy Markdown
Contributor

Just to make sure I'm following you, are you saying that every release of the operator will be accompanied by a different keycloak image?

Yes, the release processes of Operator and Operand are now 100% aligned. We can't release new Keycloak version without releasing a new Operator version and vice versa.

Having said that, what is wrong with the direct backport, i.e. is the only concern due to the rolling update of the operand?
(I do understand the motivation to lower the risk of introducing regression in the last runaway before the release - but can we assess where the risks are perhaps?)

I see the risk in the potential regressions. #21162 significantly changed how we handle watching Secrets. This change has not yet been released in any Keycloak version, just nightlies. We have integration tests of course, but there's always risk we missed something. And from my perspective it's safer to release something like that in a major version than risk breaking stuff in micro release (just before a major prod release). And I see less risk in creating a smaller targeted fix just for #22404.

…ent (keycloak#22404)

* allows normal reconciliation to continue even if secrets are not present

Closes keycloak#22170

* adds polling if any secret (in particular optional) is not present

Closes keycloak#22170
@Jamstah
Jamstah force-pushed the backport-reconcile-fix branch from 78821d1 to 14bc5c8 Compare October 5, 2023 11:54

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unreported flaky test detected, please review

@ghost

ghost commented Oct 5, 2023

Copy link
Copy Markdown

Unreported flaky test detected

If the below flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.webauthn.account.WebAuthnTransportLocaleTest#localizationTransportUSB

Keycloak CI - WebAuthn IT (chrome)

java.lang.AssertionError: Expected OIDCLogin but was  (https://localhost:8543/auth/realms/test/protocol/openid-connect/auth?client_id=account-console&redirect_uri=https%3A%2F%2Flocalhost%3A8543%2Fauth%2Frealms%2Ftest%2Faccount%2F%23%2Fsecurity%2Fsigningin&state=5775c4d3-b5b8-4034-a987-1f751ca46d9e&response_mode=fragment&response_type=code&scope=openid&nonce=7520efb8-3462-4098-b8da-50ec8a620ecf&code_challenge=gsD4llxxzug04eg1UECSqa73yMieW_Gx22JhkRo9sRc&code_challenge_method=S256)
	at org.junit.Assert.fail(Assert.java:89)
	at org.junit.Assert.assertTrue(Assert.java:42)
	at org.keycloak.testsuite.page.AbstractPage.assertCurrent(AbstractPage.java:110)
	at jdk.internal.reflect.GeneratedMethodAccessor627.invoke(Unknown Source)
...

Report flaky test

@Jamstah

Jamstah commented Oct 5, 2023

Copy link
Copy Markdown
Contributor Author

Looking at the failure on 22.0, it's actually crashing because it can't find the secret and then giving up on reconcile because it crashed too much. I think that's a different cause (although the same symptoms).

I have a more targetted fix coming in a second pr, just letting the tests run this time :)

@Jamstah

Jamstah commented Oct 5, 2023

Copy link
Copy Markdown
Contributor Author

Closing for a more targeted fix for 22.0 in #23741

@Jamstah Jamstah closed this Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants