Skip to content

cert rotation not happening when expiryTime and cron scheduled run are equal #212

@junaid-ali

Description

@junaid-ali

Before() function , that we are using here, compares if a time has happened before the time provided as the argument and returns false if both times are equal.

nextRun := cronSchedule.Next(time.Now())
if expiryTime.Before(nextRun) {
return true, "Certificate about to expire, rotating certificate"
}

We need to trigger cert rotation before/equals/close to actual cert expiration. For that we can compare expiryTime with nextRun using Sub() function.

Also, we came across with a case while rotating root cert every month, helm chart calculated the cronStr as 0 0 */23 * * (i.e. cron gets executed every 1st and 23rd day of the month). Our certificate didn't get rotated and was due expiration on 7th day of the month. Rotation didn't happen by the cronjob that ran on the 1st day of the month and the next run is in 23 days while the certificate is expiring in 6 days. So, to avoid this issue, we should also calculate if the cert is expiring before next-to-next cronjob run.

Jira issue: HELM-28

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions