Skip to content

Commit 3dfb273

Browse files
authored
add central event reasons to the log package (#7215)
1 parent f1bb8cb commit 3dfb273

File tree

18 files changed

+220
-202
lines changed

18 files changed

+220
-202
lines changed

cmd/nginx-ingress/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ func updateSelfWithVersionInfo(ctx context.Context, eventLog record.EventRecorde
10681068
for key, value := range labels {
10691069
fmt.Fprintf(labelsString, "%s=\"%s\", ", key, value)
10701070
}
1071-
eventLog.Eventf(newPod, api_v1.EventTypeNormal, "UpdatePodLabel", "Successfully added version labels, %s", strings.TrimRight(labelsString.String(), ", "))
1071+
eventLog.Eventf(newPod, api_v1.EventTypeNormal, nl.EventReasonUpdatePodLabel, "Successfully added version labels, %s", strings.TrimRight(labelsString.String(), ", "))
10721072
nl.Infof(l, "Pod label updated: %s", pod.ObjectMeta.Name)
10731073
podUpdated = true
10741074
}

internal/certmanager/sync.go

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,6 @@ import (
4040
vsapi "github.com/nginx/kubernetes-ingress/pkg/apis/configuration/v1"
4141
)
4242

43-
const (
44-
reasonBadConfig = "BadConfig"
45-
reasonCreateCertificate = "CreateCertificate"
46-
reasonUpdateCertificate = "UpdateCertificate"
47-
reasonDeleteCertificate = "DeleteCertificate"
48-
)
49-
5043
var vsGVK = vsapi.SchemeGroupVersion.WithKind("VirtualServer")
5144

5245
// SyncFn is the reconciliation function passed to cert manager VS controller.
@@ -71,7 +64,7 @@ func SyncFnFor(
7164
issuerName, issuerKind, issuerGroup, err := issuerForVirtualServer(vs)
7265
if err != nil {
7366
nl.Errorf(l, "Failed to determine issuer to be used for VirtualServer resource: %v", err)
74-
rec.Eventf(vs, corev1.EventTypeWarning, reasonBadConfig, "Could not determine issuer for virtual server due to bad config: %s",
67+
rec.Eventf(vs, corev1.EventTypeWarning, nl.EventReasonBadConfig, "Could not determine issuer for virtual server due to bad config: %s",
7568
err)
7669
return err
7770
}
@@ -81,7 +74,7 @@ func SyncFnFor(
8174
newCrts, updateCrts, err := buildCertificates(ctx, nsi.cmLister, vs, issuerName, issuerKind, issuerGroup)
8275
if err != nil {
8376
nl.Errorf(l, "Incorrect cert-manager configuration for VirtualServer resource: %v", err)
84-
rec.Eventf(vs, corev1.EventTypeWarning, reasonBadConfig, "Incorrect cert-manager configuration for VirtualServer resource: %s",
77+
rec.Eventf(vs, corev1.EventTypeWarning, nl.EventReasonBadConfig, "Incorrect cert-manager configuration for VirtualServer resource: %s",
8578
err)
8679
return err
8780
}
@@ -90,22 +83,22 @@ func SyncFnFor(
9083
_, err := cmClient.CertmanagerV1().Certificates(crt.Namespace).Create(ctx, crt, metav1.CreateOptions{})
9184
if err != nil {
9285
nl.Errorf(l, "Error issuing Certificate for VirtualServer resource: %v", err)
93-
rec.Eventf(vs, corev1.EventTypeWarning, reasonBadConfig, "Error issuing Certificate for VirtualServer resource: %s",
86+
rec.Eventf(vs, corev1.EventTypeWarning, nl.EventReasonBadConfig, "Error issuing Certificate for VirtualServer resource: %s",
9487
err)
9588
return err
9689
}
97-
rec.Eventf(vs, corev1.EventTypeNormal, reasonCreateCertificate, "Successfully created Certificate %q", crt.Name)
90+
rec.Eventf(vs, corev1.EventTypeNormal, nl.EventReasonCreateCertificate, "Successfully created Certificate %q", crt.Name)
9891
}
9992

10093
for _, crt := range updateCrts {
10194
_, err := cmClient.CertmanagerV1().Certificates(crt.Namespace).Update(ctx, crt, metav1.UpdateOptions{})
10295
if err != nil {
10396
nl.Errorf(l, "Error updating Certificate for VirtualServer resource: %v", err)
104-
rec.Eventf(vs, corev1.EventTypeWarning, reasonBadConfig, "Error updating Certificate for VirtualServer resource: %s",
97+
rec.Eventf(vs, corev1.EventTypeWarning, nl.EventReasonBadConfig, "Error updating Certificate for VirtualServer resource: %s",
10598
err)
10699
return err
107100
}
108-
rec.Eventf(vs, corev1.EventTypeNormal, reasonUpdateCertificate, "Successfully updated Certificate %q", crt.Name)
101+
rec.Eventf(vs, corev1.EventTypeNormal, nl.EventReasonUpdateCertificate, "Successfully updated Certificate %q", crt.Name)
109102
}
110103
var certs []*cmapi.Certificate
111104

@@ -121,7 +114,7 @@ func SyncFnFor(
121114
nl.Errorf(l, "Error deleting Certificate for VirtualServer resource: %v", err)
122115
return err
123116
}
124-
rec.Eventf(vs, corev1.EventTypeNormal, reasonDeleteCertificate, "Successfully deleted unrequired Certificate %q", certName)
117+
rec.Eventf(vs, corev1.EventTypeNormal, nl.EventReasonDeleteCertificate, "Successfully deleted unrequired Certificate %q", certName)
125118
}
126119

127120
return nil

internal/configs/configmaps.go

Lines changed: 44 additions & 45 deletions
Large diffs are not rendered by default.

internal/externaldns/sync.go

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,9 @@ import (
2323
)
2424

2525
const (
26-
reasonBadConfig = "BadConfig"
27-
reasonCreateDNSEndpoint = "CreateDNSEndpoint"
28-
reasonUpdateDNSEndpoint = "UpdateDNSEndpoint"
29-
recordTypeA = "A"
30-
recordTypeAAAA = "AAAA"
31-
recordTypeCNAME = "CNAME"
26+
recordTypeA = "A"
27+
recordTypeAAAA = "AAAA"
28+
recordTypeCNAME = "CNAME"
3229
)
3330

3431
var vsGVK = vsapi.SchemeGroupVersion.WithKind("VirtualServer")
@@ -54,7 +51,7 @@ func SyncFnFor(rec record.EventRecorder, client clientset.Interface, ig map[stri
5451
targets, recordType, err := getValidTargets(ctx, vs.Status.ExternalEndpoints)
5552
if err != nil {
5653
nl.Error(l, "Invalid external endpoint")
57-
rec.Eventf(vs, corev1.EventTypeWarning, reasonBadConfig, "Invalid external endpoint")
54+
rec.Eventf(vs, corev1.EventTypeWarning, nl.EventReasonBadConfig, "Invalid external endpoint")
5855
return err
5956
}
6057

@@ -63,7 +60,7 @@ func SyncFnFor(rec record.EventRecorder, client clientset.Interface, ig map[stri
6360
newDNSEndpoint, updateDNSEndpoint, err := buildDNSEndpoint(ctx, nsi.extdnslister, vs, targets, recordType)
6461
if err != nil {
6562
nl.Errorf(l, "incorrect DNSEndpoint config for VirtualServer resource: %s", err)
66-
rec.Eventf(vs, corev1.EventTypeWarning, reasonBadConfig, "Incorrect DNSEndpoint config for VirtualServer resource: %s", err)
63+
rec.Eventf(vs, corev1.EventTypeWarning, nl.EventReasonBadConfig, "Incorrect DNSEndpoint config for VirtualServer resource: %s", err)
6764
return err
6865
}
6966

@@ -80,11 +77,11 @@ func SyncFnFor(rec record.EventRecorder, client clientset.Interface, ig map[stri
8077
return fmt.Errorf("DNSEndpoint has already been created")
8178
}
8279
nl.Errorf(l, "Error creating DNSEndpoint for VirtualServer resource: %v", err)
83-
rec.Eventf(vs, corev1.EventTypeWarning, reasonBadConfig, "Error creating DNSEndpoint for VirtualServer resource %s", err)
80+
rec.Eventf(vs, corev1.EventTypeWarning, nl.EventReasonBadConfig, "Error creating DNSEndpoint for VirtualServer resource %s", err)
8481
return err
8582
}
86-
rec.Eventf(vs, corev1.EventTypeNormal, reasonCreateDNSEndpoint, "Successfully created DNSEndpoint %q", newDNSEndpoint.Name)
87-
rec.Eventf(dep, corev1.EventTypeNormal, reasonCreateDNSEndpoint, "Successfully created DNSEndpoint for VirtualServer %q", vs.Name)
83+
rec.Eventf(vs, corev1.EventTypeNormal, nl.EventReasonCreateDNSEndpoint, "Successfully created DNSEndpoint %q", newDNSEndpoint.Name)
84+
rec.Eventf(dep, corev1.EventTypeNormal, nl.EventReasonCreateDNSEndpoint, "Successfully created DNSEndpoint for VirtualServer %q", vs.Name)
8885
}
8986

9087
// Update existing DNSEndpoint object
@@ -93,11 +90,11 @@ func SyncFnFor(rec record.EventRecorder, client clientset.Interface, ig map[stri
9390
dep, err = client.ExternaldnsV1().DNSEndpoints(updateDNSEndpoint.Namespace).Update(ctx, updateDNSEndpoint, metav1.UpdateOptions{})
9491
if err != nil {
9592
nl.Errorf(l, "Error updating DNSEndpoint endpoint for VirtualServer resource: %v", err)
96-
rec.Eventf(vs, corev1.EventTypeWarning, reasonBadConfig, "Error updating DNSEndpoint for VirtualServer resource: %s", err)
93+
rec.Eventf(vs, corev1.EventTypeWarning, nl.EventReasonBadConfig, "Error updating DNSEndpoint for VirtualServer resource: %s", err)
9794
return err
9895
}
99-
rec.Eventf(vs, corev1.EventTypeNormal, reasonUpdateDNSEndpoint, "Successfully updated DNSEndpoint %q", updateDNSEndpoint.Name)
100-
rec.Eventf(dep, corev1.EventTypeNormal, reasonUpdateDNSEndpoint, "Successfully updated DNSEndpoint for VirtualServer %q", vs.Name)
96+
rec.Eventf(vs, corev1.EventTypeNormal, nl.EventReasonUpdateDNSEndpoint, "Successfully updated DNSEndpoint %q", updateDNSEndpoint.Name)
97+
rec.Eventf(dep, corev1.EventTypeNormal, nl.EventReasonUpdateDNSEndpoint, "Successfully updated DNSEndpoint for VirtualServer %q", vs.Name)
10198
}
10299
return nil
103100
}

internal/k8s/appprotect/app_protect_configuration.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import (
77
"sort"
88
"time"
99

10-
"github.com/nginx/kubernetes-ingress/pkg/apis/configuration/validation"
11-
1210
"github.com/nginx/kubernetes-ingress/internal/k8s/appprotectcommon"
11+
nl "github.com/nginx/kubernetes-ingress/internal/logger"
12+
"github.com/nginx/kubernetes-ingress/pkg/apis/configuration/validation"
1313

1414
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
1515
"k8s.io/apimachinery/pkg/runtime/schema"
@@ -354,7 +354,7 @@ func (ci *ConfigurationImpl) AddOrUpdatePolicy(policyObj *unstructured.Unstructu
354354
if err != nil {
355355
ci.Policies[resNsName] = policy
356356
return append(changes, Change{Op: Delete, Resource: policy}),
357-
append(problems, Problem{Object: policyObj, Reason: "Rejected", Message: err.Error()})
357+
append(problems, Problem{Object: policyObj, Reason: nl.EventReasonRejected, Message: err.Error()})
358358
}
359359
if ci.verifyPolicyAgainstUserSigs(policy) {
360360
ci.Policies[resNsName] = policy
@@ -364,7 +364,7 @@ func (ci *ConfigurationImpl) AddOrUpdatePolicy(policyObj *unstructured.Unstructu
364364
policy.ErrorMsg = missingUserSigErrorMsg
365365
ci.Policies[resNsName] = policy
366366
return append(changes, Change{Op: Delete, Resource: policy}),
367-
append(problems, Problem{Object: policyObj, Reason: "Rejected", Message: missingUserSigErrorMsg})
367+
append(problems, Problem{Object: policyObj, Reason: nl.EventReasonRejected, Message: missingUserSigErrorMsg})
368368
}
369369

370370
// AddOrUpdateLogConf adds or updates App Protect Log Configuration to App Protect Configuration
@@ -374,7 +374,7 @@ func (ci *ConfigurationImpl) AddOrUpdateLogConf(logconfObj *unstructured.Unstruc
374374
ci.LogConfs[resNsName] = logConf
375375
if err != nil {
376376
return append(changes, Change{Op: Delete, Resource: logConf}),
377-
append(problems, Problem{Object: logconfObj, Reason: "Rejected", Message: err.Error()})
377+
append(problems, Problem{Object: logconfObj, Reason: nl.EventReasonRejected, Message: err.Error()})
378378
}
379379
return append(changes, Change{Op: AddOrUpdate, Resource: logConf}), problems
380380
}
@@ -385,7 +385,7 @@ func (ci *ConfigurationImpl) AddOrUpdateUserSig(userSigObj *unstructured.Unstruc
385385
userSig, err := createAppProtectUserSigEx(userSigObj)
386386
ci.UserSigs[resNsName] = userSig
387387
if err != nil {
388-
problems = append(problems, Problem{Object: userSigObj, Reason: "Rejected", Message: err.Error()})
388+
problems = append(problems, Problem{Object: userSigObj, Reason: nl.EventReasonRejected, Message: err.Error()})
389389
}
390390
change.UserSigs = append(change.UserSigs, userSigObj)
391391
ci.buildUserSigChangeAndProblems(&problems, &change)
@@ -489,7 +489,7 @@ func (ci *ConfigurationImpl) reconcileUserSigs() (changes []Change, problems []P
489489
for _, sig := range sigs[1:] {
490490
if sig.IsValid {
491491
sig.setInvalid(duplicatedTagsErrorMsg)
492-
looserProblem := Problem{Object: sig.Obj, Reason: "Rejected", Message: duplicatedTagsErrorMsg}
492+
looserProblem := Problem{Object: sig.Obj, Reason: nl.EventReasonRejected, Message: duplicatedTagsErrorMsg}
493493
looserChange := Change{Op: Delete, Resource: sig}
494494
changes = append(changes, looserChange)
495495
problems = append(problems, looserProblem)
@@ -511,7 +511,7 @@ func (ci *ConfigurationImpl) verifyPolicies() (changes []Change, problems []Prob
511511
if pol.IsValid {
512512
if !ci.verifyPolicyAgainstUserSigs(pol) {
513513
pol.setInvalid(missingUserSigErrorMsg)
514-
polProb := Problem{Object: pol.Obj, Reason: "Rejected", Message: missingUserSigErrorMsg}
514+
polProb := Problem{Object: pol.Obj, Reason: nl.EventReasonRejected, Message: missingUserSigErrorMsg}
515515
polCh := Change{Op: Delete, Resource: pol}
516516
changes = append(changes, polCh)
517517
problems = append(problems, polProb)

internal/k8s/appprotect/app_protect_configuration_test.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"testing"
77
"time"
88

9+
nl "github.com/nginx/kubernetes-ingress/internal/logger"
910
nic_glog "github.com/nginx/kubernetes-ingress/internal/logger/glog"
1011
"github.com/nginx/kubernetes-ingress/internal/logger/levels"
1112

@@ -577,7 +578,7 @@ func TestAddOrUpdatePolicy(t *testing.T) {
577578
expectedProblems: []Problem{
578579
{
579580
Object: invalidTestPolicy,
580-
Reason: "Rejected",
581+
Reason: nl.EventReasonRejected,
581582
Message: "Error validating policy : error validating App Protect Policy : required field map[] not found",
582583
},
583584
},
@@ -606,7 +607,7 @@ func TestAddOrUpdatePolicy(t *testing.T) {
606607
expectedProblems: []Problem{
607608
{
608609
Object: testPolicyUnsatisfied,
609-
Reason: "Rejected",
610+
Reason: nl.EventReasonRejected,
610611
Message: "policy has unsatisfied signature requirements",
611612
},
612613
},
@@ -686,7 +687,7 @@ func TestAddOrUpdateLogConf(t *testing.T) {
686687
expectedProblems: []Problem{
687688
{
688689
Object: invalidLogConf,
689-
Reason: "Rejected",
690+
Reason: nl.EventReasonRejected,
690691
Message: "error validating App Protect Log Configuration testlogconf: required field map[] not found",
691692
},
692693
},
@@ -846,7 +847,7 @@ func TestAddOrUpdateUserSig(t *testing.T) {
846847
expectedProblems: []Problem{
847848
{
848849
Object: invalidTestUserSig2,
849-
Reason: "Rejected",
850+
Reason: nl.EventReasonRejected,
850851
Message: "validation failed",
851852
},
852853
},
@@ -863,7 +864,7 @@ func TestAddOrUpdateUserSig(t *testing.T) {
863864
{
864865
Object: testUserSigDupTag,
865866
Message: "duplicate tag set",
866-
Reason: "Rejected",
867+
Reason: nl.EventReasonRejected,
867868
},
868869
},
869870
msg: "Duplicate tags",
@@ -879,7 +880,7 @@ func TestAddOrUpdateUserSig(t *testing.T) {
879880
{
880881
Object: testUserSig1Invalid,
881882
Message: "validation failed",
882-
Reason: "Rejected",
883+
Reason: nl.EventReasonRejected,
883884
},
884885
},
885886
msg: "UserSig becomes valid after previous tag holder became invalid",
@@ -1071,7 +1072,7 @@ func TestDeleteUserSig(t *testing.T) {
10711072
},
10721073
expectedProblems: []Problem{
10731074
{
1074-
Reason: "Rejected",
1075+
Reason: nl.EventReasonRejected,
10751076
Message: "policy has unsatisfied signature requirements",
10761077
Object: &unstructured.Unstructured{
10771078
Object: map[string]interface{}{},

internal/k8s/appprotect_dos.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,17 +216,17 @@ func (lbc *LoadBalancerController) processAppProtectDosChanges(changes []appprot
216216
warnings, err := lbc.configurator.AddOrUpdateResourcesThatUseDosProtected(resourceExes.IngressExes, resourceExes.MergeableIngresses, resourceExes.VirtualServerExes)
217217
lbc.updateResourcesStatusAndEvents(resources, warnings, err)
218218
msg := fmt.Sprintf("Configuration for %s/%s was added or updated", impl.Obj.Namespace, impl.Obj.Name)
219-
lbc.recorder.Event(impl.Obj, api_v1.EventTypeNormal, "AddedOrUpdated", msg)
219+
lbc.recorder.Event(impl.Obj, api_v1.EventTypeNormal, nl.EventReasonAddedOrUpdated, msg)
220220
case *appprotectdos.DosPolicyEx:
221221
msg := "Configuration was added or updated"
222-
lbc.recorder.Event(impl.Obj, api_v1.EventTypeNormal, "AddedOrUpdated", msg)
222+
lbc.recorder.Event(impl.Obj, api_v1.EventTypeNormal, nl.EventReasonAddedOrUpdated, msg)
223223
case *appprotectdos.DosLogConfEx:
224224
eventType := api_v1.EventTypeNormal
225-
eventTitle := "AddedOrUpdated"
225+
eventTitle := nl.EventReasonAddedOrUpdated
226226
msg := "Configuration was added or updated"
227227
if impl.ErrorMsg != "" {
228228
msg += fmt.Sprintf(" ; with warning(s): %s", impl.ErrorMsg)
229-
eventTitle = "AddedOrUpdatedWithWarning"
229+
eventTitle = nl.EventReasonAddedOrUpdatedWithWarning
230230
eventType = api_v1.EventTypeWarning
231231
}
232232
lbc.recorder.Event(impl.Obj, eventType, eventTitle, msg)

internal/k8s/appprotect_waf.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ func (lbc *LoadBalancerController) processAppProtectChanges(changes []appprotect
371371

372372
warnings, updateErr := lbc.configurator.AddOrUpdateAppProtectResource(impl.Obj, resourceExes.IngressExes, resourceExes.MergeableIngresses, resourceExes.VirtualServerExes)
373373
lbc.updateResourcesStatusAndEvents(resources, warnings, updateErr)
374-
lbc.recorder.Eventf(impl.Obj, api_v1.EventTypeNormal, "AddedOrUpdated", "AppProtectPolicy %v was added or updated", namespace+"/"+name)
374+
lbc.recorder.Eventf(impl.Obj, api_v1.EventTypeNormal, nl.EventReasonAddedOrUpdated, "AppProtectPolicy %v was added or updated", namespace+"/"+name)
375375
case *appprotect.LogConfEx:
376376
namespace := impl.Obj.GetNamespace()
377377
name := impl.Obj.GetName()
@@ -385,7 +385,7 @@ func (lbc *LoadBalancerController) processAppProtectChanges(changes []appprotect
385385

386386
warnings, updateErr := lbc.configurator.AddOrUpdateAppProtectResource(impl.Obj, resourceExes.IngressExes, resourceExes.MergeableIngresses, resourceExes.VirtualServerExes)
387387
lbc.updateResourcesStatusAndEvents(resources, warnings, updateErr)
388-
lbc.recorder.Eventf(impl.Obj, api_v1.EventTypeNormal, "AddedOrUpdated", "AppProtectLogConfig %v was added or updated", namespace+"/"+name)
388+
lbc.recorder.Eventf(impl.Obj, api_v1.EventTypeNormal, nl.EventReasonAddedOrUpdated, "AppProtectLogConfig %v was added or updated", namespace+"/"+name)
389389
}
390390
} else if c.Op == appprotect.Delete {
391391
switch impl := c.Resource.(type) {

internal/k8s/appprotectdos/app_protect_dos_configuration.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66

77
"github.com/nginx/kubernetes-ingress/internal/configs"
88
"github.com/nginx/kubernetes-ingress/internal/k8s/appprotectcommon"
9+
nl "github.com/nginx/kubernetes-ingress/internal/logger"
910
"github.com/nginx/kubernetes-ingress/pkg/apis/dos/v1beta1"
1011
"github.com/nginx/kubernetes-ingress/pkg/apis/dos/validation"
1112
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
@@ -117,7 +118,7 @@ func (ci *Configuration) AddOrUpdatePolicy(policyObj *unstructured.Unstructured)
117118
op := AddOrUpdate
118119
if err != nil {
119120
op = Delete
120-
problems = append(problems, Problem{Object: policyObj, Reason: "Rejected", Message: err.Error()})
121+
problems = append(problems, Problem{Object: policyObj, Reason: nl.EventReasonRejected, Message: err.Error()})
121122
}
122123

123124
changes = append(changes, Change{Op: op, Resource: policy})
@@ -140,7 +141,7 @@ func (ci *Configuration) AddOrUpdateLogConf(logConfObj *unstructured.Unstructure
140141
op := AddOrUpdate
141142
if err != nil {
142143
op = Delete
143-
problems = append(problems, Problem{Object: logConfObj, Reason: "Rejected", Message: err.Error()})
144+
problems = append(problems, Problem{Object: logConfObj, Reason: nl.EventReasonRejected, Message: err.Error()})
144145
}
145146

146147
changes = append(changes, Change{Op: op, Resource: logConf})
@@ -162,7 +163,7 @@ func (ci *Configuration) AddOrUpdateDosProtectedResource(protectedConf *v1beta1.
162163
ci.dosProtectedResource[resNsName] = protectedEx
163164
if err != nil {
164165
return []Change{{Op: Delete, Resource: protectedEx}},
165-
[]Problem{{Object: protectedConf, Reason: "Rejected", Message: err.Error()}}
166+
[]Problem{{Object: protectedConf, Reason: nl.EventReasonRejected, Message: err.Error()}}
166167
}
167168
if protectedEx.Obj.Spec.ApDosPolicy != "" {
168169
policyReference := protectedEx.Obj.Spec.ApDosPolicy
@@ -173,7 +174,7 @@ func (ci *Configuration) AddOrUpdateDosProtectedResource(protectedConf *v1beta1.
173174
_, err := ci.getPolicy(policyReference)
174175
if err != nil {
175176
return []Change{{Op: Delete, Resource: protectedEx}},
176-
[]Problem{{Object: protectedConf, Reason: "Rejected", Message: fmt.Sprintf("dos protected refers (%s) to an invalid DosPolicy: %s", policyReference, err.Error())}}
177+
[]Problem{{Object: protectedConf, Reason: nl.EventReasonRejected, Message: fmt.Sprintf("dos protected refers (%s) to an invalid DosPolicy: %s", policyReference, err.Error())}}
177178
}
178179
}
179180
if protectedEx.Obj.Spec.DosSecurityLog != nil && protectedEx.Obj.Spec.DosSecurityLog.ApDosLogConf != "" {
@@ -185,7 +186,7 @@ func (ci *Configuration) AddOrUpdateDosProtectedResource(protectedConf *v1beta1.
185186
_, err := ci.getLogConf(logConfReference)
186187
if err != nil {
187188
return []Change{{Op: Delete, Resource: protectedEx}},
188-
[]Problem{{Object: protectedConf, Reason: "Rejected", Message: fmt.Sprintf("dos protected refers (%s) to an invalid DosLogConf: %s", logConfReference, err.Error())}}
189+
[]Problem{{Object: protectedConf, Reason: nl.EventReasonRejected, Message: fmt.Sprintf("dos protected refers (%s) to an invalid DosLogConf: %s", logConfReference, err.Error())}}
189190
}
190191
}
191192
return []Change{{Op: AddOrUpdate, Resource: protectedEx}}, nil

0 commit comments

Comments
 (0)