Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ahus1
Copy link
Contributor

@ahus1 ahus1 commented Jun 28, 2024

Closes #30924

@ahus1
Copy link
Contributor Author

ahus1 commented Jul 4, 2024

@shawkins - I'm struggling with this change as after using the port name, the Operator can't update a custom Ingress which has only the port number specified. It then throws the error "cannot set both port name & port number".

What is the recommended way to handle this with server-side-apply? IMHO the Ingress is missing an annotation in the Go code of Kubernetes to make this work, and I've opened an upstream issue for that: kubernetes/kubernetes#125869

Still this won't solve my problem short term. So I wonder:

  • Is there a simple fix for that?
  • Should the Ingress be deleted and re-created in this case? Where would I put such code?
  • Should I abandon this PR altogether? The initial trigger was to work around a bug in the nginx ingress, see field ingress.spec.defaultBackend.service.port.number is broken kubernetes/ingress-nginx#11517 were I don't know how many people it affects. At the same time the current code might fail if there is a custom ingress which uses a port name, and the Operator would then have a problem changing it to a port number.

Thanks!

@shawkins
Copy link
Contributor

shawkins commented Jul 5, 2024

I'm struggling with this change as after using the port name, the Operator can't update a custom Ingress which has only the port number specified. It then throws the error "cannot set both port name & port number".

I've logged upstream issues related to this, but for services. SSA does not use the same rules as merge patches, so it's easier for it to get in a situation where the patch is invalid.

Is there a simple fix for that?

Let me check.

Should the Ingress be deleted and re-created in this case? Where would I put such code?

Ideally not, but in some cases we don't have a choice - such as changing a immutable field like statefulset match labels.

If a regular merge patch will work, it would probably be just as easy to use an override to do that patch instead of deleting.

At the same time the current code might fail if there is a custom ingress which uses a port name, and the Operator would then have a problem changing it to a port number.

If the user creates the ingress and it lacks the owner reference for the operator, the operator will not manage it - if it has the same name as the managed ingress and the user has not turned off ingress handling in the keycloak cr, then we'll throw an exception when we try to create the managed version.

@shawkins
Copy link
Contributor

shawkins commented Jul 5, 2024

Let me check.

I committed a possible workaround to repeat the update as a regular patch.

@ahus1 ahus1 force-pushed the is-30924-use-port-name-on-ingress branch from 67d95df to c5f309a Compare July 8, 2024 14:12
@ahus1 ahus1 marked this pull request as ready for review July 8, 2024 16:17
@ahus1 ahus1 requested review from a team as code owners July 8, 2024 16:17
@ahus1 ahus1 requested a review from shawkins July 8, 2024 16:17
@ahus1
Copy link
Contributor Author

ahus1 commented Jul 8, 2024

@shawkins - thank you for your contribution. I've updated this PR to apply the client side work a bit more broader in a way that you suggested in your commit. I didn't want to catch all KubernetesClientExceptions as that seems to be a bit broad to me.

Please let me know your thoughts in a review, and also decide if someone else from the CND team should review it as well.

Thanks!

shawkins
shawkins previously approved these changes Jul 8, 2024
Copy link
Contributor

@shawkins shawkins left a comment

Choose a reason for hiding this comment

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

I didn't want to catch all KubernetesClientExceptions as that seems to be a bit broad to me.

I think this looks good, but it still might be better to look at the code for the KubernetesClientException, rather than the message - that should be more stable as that will come directly from the api server.

@shawkins shawkins requested a review from Pepo48 July 8, 2024 18:33
Pepo48
Pepo48 previously approved these changes Jul 8, 2024
Copy link
Contributor

@Pepo48 Pepo48 left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you both.

@ahus1 ahus1 dismissed stale reviews from Pepo48 and shawkins via 376d171 July 9, 2024 10:38
@ahus1 ahus1 force-pushed the is-30924-use-port-name-on-ingress branch from c5f309a to 376d171 Compare July 9, 2024 10:38
@ahus1
Copy link
Contributor Author

ahus1 commented Jul 9, 2024

@shawkins - thank you for pointing me at the "code". I didn't know about it and it is a lot cleaner.

I've updated the commit. If the build is green, it should be ready for review.

Also adding a retry if server-side-apply fails

Closes keycloak#30924

Co-authored-by: Steven Hawkins <[email protected]>
Signed-off-by: Alexander Schwartz <[email protected]>
@shawkins shawkins force-pushed the is-30924-use-port-name-on-ingress branch from cfe3cc9 to a5dbf80 Compare July 9, 2024 17:11
@shawkins shawkins self-requested a review July 9, 2024 19:00
Copy link
Contributor

@shawkins shawkins left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @ahus1

@Pepo48 do you want one more look?

@shawkins shawkins merged commit bebb314 into keycloak:main Jul 10, 2024
samsara-lab pushed a commit to samsara-lab/keycloak-31197 that referenced this pull request Jul 14, 2024
Also adding a retry if server-side-apply fails

Closes keycloak#30924

Signed-off-by: Alexander Schwartz <[email protected]>
Co-authored-by: Steven Hawkins <[email protected]>
Signed-off-by: Pavel Borisenko <[email protected]>
Captain-P-Goldfish pushed a commit to Captain-P-Goldfish/keycloak that referenced this pull request Jul 17, 2024
Also adding a retry if server-side-apply fails

Closes keycloak#30924

Signed-off-by: Alexander Schwartz <[email protected]>
Co-authored-by: Steven Hawkins <[email protected]>
stianst pushed a commit to stianst/keycloak that referenced this pull request Jul 25, 2024
Also adding a retry if server-side-apply fails

Closes keycloak#30924

Signed-off-by: Alexander Schwartz <[email protected]>
Co-authored-by: Steven Hawkins <[email protected]>
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.

Keycloak Operator should use the port name and not the port number for the ingress

3 participants