Don't fire an event when the Denied ready condition is set
Signed-off-by: joshvanl <vleeuwenjoshua@gmail.com>
This commit is contained in:
parent
9a5e36e732
commit
ff3e4bb07d
@ -67,14 +67,6 @@ func (r *Reporter) Denied(cr *cmapi.CertificateRequest) {
|
||||
}
|
||||
|
||||
message := "The CertificateRequest was denied by an approval controller"
|
||||
|
||||
// If RequestDenied condition not already set then fire a RequestDenied
|
||||
// Event. This is to reduce strain on the API server and avoid rate limiting
|
||||
// ourselves for Event creation.
|
||||
if apiutil.CertificateRequestReadyReason(cr) != cmapi.CertificateRequestReasonDenied {
|
||||
r.recorder.Event(cr, corev1.EventTypeWarning, cmapi.CertificateRequestReasonDenied, message)
|
||||
}
|
||||
|
||||
apiutil.SetCertificateRequestCondition(cr, cmapi.CertificateRequestConditionReady,
|
||||
cmmeta.ConditionFalse, cmapi.CertificateRequestReasonDenied, message)
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ func TestReporter(t *testing.T) {
|
||||
|
||||
deniedReadyCondition := cmapi.CertificateRequestCondition{
|
||||
Type: cmapi.CertificateRequestConditionReady,
|
||||
Reason: "RequestDenied",
|
||||
Reason: "Denied",
|
||||
Message: "The CertificateRequest was denied by an approval controller",
|
||||
Status: "False",
|
||||
LastTransitionTime: &nowMetaTime,
|
||||
@ -213,18 +213,16 @@ func TestReporter(t *testing.T) {
|
||||
call: "ready",
|
||||
},
|
||||
|
||||
"a denied report should update the conditions and send an event": {
|
||||
certificateRequest: gen.CertificateRequestFrom(baseCR),
|
||||
expectedEvents: []string{
|
||||
"Warning RequestDenied The CertificateRequest was denied by an approval controller",
|
||||
},
|
||||
"a denied report should update the Ready condition to 'Denied'": {
|
||||
certificateRequest: gen.CertificateRequestFrom(baseCR),
|
||||
expectedEvents: []string{},
|
||||
expectedConditions: []cmapi.CertificateRequestCondition{deniedReadyCondition},
|
||||
expectedFailureTime: &nowMetaTime,
|
||||
|
||||
call: "denied",
|
||||
},
|
||||
|
||||
"a denied report should update the conditions and send an event, but not update failure time or send event if existing": {
|
||||
"a denied report should update the Ready condition to 'Denied', but not update failure time existing": {
|
||||
certificateRequest: gen.CertificateRequestFrom(baseCR,
|
||||
gen.SetCertificateRequestStatusCondition(deniedReadyCondition),
|
||||
gen.SetCertificateRequestFailureTime(oldMetaTime),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user