Include Order failure reason as part of CertificateRequest failure message
Signed-off-by: James Munnelly <james@munnelly.eu>
This commit is contained in:
parent
8867a35cb1
commit
ec44d8992c
@ -161,12 +161,9 @@ func (a *ACME) Sign(ctx context.Context, cr *v1alpha2.CertificateRequest, issuer
|
||||
|
||||
// If the acme order has failed then so too does the CertificateRequest meet the same fate.
|
||||
if acme.IsFailureState(order.Status.State) {
|
||||
message := fmt.Sprintf("Failed to wait for order resource %s/%s to become ready",
|
||||
expectedOrder.Namespace, expectedOrder.Name)
|
||||
err := fmt.Errorf("order is in %q state", order.Status.State)
|
||||
|
||||
message := fmt.Sprintf("Failed to wait for order resource %q to become ready", expectedOrder.Name)
|
||||
err := fmt.Errorf("order is in %q state: %s", order.Status.State, order.Status.Reason)
|
||||
a.reporter.Failed(cr, err, "OrderFailed", message)
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
||||
@ -289,11 +289,12 @@ func TestSign(t *testing.T) {
|
||||
certificateRequest: baseCR.DeepCopy(),
|
||||
builder: &testpkg.Builder{
|
||||
ExpectedEvents: []string{
|
||||
`Warning OrderFailed Failed to wait for order resource default-unit-test-ns/test-cr-3921610499 to become ready: order is in "invalid" state`,
|
||||
`Warning OrderFailed Failed to wait for order resource "test-cr-3921610499" to become ready: order is in "invalid" state: simulated failure`,
|
||||
},
|
||||
CertManagerObjects: []runtime.Object{baseCR.DeepCopy(), baseIssuer.DeepCopy(),
|
||||
gen.OrderFrom(baseOrder,
|
||||
gen.SetOrderState(cmacme.Invalid),
|
||||
gen.SetOrderReason("simulated failure"),
|
||||
),
|
||||
},
|
||||
ExpectedActions: []testpkg.Action{
|
||||
@ -306,7 +307,7 @@ func TestSign(t *testing.T) {
|
||||
Type: cmapi.CertificateRequestConditionReady,
|
||||
Status: cmmeta.ConditionFalse,
|
||||
Reason: cmapi.CertificateRequestReasonFailed,
|
||||
Message: `Failed to wait for order resource default-unit-test-ns/test-cr-3921610499 to become ready: order is in "invalid" state`,
|
||||
Message: `Failed to wait for order resource "test-cr-3921610499" to become ready: order is in "invalid" state: simulated failure`,
|
||||
LastTransitionTime: &metaFixedClockStart,
|
||||
}),
|
||||
gen.SetCertificateRequestFailureTime(metaFixedClockStart),
|
||||
|
||||
@ -66,6 +66,12 @@ func SetOrderState(s cmacme.State) OrderModifier {
|
||||
}
|
||||
}
|
||||
|
||||
func SetOrderReason(reason string) OrderModifier {
|
||||
return func(crt *cmacme.Order) {
|
||||
crt.Status.Reason = reason
|
||||
}
|
||||
}
|
||||
|
||||
func SetOrderStatus(s cmacme.OrderStatus) OrderModifier {
|
||||
return func(o *cmacme.Order) {
|
||||
o.Status = s
|
||||
|
||||
Loading…
Reference in New Issue
Block a user