Skip to content

Commit 93fc649

Browse files
committed
fix issues to upgrade kubernetes package
1 parent 345f2fa commit 93fc649

File tree

10 files changed

+16
-16
lines changed

10 files changed

+16
-16
lines changed

npm/ipsm/ipsm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ func (ipsMgr *IpsetManager) run(entry *ipsEntry) (int, error) {
215215
errfmt := fmt.Errorf("error running command: [%s %v] Stderr: [%w, %s]",
216216
cmdName, strings.Join(cmdArgs, " "), err, strings.TrimSuffix(string(output), "\n"))
217217
if exitCode > 0 {
218-
metrics.SendErrorLogAndMetric(util.IpsmID, errfmt.Error())
218+
metrics.SendErrorLogAndMetric(util.IpsmID, "%s", errfmt.Error())
219219
}
220220

221221
return exitCode, errfmt

npm/ipsm/ipsm_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ func TestDestroyNpmIpsets(t *testing.T) {
514514
References: 0
515515
Number of entries: 0
516516
Members:
517-
517+
518518
Name: %s
519519
Type: hash:net
520520
Revision: 6
@@ -547,26 +547,26 @@ func TestDestroyNpmIpsets(t *testing.T) {
547547
err := ipsMgr.CreateSetNoLock(testSet1Name, []string{"nethash"})
548548
if err != nil {
549549
t.Errorf("TestDestroyNpmIpsets failed @ ipsMgr.createSet")
550-
t.Errorf(err.Error())
550+
t.Errorf("%s", err.Error())
551551
}
552552

553553
err = ipsMgr.CreateSetNoLock(testSet2Name, []string{"nethash"})
554554
if err != nil {
555555
t.Errorf("TestDestroyNpmIpsets failed @ ipsMgr.createSet")
556-
t.Errorf(err.Error())
556+
t.Errorf("%s", err.Error())
557557
}
558558

559559
// expect prometheus to add this entry, but remove it when destroying npm sets
560560
err = ipsMgr.AddToSet(testSet1Name, "1.2.3.4", util.IpsetNetHashFlag, "")
561561
if err != nil {
562562
t.Errorf("TestDestroyNpmIpsets failed @ ipsMgr.addToSet")
563-
t.Errorf(err.Error())
563+
t.Errorf("%s",err.Error())
564564
}
565565

566566
err = ipsMgr.DestroyNpmIpsets()
567567
if err != nil {
568568
t.Errorf("TestDestroyNpmIpsets failed @ ipsMgr.DestroyNpmIpsets")
569-
t.Errorf(err.Error())
569+
t.Errorf("%s",err.Error())
570570
}
571571
}
572572

npm/iptm/iptm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ func (iptMgr *IptablesManager) addAllRulesToChains() error {
362362
msg = "Error: failed to add main chains with invalid rule length"
363363
}
364364

365-
metrics.SendErrorLogAndMetric(util.IptmID, msg)
365+
metrics.SendErrorLogAndMetric(util.IptmID, "%s", msg)
366366
return err
367367
}
368368
}

npm/metrics/ai-utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func SendLog(operationID int, msg string, printLog bool) {
106106
CustomDimensions: make(map[string]string),
107107
}
108108
if printLog {
109-
klog.Infof(msg)
109+
klog.Infof("%s", msg)
110110
}
111111
if th == nil {
112112
return

npm/pkg/dataplane/dataplane.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ func (dp *DataPlane) addPolicies(netPols []*policies.NPMNetworkPolicy) error {
508508
// this should never happen because bootup phase is for windows, but just in case, we don't want to applyDataplaneNow() or else there will be a deadlock on dp.applyInfo
509509
msg := fmt.Sprintf("[DataPlane] [%s] at risk of improperly applying a policy which is removed then readded", contextAddNetPolPrecaution)
510510
klog.Warning(msg)
511-
metrics.SendErrorLogAndMetric(util.DaemonDataplaneID, msg)
511+
metrics.SendErrorLogAndMetric(util.DaemonDataplaneID, "%s", msg)
512512
} else {
513513
// prevent #2977
514514
if err := dp.applyDataPlaneNow(contextAddNetPolPrecaution); err != nil {

npm/pkg/dataplane/debug/converter_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func TestGetSetType(t *testing.T) {
179179
actualType := c.getSetType(test.inputSetName, test.inputMapName)
180180
diff := cmp.Diff(test.expected, actualType)
181181
if diff != "" {
182-
t.Fatalf(diff)
182+
t.Fatalf("%s", diff)
183183
}
184184
})
185185
}

npm/pkg/dataplane/ipsets/dirtycache.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func (dc *dirtyCache) create(set *IPSet) {
9696
if _, ok := dc.toUpdateCache[set.Name]; ok {
9797
msg := fmt.Sprintf("create should not be called for set %s since it's in the toUpdateCache", set.Name)
9898
klog.Warning(msg)
99-
metrics.SendErrorLogAndMetric(util.IpsmID, msg)
99+
metrics.SendErrorLogAndMetric(util.IpsmID, "%s", msg)
100100
return
101101
}
102102

@@ -136,7 +136,7 @@ func (dc *dirtyCache) deleteMember(set *IPSet, member string) {
136136
if dc.isSetToDelete(set.Name) {
137137
msg := fmt.Sprintf("attempting to delete member %s for set %s in the toDestroyCache", member, set.Name)
138138
klog.Warning(msg)
139-
metrics.SendErrorLogAndMetric(util.IpsmID, msg)
139+
metrics.SendErrorLogAndMetric(util.IpsmID, "%s", msg)
140140
return
141141
}
142142
if diff, ok := dc.toCreateCache[set.Name]; ok {

npm/pkg/dataplane/ipsets/ipsetmanager.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ func (iMgr *IPSetManager) AddToSets(addToSets []*IPSetMetadata, ip, podKey strin
246246

247247
if !validateIPSetMemberIP(ip) {
248248
msg := fmt.Sprintf("error: failed to add to sets: invalid ip %s", ip)
249-
metrics.SendErrorLogAndMetric(util.IpsmID, msg)
249+
metrics.SendErrorLogAndMetric(util.IpsmID, "%s", msg)
250250
return npmerrors.Errorf(npmerrors.AppendIPSet, true, msg)
251251
}
252252

@@ -282,7 +282,7 @@ func (iMgr *IPSetManager) RemoveFromSets(removeFromSets []*IPSetMetadata, ip, po
282282

283283
if !validateIPSetMemberIP(ip) {
284284
msg := fmt.Sprintf("error: failed to add to sets: invalid ip %s", ip)
285-
metrics.SendErrorLogAndMetric(util.IpsmID, msg)
285+
metrics.SendErrorLogAndMetric(util.IpsmID, "%s", msg)
286286
return npmerrors.Errorf(npmerrors.AppendIPSet, true, msg)
287287
}
288288

npm/pkg/dataplane/ipsets/ipsetmanager_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ func (iMgr *IPSetManager) applyIPSets() error {
428428
if iMgr.consecutiveApplyFailures >= maxConsecutiveFailures {
429429
msg := fmt.Sprintf("exceeded max consecutive failures (%d) when applying ipsets. final error: %s", maxConsecutiveFailures, restoreError.Error())
430430
klog.Error(msg)
431-
metrics.SendErrorLogAndMetric(util.IpsmID, msg)
431+
metrics.SendErrorLogAndMetric(util.IpsmID, "%s", msg)
432432
metrics.Close()
433433
panic(msg)
434434
}

test/internal/kubernetes/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ func WaitForDeploymentToDelete(ctx context.Context, deploymentsClient typedappsv
359359
if apierrors.IsNotFound(err) {
360360
return nil
361361
}
362-
return errors.Errorf(fmt.Sprintf("expected isNotFound error when getting deployment, but got %+v", err))
362+
return errors.Errorf("expected isNotFound error when getting deployment, but got %+v", err)
363363
}
364364
retrier := retry.Retrier{Attempts: DeleteRetryAttempts, Delay: DeleteRetryDelay}
365365
return errors.Wrapf(retrier.Do(ctx, assertDeploymentNotFound), "could not assert deployment %s isNotFound", d.Name)

0 commit comments

Comments
 (0)