Skip to content

Conversation

@ArkaSaha30
Copy link
Contributor

@ArkaSaha30 ArkaSaha30 commented Dec 14, 2025

This PR will handle a scenario of invalid ValidityDuration user input for the following certificate providers and throw an error.
In case ValidityDuration is not defined by the user, it will default to the corresponding default values:

  • Cert-manager Provider, default 90days
  • Auto Provider, default 365days

Fixes: #251

@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ArkaSaha30
Once this PR has been reviewed and has the lgtm label, please assign jberkus for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ArkaSaha30
Copy link
Contributor Author

cc @neolit123

@ArkaSaha30 ArkaSaha30 force-pushed the fix-cert-duration-check branch 2 times, most recently from 783c3dc to e6346e5 Compare December 15, 2025 05:05
@ArkaSaha30
Copy link
Contributor Author

/test pull-etcd-operator-test-e2e

Comment on lines 613 to 622
// Set default duration to 365 days for auto provider if not provided
var duration time.Duration
if autoConfig.ValidityDuration == "" {
duration = certInterface.DefaultAutoValidity
} else {
var err error
duration, err = time.ParseDuration(autoConfig.ValidityDuration)
if err != nil {
return nil, fmt.Errorf("failed to parse ValidityDuration: %w", err)
}
Copy link
Member

Choose a reason for hiding this comment

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

Please add a function something like below, and reuse it for both createCMCertificateConfig and createAutoCertificateConfig

func parseValidityDuration(customizedDuration string, defaultDuration time.Duration) (time.Duration, error)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, updated the PR.

@ivanvc ivanvc self-requested a review January 6, 2026 19:15
Copy link
Member

@ivanvc ivanvc left a comment

Choose a reason for hiding this comment

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

Thanks for the pull request, Arka. Other than Benjamin's comment and one observation I left, this looks great :)

log.Printf("calling SelfCert with hosts: %v", hosts)

tlsInfo, selfCertErr := transport.SelfCert(zap.NewNop(), tmpDir, hosts, uint(validity/DefaultValidity))
tlsInfo, selfCertErr := transport.SelfCert(zap.NewNop(), tmpDir, hosts, uint(validity/interfaces.DefaultAutoValidity))
Copy link
Member

Choose a reason for hiding this comment

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

I think that dividing by interfaces.DefaultAutoValidity may be error-prone in the future (i.e., if someone changes the DefaultAutoValidity to anything other than one year). I think this division needs to be fixed to be by 365 * 24 * time.Hour, as transport.SelfCert(...) expects this to be years.

It could be another constant defined in this function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, updated the PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll debug and fix the failing test as well

This commit will handle a scenario of invalid cert-manager ValidityDuration user input
and throw an error.
In case, ValidityDuration is not defined by user it will default to 90days for cert-manager

Signed-off-by: ArkaSaha30 <[email protected]>
@ArkaSaha30 ArkaSaha30 force-pushed the fix-cert-duration-check branch from e6346e5 to 4adafe5 Compare January 11, 2026 15:47
This commit will handle a scenario of invalid auto cert provider ValidityDuration user input
and throw an error.
In case, ValidityDuration is not defined by user it will default to 365days for auto cert provider

Signed-off-by: ArkaSaha30 <[email protected]>
@ArkaSaha30 ArkaSaha30 force-pushed the fix-cert-duration-check branch from 4adafe5 to 4d9d86c Compare January 11, 2026 18:08
Signed-off-by: ArkaSaha30 <[email protected]>
@k8s-ci-robot
Copy link

@ArkaSaha30: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-etcd-operator-test-e2e f7a0e41 link true /test pull-etcd-operator-test-e2e

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor certificate management code bits

4 participants