Skip to content

Commit f69766c

Browse files
gabo1208dprotaso
andauthored
Bubble up KCertificate Status Message when its not ready (#14496)
* basic change done kcert error bubbling up correctly, still need to fail when url is too long * Update pkg/apis/serving/v1/route_lifecycle.go Co-authored-by: Dave Protasowski <[email protected]> --------- Co-authored-by: Dave Protasowski <[email protected]>
1 parent 2c0b8dc commit f69766c

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed

pkg/apis/serving/v1/route_lifecycle.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,11 @@ func (rs *RouteStatus) MarkCertificateReady(name string) {
174174

175175
// MarkCertificateNotReady marks the RouteConditionCertificateProvisioned
176176
// condition to indicate that the Certificate is not ready.
177-
func (rs *RouteStatus) MarkCertificateNotReady(name string) {
177+
func (rs *RouteStatus) MarkCertificateNotReady(c *v1alpha1.Certificate) {
178+
certificateCondition := c.Status.GetCondition("Ready")
178179
routeCondSet.Manage(rs).MarkUnknown(RouteConditionCertificateProvisioned,
179180
"CertificateNotReady",
180-
"Certificate %s is not ready.", name)
181+
"Certificate %s is not ready: %s", c.Name, certificateCondition.GetReason())
181182
}
182183

183184
// MarkCertificateNotOwned changes the RouteConditionCertificateProvisioned

pkg/apis/serving/v1/route_lifecycle_test.go

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package v1
1818

1919
import (
20+
"strings"
2021
"testing"
2122
"time"
2223

@@ -438,11 +439,37 @@ func TestCertificateReady(t *testing.T) {
438439
func TestCertificateNotReady(t *testing.T) {
439440
r := &RouteStatus{}
440441
r.InitializeConditions()
441-
r.MarkCertificateNotReady("cert")
442+
r.MarkCertificateNotReady(&netv1alpha1.Certificate{})
442443

443444
apistest.CheckConditionOngoing(r, RouteConditionCertificateProvisioned, t)
444445
}
445446

447+
func TestCertificateNotReadyWithBubbledUpMessage(t *testing.T) {
448+
cert := &netv1alpha1.Certificate{
449+
Status: netv1alpha1.CertificateStatus{
450+
Status: duckv1.Status{
451+
Conditions: duckv1.Conditions{
452+
{
453+
Type: "Ready",
454+
Status: "False",
455+
Reason: "CommonName Too Long",
456+
},
457+
},
458+
},
459+
},
460+
}
461+
462+
r := &RouteStatus{}
463+
r.InitializeConditions()
464+
r.MarkCertificateNotReady(cert)
465+
466+
expectedCertMessage := "CommonName Too Long"
467+
certMessage := r.Status.GetCondition("Ready").Message
468+
if !strings.Contains(certMessage, expectedCertMessage) {
469+
t.Errorf("Literal %q not found in status message: %q", expectedCertMessage, certMessage)
470+
}
471+
}
472+
446473
func TestCertificateProvisionFailed(t *testing.T) {
447474
r := &RouteStatus{}
448475
r.InitializeConditions()

pkg/reconciler/route/route.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ func (c *Reconciler) tls(ctx context.Context, host string, r *v1.Route, traffic
265265
tls = append(tls, resources.MakeIngressTLS(cert, dnsNames.List()))
266266
} else {
267267
acmeChallenges = append(acmeChallenges, cert.Status.HTTP01Challenges...)
268-
r.Status.MarkCertificateNotReady(cert.Name)
268+
r.Status.MarkCertificateNotReady(cert)
269269
// When httpProtocol is enabled, downgrade http scheme.
270270
// Explicitly not using the override settings here as to not to muck with
271271
// external-domain-tls semantics.

pkg/testing/v1/route.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ func MarkUnknownTrafficError(msg string) RouteOption {
208208

209209
// MarkCertificateNotReady calls the method of the same name on .Status
210210
func MarkCertificateNotReady(r *v1.Route) {
211-
r.Status.MarkCertificateNotReady(routenames.Certificate(r))
211+
r.Status.MarkCertificateNotReady(&netv1alpha1.Certificate{})
212212
}
213213

214214
// MarkCertificateNotOwned calls the method of the same name on .Status

0 commit comments

Comments
 (0)