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

Simplify Ca and CaReconciler logic #10809

Merged
merged 2 commits into from
Nov 21, 2024
Merged

Conversation

katheris
Copy link
Contributor

@katheris katheris commented Nov 6, 2024

Type of change

Select the type of your PR

  • Refactoring

Description

Simplify Ca and CaReconciler logic:

  1. Remove code in CaReconciler that is never being executed.
  2. Move Secret existence checking from CaReconciler to Ca.

Here are fuller explanations of why I did the refactors.

1
Today logRenewalState() in Ca.java is only called from inside shouldCreateOrRenew(), and shouldCreateOrRenew() is only called from createRenewOrReplace() and only when generateCa is true. Therefore any code in logRenewalState() that is only executed when generateCa is false is never executed. To further simplify the code I removed logRenewalState() completely and moved the code that is executed inside shouldCreateOrRenew().

2
Today createRenewOrReplace() in Ca.java is only called (excluding test classes) from CaReconciler.java, once for the ClusterCA and once for the ClientsCA. Prior to that call we call checkCustomCaSecret() to verify the Secret exists. Then inside Ca.java we have additional logic to handle the case where the Secrets are null. I moved the verification logic into Ca.java to simplify the code.

Checklist

Please go through this checklist and make sure all applicable tasks have been done

  • Write tests
  • Make sure all tests pass
  • Update documentation
  • Check RBAC rights for Kubernetes / OpenShift roles
  • Try your changes from Pod inside your Kubernetes and OpenShift cluster, not just locally
  • Reference relevant issue(s) and close them after merging
  • Update CHANGELOG.md
  • Supply screenshots for visual changes, such as Grafana dashboards

@katheris katheris added this to the 0.45.0 milestone Nov 6, 2024
* Remove code in CaReconciler that is
never being executed.
* Move Secret existence checking from
CaReconciler to Ca.

Signed-off-by: Katherine Stanley <11195226+katheris@users.noreply.github.com>
Copy link
Member

@ppatierno ppatierno 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!

@ppatierno
Copy link
Member

/azp run regression

@ppatierno ppatierno requested a review from scholzj November 7, 2024 11:19
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@tinaselenge tinaselenge left a comment

Choose a reason for hiding this comment

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

LGTM :)

@ppatierno
Copy link
Member

@scholzj do you have any plan to review this one or I can proceed by merging it? Thanks!

@scholzj
Copy link
Member

scholzj commented Nov 18, 2024

I do plan to review it when I get back.

Copy link
Member

@scholzj scholzj left a comment

Choose a reason for hiding this comment

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

I left some nits.

Signed-off-by: Katherine Stanley <11195226+katheris@users.noreply.github.com>
@scholzj
Copy link
Member

scholzj commented Nov 21, 2024

/azp run zookeeper-regression

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@scholzj scholzj merged commit 6ba9cc5 into strimzi:main Nov 21, 2024
21 checks passed
OwenCorrigan76 pushed a commit to OwenCorrigan76/strimzi-kafka-operator that referenced this pull request Dec 6, 2024
Signed-off-by: Katherine Stanley <11195226+katheris@users.noreply.github.com>
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.

5 participants