Populate reason field regardless

If we have an error, then tell people about it.

Signed-off-by: Daniel Morsing <dmo@jetstack.io>
This commit is contained in:
Daniel Morsing 2019-01-10 14:54:43 +00:00
parent 1b921b1583
commit cc946c0b45
2 changed files with 18 additions and 20 deletions

View File

@ -224,16 +224,15 @@ func (c *Controller) syncChallengeStatus(ctx context.Context, cl acmecl.Interfac
// TODO: should we validate the State returned by the ACME server here?
cmState := cmapi.State(acmeChallenge.Status)
if cmState == cmapi.Invalid {
// be nice to our users and check if there is an error that we
// can tell them about in the reason field
// TODO(dmo): problems may be compound and they may be tagged with
// a type field that suggests changes we should make (like provisioning
// an account). We might be able to handle errors more gracefully using
// this info
if acmeChallenge.Error != nil {
ch.Status.Reason = acmeChallenge.Error.Detail
}
// be nice to our users and check if there is an error that we
// can tell them about in the reason field
// TODO(dmo): problems may be compound and they may be tagged with
// a type field that suggests changes we should make (like provisioning
// an account). We might be able to handle errors more gracefully using
// this info
ch.Status.Reason = ""
if acmeChallenge.Error != nil {
ch.Status.Reason = acmeChallenge.Error.Detail
}
ch.Status.State = cmState

View File

@ -452,16 +452,15 @@ func buildChallenge(i int, o *cmapi.Order, chalSpec cmapi.ChallengeSpec) *cmapi.
func (c *Controller) setOrderStatus(o *cmapi.OrderStatus, acmeOrder *acmeapi.Order) {
// TODO: should we validate the State returned by the ACME server here?
cmState := cmapi.State(acmeOrder.Status)
if cmState == cmapi.Invalid {
// be nice to our users and check if there is an error that we
// can tell them about in the reason field
// TODO(dmo): problems may be compound and they may be tagged with
// a type field that suggests changes we should make (like provisioning
// an account). We might be able to handle errors more gracefully using
// this info
if acmeOrder.Error != nil {
o.Reason = acmeOrder.Error.Detail
}
// be nice to our users and check if there is an error that we
// can tell them about in the reason field
// TODO(dmo): problems may be compound and they may be tagged with
// a type field that suggests changes we should make (like provisioning
// an account). We might be able to handle errors more gracefully using
// this info
o.Reason = ""
if acmeOrder.Error != nil {
o.Reason = acmeOrder.Error.Detail
}
c.setOrderState(o, cmState)