@@ -158,9 +158,6 @@ func ensureOwnerReference(meta *metav1.ObjectMeta, owner *metav1.OwnerReference)
158
158
func needNewSigningCertKeyPair (secret * corev1.Secret , refresh time.Duration , refreshOnlyWhenExpired bool ) (bool , string ) {
159
159
annotations := secret .Annotations
160
160
notBefore , notAfter , reason := getValidityFromAnnotations (annotations )
161
- if len (reason ) > 0 {
162
- return true , reason
163
- }
164
161
165
162
if time .Now ().After (notAfter ) {
166
163
return true , "already expired"
@@ -170,6 +167,10 @@ func needNewSigningCertKeyPair(secret *corev1.Secret, refresh time.Duration, ref
170
167
return false , ""
171
168
}
172
169
170
+ if len (reason ) > 0 {
171
+ return true , reason
172
+ }
173
+
173
174
validity := notAfter .Sub (notBefore )
174
175
at80Percent := notAfter .Add (- validity / 5 )
175
176
if time .Now ().After (at80Percent ) {
@@ -191,15 +192,15 @@ func getValidityFromAnnotations(annotations map[string]string) (notBefore time.T
191
192
}
192
193
notAfter , err := time .Parse (time .RFC3339 , notAfterString )
193
194
if err != nil {
194
- return notBefore , notAfter , fmt .Sprintf ("bad expiry: %q" , notAfterString )
195
+ return notBefore , notAfter , fmt .Sprintf ("bad notAfter expiry: %q" , notAfterString )
195
196
}
196
197
notBeforeString := annotations [CertificateNotBeforeAnnotation ]
197
- if len (notAfterString ) == 0 {
198
+ if len (notBeforeString ) == 0 {
198
199
return notBefore , notAfter , "missing notBefore"
199
200
}
200
201
notBefore , err = time .Parse (time .RFC3339 , notBeforeString )
201
202
if err != nil {
202
- return notBefore , notAfter , fmt .Sprintf ("bad expiry: %q" , notBeforeString )
203
+ return notBefore , notAfter , fmt .Sprintf ("bad notBefore expiry: %q" , notBeforeString )
203
204
}
204
205
205
206
return notBefore , notAfter , ""
0 commit comments