Skip to content

Commit f4675c9

Browse files
authored
ci: remove debug stack usage (#4075)
remove debug stack usage
1 parent d122fcb commit f4675c9

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

cni/network/invoker_azure.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package network
22

33
import (
4+
"errors"
45
"fmt"
56
"net"
67
"os"
7-
"runtime/debug"
88
"strings"
99

1010
"github.com/Azure/azure-container-networking/cni"
@@ -20,7 +20,11 @@ import (
2020
"go.uber.org/zap"
2121
)
2222

23-
var logger = log.CNILogger.With(zap.String("component", "cni-net"))
23+
var (
24+
logger = log.CNILogger.With(zap.String("component", "cni-net"))
25+
errNilNetworkConfig = errors.New("network config is nil")
26+
errInvalidIPAddress = errors.New("invalid ip address")
27+
)
2428

2529
const (
2630
bytesSize4 = 4
@@ -50,7 +54,7 @@ func (invoker *AzureIPAMInvoker) Add(addConfig IPAMAddConfig) (IPAMAddResult, er
5054
addResult := IPAMAddResult{interfaceInfo: make(map[string]network.InterfaceInfo)}
5155

5256
if addConfig.nwCfg == nil {
53-
return addResult, invoker.plugin.Errorf("nil nwCfg passed to CNI ADD, stack: %+v", string(debug.Stack()))
57+
return addResult, invoker.plugin.Errorf("nil nwCfg passed to CNI ADD: %v", errNilNetworkConfig)
5458
}
5559

5660
if len(invoker.nwInfo.Subnets) > 0 {
@@ -161,7 +165,7 @@ func (invoker *AzureIPAMInvoker) deleteIpamState() {
161165

162166
func (invoker *AzureIPAMInvoker) Delete(address *net.IPNet, nwCfg *cni.NetworkConfig, _ *cniSkel.CmdArgs, options map[string]interface{}) error { //nolint
163167
if nwCfg == nil {
164-
return invoker.plugin.Errorf("nil nwCfg passed to CNI ADD, stack: %+v", string(debug.Stack()))
168+
return invoker.plugin.Errorf("nil nwCfg passed to CNI DEL: %v", errNilNetworkConfig)
165169
}
166170

167171
if len(invoker.nwInfo.Subnets) > 0 {
@@ -203,7 +207,7 @@ func (invoker *AzureIPAMInvoker) Delete(address *net.IPNet, nwCfg *cni.NetworkCo
203207
return invoker.plugin.Errorf("Failed to release ipv6 address: %v", err)
204208
}
205209
} else {
206-
return invoker.plugin.Errorf("Address is incorrect, not valid IPv4 or IPv6, stack: %+v", string(debug.Stack()))
210+
return invoker.plugin.Errorf("address is incorrect, not valid IPv4 or IPv6: %v", errInvalidIPAddress)
207211
}
208212

209213
return nil

0 commit comments

Comments
 (0)