Skip to content

Commit c820189

Browse files
feat: [NPM] send more AI logs (#1230)
* send heartbeat log and send logs in v2 * address comment and add logs for ip validation and policy manager bootup
1 parent d5f134d commit c820189

File tree

9 files changed

+95
-38
lines changed

9 files changed

+95
-38
lines changed

npm/cmd/start.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ func start(config npmconfig.Config, flags npmconfig.Flags) error {
160160

161161
go restserver.NPMRestServerListenAndServe(config, npMgr)
162162

163+
metrics.SendLog(util.NpmID, "starting NPM")
163164
if err = npMgr.Start(config, stopChannel); err != nil {
164165
metrics.SendErrorLogAndMetric(util.NpmID, "Failed to start NPM due to %+v", err)
165166
return fmt.Errorf("failed to start with err: %w", err)

npm/iptm/iptm.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ func (iptMgr *IptablesManager) reconcileChains(stopCh <-chan struct{}) {
330330
if err := iptMgr.checkAndAddForwardChain(); err != nil {
331331
metrics.SendErrorLogAndMetric(util.NpmID, "Error: failed to reconcileChains Azure-NPM due to %s", err.Error())
332332
}
333+
metrics.SendHeartbeatLog()
333334
}
334335
}
335336
}

npm/metrics/ai-utils.go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,29 +62,37 @@ func SendErrorLogAndMetric(operationID int, format string, args ...interface{})
6262

6363
// Send error logs
6464
msg := fmt.Sprintf(format, args...)
65-
report := aitelemetry.Report{
66-
Message: msg,
67-
Context: strconv.Itoa(operationID),
68-
CustomDimensions: make(map[string]string),
69-
}
7065
log.Errorf(msg)
71-
SendLog(report)
66+
SendLog(operationID, msg)
7267
}
7368

7469
// SendMetric sends metrics
7570
func SendMetric(metric aitelemetry.Metric) {
7671
if th == nil {
77-
log.Logf("AppInsights didn't initialized.")
72+
log.Logf("AppInsights didn't initialize")
7873
return
7974
}
8075
th.TrackMetric(metric)
8176
}
8277

8378
// SendLog sends log
84-
func SendLog(report aitelemetry.Report) {
79+
func SendLog(operationID int, msg string) {
80+
report := aitelemetry.Report{
81+
Message: msg,
82+
Context: strconv.Itoa(operationID),
83+
CustomDimensions: make(map[string]string),
84+
}
8585
if th == nil {
8686
log.Logf("AppInsights didn't initialized.")
8787
return
8888
}
8989
th.TrackLog(report)
9090
}
91+
92+
func SendHeartbeatLog() {
93+
numPolicies, err := GetNumPolicies()
94+
if err != nil {
95+
message := fmt.Sprintf("Info: NPM currently has %d policies", numPolicies)
96+
SendLog(util.NpmID, message)
97+
}
98+
}

npm/pkg/dataplane/dataplane.go

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/Azure/azure-container-networking/npm/metrics"
1010
"github.com/Azure/azure-container-networking/npm/pkg/dataplane/ipsets"
1111
"github.com/Azure/azure-container-networking/npm/pkg/dataplane/policies"
12+
"github.com/Azure/azure-container-networking/npm/util"
1213
npmerrors "github.com/Azure/azure-container-networking/npm/util/errors"
1314
"k8s.io/klog"
1415
)
@@ -111,9 +112,9 @@ func (dp *DataPlane) AddToSets(setNames []*ipsets.IPSetMetadata, podMetadata *Po
111112
return fmt.Errorf("[DataPlane] error while adding to set: %w", err)
112113
}
113114
if dp.shouldUpdatePod() {
114-
klog.Infof("[Dataplane] Updating Sets to Add for pod key %s", podMetadata.PodKey)
115+
klog.Infof("[DataPlane] Updating Sets to Add for pod key %s", podMetadata.PodKey)
115116
if _, ok := dp.updatePodCache[podMetadata.PodKey]; !ok {
116-
klog.Infof("[Dataplane] {AddToSet} pod key %s not found creating a new obj", podMetadata.PodKey)
117+
klog.Infof("[DataPlane] {AddToSet} pod key %s not found creating a new obj", podMetadata.PodKey)
117118
dp.updatePodCache[podMetadata.PodKey] = newUpdateNPMPod(podMetadata)
118119
}
119120

@@ -132,9 +133,9 @@ func (dp *DataPlane) RemoveFromSets(setNames []*ipsets.IPSetMetadata, podMetadat
132133
}
133134

134135
if dp.shouldUpdatePod() {
135-
klog.Infof("[Dataplane] Updating Sets to Remove for pod key %s", podMetadata.PodKey)
136+
klog.Infof("[DataPlane] Updating Sets to Remove for pod key %s", podMetadata.PodKey)
136137
if _, ok := dp.updatePodCache[podMetadata.PodKey]; !ok {
137-
klog.Infof("[Dataplane] {RemoveFromSet} pod key %s not found creating a new obj", podMetadata.PodKey)
138+
klog.Infof("[DataPlane] {RemoveFromSet} pod key %s not found creating a new obj", podMetadata.PodKey)
138139
dp.updatePodCache[podMetadata.PodKey] = newUpdateNPMPod(podMetadata)
139140
}
140141

@@ -179,6 +180,7 @@ func (dp *DataPlane) ApplyDataPlane() error {
179180
for podKey, pod := range dp.updatePodCache {
180181
err := dp.updatePod(pod)
181182
if err != nil {
183+
metrics.SendErrorLogAndMetric(util.DaemonDataplaneID, "error: failed to update pods: %s", err.Error())
182184
return fmt.Errorf("[DataPlane] error while updating pod: %w", err)
183185
}
184186
delete(dp.updatePodCache, podKey)
@@ -292,7 +294,7 @@ func (dp *DataPlane) createIPSetsAndReferences(sets []*ipsets.TranslatedIPSet, n
292294
dp.ipsetMgr.CreateIPSets([]*ipsets.IPSetMetadata{set.Metadata})
293295
err := dp.ipsetMgr.AddReference(set.Metadata.GetPrefixName(), netpolName, referenceType)
294296
if err != nil {
295-
return npmerrors.Errorf(npmErrorString, false, fmt.Sprintf("[dataplane] failed to add reference with err: %s", err.Error()))
297+
return npmerrors.Errorf(npmErrorString, false, fmt.Sprintf("[DataPlane] failed to add reference with err: %s", err.Error()))
296298
}
297299
}
298300

@@ -308,19 +310,19 @@ func (dp *DataPlane) createIPSetsAndReferences(sets []*ipsets.TranslatedIPSet, n
308310
for _, ipblock := range set.Members {
309311
err := validateIPBlock(ipblock)
310312
if err != nil {
311-
return npmerrors.Errorf(npmErrorString, false, fmt.Sprintf("[dataplane] failed to parseCIDR in addIPSetReferences with err: %s", err.Error()))
313+
return npmerrors.Errorf(npmErrorString, false, fmt.Sprintf("[DataPlane] failed to parseCIDR in addIPSetReferences with err: %s", err.Error()))
312314
}
313315
err = dp.ipsetMgr.AddToSets([]*ipsets.IPSetMetadata{set.Metadata}, ipblock, "")
314316
if err != nil {
315-
return npmerrors.Errorf(npmErrorString, false, fmt.Sprintf("[dataplane] failed to AddToSet in addIPSetReferences with err: %s", err.Error()))
317+
return npmerrors.Errorf(npmErrorString, false, fmt.Sprintf("[DataPlane] failed to AddToSet in addIPSetReferences with err: %s", err.Error()))
316318
}
317319
}
318320
} else if setType == ipsets.NestedLabelOfPod && len(set.Members) > 0 {
319321
// Check if any 2nd level IPSets are generated by Controller with members
320322
// Apply members to the list set
321323
err := dp.ipsetMgr.AddToLists([]*ipsets.IPSetMetadata{set.Metadata}, getMembersOfTranslatedSets(set.Members))
322324
if err != nil {
323-
return npmerrors.Errorf(npmErrorString, false, fmt.Sprintf("[dataplane] failed to AddToList in addIPSetReferences with err: %s", err.Error()))
325+
return npmerrors.Errorf(npmErrorString, false, fmt.Sprintf("[DataPlane] failed to AddToList in addIPSetReferences with err: %s", err.Error()))
324326
}
325327
}
326328
}
@@ -338,7 +340,7 @@ func (dp *DataPlane) deleteIPSetsAndReferences(sets []*ipsets.TranslatedIPSet, n
338340
// TODO add delete ipset after removing members
339341
err := dp.ipsetMgr.DeleteReference(set.Metadata.GetPrefixName(), netpolName, referenceType)
340342
if err != nil {
341-
return npmerrors.Errorf(npmErrorString, false, fmt.Sprintf("[dataplane] failed to deleteIPSetReferences with err: %s", err.Error()))
343+
return npmerrors.Errorf(npmErrorString, false, fmt.Sprintf("[DataPlane] failed to deleteIPSetReferences with err: %s", err.Error()))
342344
}
343345
}
344346

@@ -356,18 +358,18 @@ func (dp *DataPlane) deleteIPSetsAndReferences(sets []*ipsets.TranslatedIPSet, n
356358
for _, ipblock := range set.Members {
357359
err := validateIPBlock(ipblock)
358360
if err != nil {
359-
return npmerrors.Errorf(npmErrorString, false, fmt.Sprintf("[dataplane] failed to parseCIDR in deleteIPSetReferences with err: %s", err.Error()))
361+
return npmerrors.Errorf(npmErrorString, false, fmt.Sprintf("[DataPlane] failed to parseCIDR in deleteIPSetReferences with err: %s", err.Error()))
360362
}
361363
err = dp.ipsetMgr.RemoveFromSets([]*ipsets.IPSetMetadata{set.Metadata}, ipblock, "")
362364
if err != nil {
363-
return npmerrors.Errorf(npmErrorString, false, fmt.Sprintf("[dataplane] failed to RemoveFromSet in deleteIPSetReferences with err: %s", err.Error()))
365+
return npmerrors.Errorf(npmErrorString, false, fmt.Sprintf("[DataPlane] failed to RemoveFromSet in deleteIPSetReferences with err: %s", err.Error()))
364366
}
365367
}
366368
} else if set.Metadata.GetSetKind() == ipsets.ListSet && len(set.Members) > 0 {
367369
// Delete if any 2nd level IPSets are generated by Controller with members
368370
err := dp.ipsetMgr.RemoveFromList(set.Metadata, getMembersOfTranslatedSets(set.Members))
369371
if err != nil {
370-
return npmerrors.Errorf(npmErrorString, false, fmt.Sprintf("[dataplane] failed to RemoveFromList in deleteIPSetReferences with err: %s", err.Error()))
372+
return npmerrors.Errorf(npmErrorString, false, fmt.Sprintf("[DataPlane] failed to RemoveFromList in deleteIPSetReferences with err: %s", err.Error()))
371373
}
372374

373375
}
@@ -385,6 +387,7 @@ func validateIPBlock(ipblock string) error {
385387
onlyCidr := strings.Split(ipblock, " ")[0]
386388
_, _, err := net.ParseCIDR(onlyCidr)
387389
if err != nil {
390+
metrics.SendErrorLogAndMetric(util.IpsmID, "error: failed to parse CIDR: %s", err.Error())
388391
return npmerrors.SimpleErrorWrapper("failed to parse CIDR", err)
389392
}
390393
return nil

npm/pkg/dataplane/ipsets/ipsetmanager.go

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

77
"github.com/Azure/azure-container-networking/common"
88
"github.com/Azure/azure-container-networking/npm/metrics"
9+
"github.com/Azure/azure-container-networking/npm/util"
910
npmerrors "github.com/Azure/azure-container-networking/npm/util/errors"
1011
"k8s.io/klog"
1112
)
@@ -52,6 +53,7 @@ func (iMgr *IPSetManager) ResetIPSets() error {
5253
defer iMgr.Unlock()
5354
err := iMgr.resetIPSets()
5455
if err != nil {
56+
metrics.SendErrorLogAndMetric(util.IpsmID, "error: failed to reset ipsetmanager: %s", err.Error())
5557
return fmt.Errorf("error while resetting ipsetmanager: %w", err)
5658
}
5759
// TODO update prometheus metrics here instead of in OS-specific functions (done in Linux right now)
@@ -122,12 +124,16 @@ func (iMgr *IPSetManager) AddReference(setName, referenceName string, referenceT
122124
if referenceType == NetPolType {
123125
npmErrorString = npmerrors.AddNetPolReference
124126
}
125-
return npmerrors.Errorf(npmErrorString, false, fmt.Sprintf("ipset %s does not exist", setName))
127+
msg := fmt.Sprintf("ipset %s does not exist", setName)
128+
metrics.SendErrorLogAndMetric(util.IpsmID, "error: failed to add reference: %s", msg)
129+
return npmerrors.Errorf(npmErrorString, false, msg)
126130
}
127131

128132
set := iMgr.setMap[setName]
129133
if referenceType == SelectorType && !set.canSetBeSelectorIPSet() {
130-
return npmerrors.Errorf(npmerrors.AddSelectorReference, false, fmt.Sprintf("ipset %s is not a selector ipset it is of type %s", setName, set.Type.String()))
134+
msg := fmt.Sprintf("ipset %s is not a selector ipset it is of type %s", setName, set.Type.String())
135+
metrics.SendErrorLogAndMetric(util.IpsmID, "error: failed to add reference: %s", msg)
136+
return npmerrors.Errorf(npmerrors.AddSelectorReference, false, msg)
131137
}
132138
wasInKernel := iMgr.shouldBeInKernel(set)
133139
set.addReference(referenceName, referenceType)
@@ -152,7 +158,9 @@ func (iMgr *IPSetManager) DeleteReference(setName, referenceName string, referen
152158
if referenceType == NetPolType {
153159
npmErrorString = npmerrors.DeleteNetPolReference
154160
}
155-
return npmerrors.Errorf(npmErrorString, false, fmt.Sprintf("ipset %s does not exist", setName))
161+
msg := fmt.Sprintf("ipset %s does not exist", setName)
162+
metrics.SendErrorLogAndMetric(util.IpsmID, "error: failed to delete reference: %s", msg)
163+
return npmerrors.Errorf(npmErrorString, false, msg)
156164
}
157165

158166
set := iMgr.setMap[setName]
@@ -188,7 +196,9 @@ func (iMgr *IPSetManager) AddToSets(addToSets []*IPSetMetadata, ip, podKey strin
188196
set = iMgr.setMap[prefixedName]
189197
}
190198
if set.Kind != HashSet {
191-
return npmerrors.Errorf(npmerrors.AppendIPSet, false, fmt.Sprintf("ipset %s is not a hash set", prefixedName))
199+
msg := fmt.Sprintf("ipset %s is not a hash set", prefixedName)
200+
metrics.SendErrorLogAndMetric(util.IpsmID, "error: failed to add to sets: %s", msg)
201+
return npmerrors.Errorf(npmerrors.AppendIPSet, false, msg)
192202
}
193203

194204
// 2. add ip to the set, and update the pod key
@@ -219,7 +229,9 @@ func (iMgr *IPSetManager) RemoveFromSets(removeFromSets []*IPSetMetadata, ip, po
219229
continue
220230
}
221231
if set.Kind != HashSet {
222-
return npmerrors.Errorf(npmerrors.DeleteIPSet, false, fmt.Sprintf("ipset %s is not a hash set", prefixedName))
232+
msg := fmt.Sprintf("ipset %s is not a hash set", prefixedName)
233+
metrics.SendErrorLogAndMetric(util.IpsmID, "error: failed to remove from sets: %s", msg)
234+
return npmerrors.Errorf(npmerrors.DeleteIPSet, false, msg)
223235
}
224236

225237
// 2. remove ip from the set
@@ -264,7 +276,9 @@ func (iMgr *IPSetManager) AddToLists(listMetadatas, setMetadatas []*IPSetMetadat
264276
// Nested IPSets are only supported for windows
265277
// Check if we want to actually use that support
266278
if set.Kind != HashSet {
267-
return npmerrors.Errorf(npmerrors.AppendIPSet, false, fmt.Sprintf("ipset %s is not a hash set and nested list sets are not supported", setName))
279+
msg := fmt.Sprintf("ipset %s is not a hash set and nested list sets are not supported", setName)
280+
metrics.SendErrorLogAndMetric(util.IpsmID, "error: failed to add to lists: %s", msg)
281+
return npmerrors.Errorf(npmerrors.AppendIPSet, false, msg)
268282
}
269283
}
270284

@@ -279,7 +293,9 @@ func (iMgr *IPSetManager) AddToLists(listMetadatas, setMetadatas []*IPSetMetadat
279293
}
280294

281295
if list.Kind != ListSet {
282-
return npmerrors.Errorf(npmerrors.AppendIPSet, false, fmt.Sprintf("ipset %s is not a list set", listName))
296+
msg := fmt.Sprintf("ipset %s is not a list set", listName)
297+
metrics.SendErrorLogAndMetric(util.IpsmID, "error: failed to add to lists: %s", msg)
298+
return npmerrors.Errorf(npmerrors.AppendIPSet, false, msg)
283299
}
284300

285301
modified := false
@@ -323,7 +339,9 @@ func (iMgr *IPSetManager) RemoveFromList(listMetadata *IPSetMetadata, setMetadat
323339
}
324340

325341
if list.Kind != ListSet {
326-
return npmerrors.Errorf(npmerrors.DeleteIPSet, false, fmt.Sprintf("ipset %s is not a list set", listName))
342+
msg := fmt.Sprintf("ipset %s is not a list set", listName)
343+
metrics.SendErrorLogAndMetric(util.IpsmID, "error: failed to remove from list: %s", msg)
344+
return npmerrors.Errorf(npmerrors.DeleteIPSet, false, msg)
327345
}
328346

329347
modified := false
@@ -340,7 +358,9 @@ func (iMgr *IPSetManager) RemoveFromList(listMetadata *IPSetMetadata, setMetadat
340358
if modified {
341359
iMgr.modifyCacheForKernelMemberUpdate(list)
342360
}
343-
return npmerrors.Errorf(npmerrors.DeleteIPSet, false, fmt.Sprintf("ipset %s is not a hash set and nested list sets are not supported", memberName))
361+
msg := fmt.Sprintf("ipset %s is not a hash set and nested list sets are not supported", memberName)
362+
metrics.SendErrorLogAndMetric(util.IpsmID, "error: failed to remove from list: %s", msg)
363+
return npmerrors.Errorf(npmerrors.DeleteIPSet, false, msg)
344364
}
345365

346366
// 2. remove member from the list
@@ -382,6 +402,7 @@ func (iMgr *IPSetManager) ApplyIPSets() error {
382402
// Call the appropriate apply ipsets
383403
err := iMgr.applyIPSets()
384404
if err != nil {
405+
metrics.SendErrorLogAndMetric(util.IpsmID, "error: failed to apply ipsets: %s", err.Error())
385406
return err
386407
}
387408

@@ -494,12 +515,17 @@ func (iMgr *IPSetManager) modifyCacheForKernelMemberUpdate(set *IPSet) {
494515
// sanitizeDirtyCache will check if any set marked as delete is in toAddUpdate
495516
// if so will not delete it
496517
func (iMgr *IPSetManager) sanitizeDirtyCache() {
518+
anyProblems := false
497519
for setName := range iMgr.toDeleteCache {
498520
_, ok := iMgr.toAddOrUpdateCache[setName]
499521
if ok {
500-
klog.Errorf("[IPSetManager] Unexpected state in dirty cache %s set is part of both update and delete caches \n ", setName)
522+
klog.Errorf("[IPSetManager] Unexpected state in dirty cache %s set is part of both update and delete caches", setName)
523+
anyProblems = true
501524
}
502525
}
526+
if anyProblems {
527+
metrics.SendErrorLogAndMetric(util.IpsmID, "error: some dirty cache sets are part of both update and delete caches")
528+
}
503529
}
504530

505531
func (iMgr *IPSetManager) clearDirtyCache() {

npm/pkg/dataplane/policies/chain-management_linux.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,9 @@ func (pMgr *PolicyManager) bootup(_ []string) error {
194194
// - cleans up stale policy chains. It can be forced to stop this process if reconcileManager.forceLock() is called.
195195
func (pMgr *PolicyManager) reconcile() {
196196
if err := pMgr.positionAzureChainJumpRule(); err != nil {
197-
klog.Errorf("failed to reconcile jump rule to Azure-NPM due to %s", err.Error())
197+
msg := fmt.Sprintf("failed to reconcile jump rule to Azure-NPM due to %s", err.Error())
198+
metrics.SendErrorLogAndMetric(util.IptmID, "error: %s", msg)
199+
klog.Error(msg)
198200
}
199201

200202
pMgr.reconcileManager.Lock()
@@ -207,7 +209,9 @@ func (pMgr *PolicyManager) reconcile() {
207209

208210
klog.Infof("cleaning up these stale chains: %+v", staleChains)
209211
if err := pMgr.cleanupChains(staleChains); err != nil {
210-
klog.Errorf("failed to clean up old policy chains with the following error: %s", err.Error())
212+
msg := fmt.Sprintf("failed to clean up old policy chains with the following error: %s", err.Error())
213+
metrics.SendErrorLogAndMetric(util.IptmID, "error: %s", msg)
214+
klog.Error(msg)
211215
}
212216
}
213217

npm/pkg/dataplane/policies/policymanager.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
"github.com/Azure/azure-container-networking/common"
99
"github.com/Azure/azure-container-networking/npm/metrics"
10+
"github.com/Azure/azure-container-networking/npm/util"
1011
npmerrors "github.com/Azure/azure-container-networking/npm/util/errors"
1112
"k8s.io/klog"
1213
)
@@ -62,6 +63,7 @@ func NewPolicyManager(ioShim *common.IOShim, cfg *PolicyManagerCfg) *PolicyManag
6263

6364
func (pMgr *PolicyManager) Bootup(epIDs []string) error {
6465
if err := pMgr.bootup(epIDs); err != nil {
66+
metrics.SendErrorLogAndMetric(util.IptmID, "error: failed to bootup policy manager: %s", err.Error())
6567
return npmerrors.ErrorWrapper(npmerrors.BootupPolicyMgr, false, "failed to bootup policy manager", err)
6668
}
6769
return nil
@@ -78,6 +80,7 @@ func (pMgr *PolicyManager) Reconcile(stopChannel <-chan struct{}) {
7880
return
7981
case <-ticker.C:
8082
pMgr.reconcile()
83+
metrics.SendHeartbeatLog()
8184
}
8285
}
8386
}()
@@ -102,13 +105,17 @@ func (pMgr *PolicyManager) AddPolicy(policy *NPMNetworkPolicy, endpointList map[
102105
defer metrics.RecordACLRuleExecTime(prometheusTimer) // record execution time regardless of failure
103106
normalizePolicy(policy)
104107
if err := validatePolicy(policy); err != nil {
105-
return npmerrors.Errorf(npmerrors.AddPolicy, false, fmt.Sprintf("couldn't add malformed policy: %s", err.Error()))
108+
msg := fmt.Sprintf("failed to validate policy: %s", err.Error())
109+
metrics.SendErrorLogAndMetric(util.IptmID, "error: %s", msg)
110+
return npmerrors.Errorf(npmerrors.AddPolicy, false, msg)
106111
}
107112

108113
// Call actual dataplane function to apply changes
109114
err := pMgr.addPolicy(policy, endpointList)
110115
if err != nil {
111-
return npmerrors.Errorf(npmerrors.AddPolicy, false, fmt.Sprintf("failed to add policy: %v", err))
116+
msg := fmt.Sprintf("failed to add policy: %s", err.Error())
117+
metrics.SendErrorLogAndMetric(util.IptmID, "error: %s", msg)
118+
return npmerrors.Errorf(npmerrors.AddPolicy, false, msg)
112119
}
113120

114121
pMgr.policyMap.cache[policy.PolicyKey] = policy
@@ -133,7 +140,9 @@ func (pMgr *PolicyManager) RemovePolicy(policyKey string, endpointList map[strin
133140
// Call actual dataplane function to apply changes
134141
err := pMgr.removePolicy(policy, endpointList)
135142
if err != nil {
136-
return npmerrors.Errorf(npmerrors.RemovePolicy, false, fmt.Sprintf("failed to remove policy: %v", err))
143+
msg := fmt.Sprintf("failed to remove policy: %s", err.Error())
144+
metrics.SendErrorLogAndMetric(util.IptmID, "error: %s", msg)
145+
return npmerrors.Errorf(npmerrors.RemovePolicy, false, msg)
137146
}
138147

139148
delete(pMgr.policyMap.cache, policyKey)

0 commit comments

Comments
 (0)