Skip to content

Commit 576d96f

Browse files
committed
certrotation: update reasons in getValidityFromAnnotations
1 parent db1a930 commit 576d96f

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

pkg/operator/certrotation/signer.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ func ensureOwnerReference(meta *metav1.ObjectMeta, owner *metav1.OwnerReference)
158158
func needNewSigningCertKeyPair(secret *corev1.Secret, refresh time.Duration, refreshOnlyWhenExpired bool) (bool, string) {
159159
annotations := secret.Annotations
160160
notBefore, notAfter, reason := getValidityFromAnnotations(annotations)
161+
161162
if len(reason) > 0 {
162163
return true, reason
163164
}
@@ -191,15 +192,15 @@ func getValidityFromAnnotations(annotations map[string]string) (notBefore time.T
191192
}
192193
notAfter, err := time.Parse(time.RFC3339, notAfterString)
193194
if err != nil {
194-
return notBefore, notAfter, fmt.Sprintf("bad expiry: %q", notAfterString)
195+
return notBefore, notAfter, fmt.Sprintf("bad notAfter expiry: %q", notAfterString)
195196
}
196197
notBeforeString := annotations[CertificateNotBeforeAnnotation]
197-
if len(notAfterString) == 0 {
198+
if len(notBeforeString) == 0 {
198199
return notBefore, notAfter, "missing notBefore"
199200
}
200201
notBefore, err = time.Parse(time.RFC3339, notBeforeString)
201202
if err != nil {
202-
return notBefore, notAfter, fmt.Sprintf("bad expiry: %q", notBeforeString)
203+
return notBefore, notAfter, fmt.Sprintf("bad notBefore expiry: %q", notBeforeString)
203204
}
204205

205206
return notBefore, notAfter, ""

pkg/operator/certrotation/target_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ package certrotation
33
import (
44
"context"
55
"crypto/x509/pkix"
6-
clocktesting "k8s.io/utils/clock/testing"
76
"strings"
87
"testing"
98
"time"
109

10+
clocktesting "k8s.io/utils/clock/testing"
11+
1112
"github.com/davecgh/go-spew/spew"
1213

1314
"github.com/openshift/api/annotations"
@@ -64,7 +65,7 @@ func TestNeedNewTargetCertKeyPairForTime(t *testing.T) {
6465
return nowCert, nil
6566
},
6667
refresh: 50 * time.Minute,
67-
expected: `bad expiry: "malformed"`,
68+
expected: `bad notAfter expiry: "malformed"`,
6869
},
6970
{
7071
name: "past midpoint and cert is ready",

0 commit comments

Comments
 (0)