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: cert-manager duration expects XhYmZs format #273

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

gozer
Copy link

@gozer gozer commented Jul 9, 2024

It accepts shorter format like Yh, but the mutating webhook, if
installed/enabled will convert it to the full format, causing potential
endless reconciliation loops with tools like ArgoCD

Fixes #190

@gozer gozer requested a review from a team as a code owner July 9, 2024 02:02
@gozer gozer force-pushed the gozer/20240708/cert-manager-duration branch from 4f2b90f to e3bc7c7 Compare July 9, 2024 02:03
It accepts shorter format like Yh, but the mutating webhook, if
installed/enabled will convert it to the full format, causing potential
endless reconciliation loops with tools like ArgoCD

Fixes topolvm#190

Signed-off-by: Philippe M. Chiasson <gozer@ectoplasm.org>
Signed-off-by: Philippe M. Chiasson <gozer@lacework.net>
@gozer gozer force-pushed the gozer/20240708/cert-manager-duration branch from e3bc7c7 to 054bff2 Compare July 9, 2024 02:04
@llamerada-jp
Copy link
Contributor

llamerada-jp commented Jul 10, 2024

if installed/enabled will convert it to the full format, causing potential endless reconciliation loops with tools like ArgoCD

The reverse is also true, If there is a mutating webhook that converts to a shorter format, The change o this PR can cause endless reconcilation loop. I have checked and argocd works fine with both 87600h and 87600h0m0s descriptions. According to upstream's comment, the problem was fixed at v2.10 or later.
Would you please review the mutating webhook settings first, and if you can't avoid the problem, change it so that it can handle both formats.

@gozer
Copy link
Author

gozer commented Jul 10, 2024

The reverse is also true, If there is a mutating webhook that converts to a shorter format, The change to this PR can cause endless reconcilation loop. I have checked and argocd works fine with both 87600h and 87600h0m0s descriptions.

The issue isn't with ArgoCD itself, but rather with cert-manager itself, it requires durations to be in that format, and it's cert-manager's own mutating webhook controller that makes this conversion transparently.

So, technically, a Certificate spec.duration field needs to be in this format to be correct, this this PR

@llamerada-jp
Copy link
Contributor

Thanks for letting me know.

I tried to check the output format of cert-manager for the review, but I could not see the above behavior in my environment. It may be a difference in versions, so please tell me which version you tested. Or do I need any options for cert-manager?

@gozer
Copy link
Author

gozer commented Jul 11, 2024

Thanks for letting me know.

No worries!

I tried to check the output format of cert-manager for the review, but I could not see the above behavior in my environment. It may be a difference in versions, so please tell me which version you tested. Or do I need any options for cert-manager?

The validating/mutating webhook portion of cert-manager is an optional component.

I've seen it with cert-manager 1.13.3 as of now.

@llamerada-jp
Copy link
Contributor

I checked my environment, cert-manager is 1.14.4, and the webhook is enabled. Does your environment set additional options for webhooks?

I checked the cert-manager code, but could only find a webhook for the CertificateResuest custom resource and could not found logic for Certificate custom resource.
https://github.com/cert-manager/cert-manager/tree/master/internal/webhook/admission/certificaterequest

The validating/mutating webhook portion of cert-manager is an optional component.

Does this mean it is a external product?

@iflan7744
Copy link

@gozer I agree with your change, and I am also experiencing this issue when installing the chart via ArgoCD. One small suggestion: instead of hardcoding, it would be nice if we can call it via values.yaml, allowing people to modify it based on their requirements.

webhook:
  pvcMutatingWebhook:
    enabled: true
  certificate:
    generate: true
    caCertDuration: 87600h  # 10 years
    certDuration: 8760h     # 1 year

Copy link
Contributor

This pull request has been automatically marked as stale because it has not had any activity for 30 days. It will be closed in a week if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Aug 18, 2024
@gozer
Copy link
Author

gozer commented Aug 19, 2024

@gozer I agree with your change, and I am also experiencing this issue when installing the chart via ArgoCD. One small suggestion: instead of hardcoding, it would be nice if we can call it via values.yaml, allowing people to modify it based on their requirements.

Thanks! I didn't have time to dig down precisely where it's coming from so I can offer a reproductible test case. At least I am not alone.

And yes, making it a value makes a whole lot more sense. I'll fix the PR.

Via `controller.certificate.duration`

Signed-off-by: Philippe M. Chiasson <gozer@ectoplasm.org>
@gozer gozer force-pushed the gozer/20240708/cert-manager-duration branch from e116b33 to 18f8839 Compare August 19, 2024 12:55
Signed-off-by: Philippe M. Chiasson <gozer@ectoplasm.org>
@gozer gozer force-pushed the gozer/20240708/cert-manager-duration branch from 10d3548 to 52ce7dc Compare August 19, 2024 12:57
@github-actions github-actions bot removed the stale label Aug 19, 2024
@toshipp
Copy link
Contributor

toshipp commented Aug 20, 2024

@gozer
Please check and answer @llamerada-jp's question. We can not approve this unless it is reasonable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Review in progress
Development

Successfully merging this pull request may close these issues.

ArgoCD sync trying convert 87600h0m0s back to 87600h
4 participants