Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cni/network/invoker_azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ func (invoker *AzureIPAMInvoker) deleteIpamState() {
return
}

if cniStateExists {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: with this we can remove the below !cniStateExists on line 115

return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should put a comment here explaining why we return if cniStateExists. Even for folks that have seen this code path before, it's not immediately obvious.

}

ipamStateExists, err := platform.CheckIfFileExists(platform.CNIIpamStatePath)
if err != nil {
log.Printf("[cni] Error checking IPAM state exist: %v", err)
Expand Down
29 changes: 14 additions & 15 deletions ipam/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,24 @@ import (

var (
// Error responses returned by AddressManager.
errInvalidAddressSpace = fmt.Errorf("Invalid address space")
errInvalidPoolId = fmt.Errorf("Invalid address pool")
errInvalidAddress = fmt.Errorf("Invalid address")
errInvalidScope = fmt.Errorf("Invalid scope")
errInvalidConfiguration = fmt.Errorf("Invalid configuration")
errAddressPoolExists = fmt.Errorf("Address pool already exists")
errAddressPoolNotFound = fmt.Errorf("Address pool not found")
errAddressPoolInUse = fmt.Errorf("Address pool already in use")
errAddressPoolNotInUse = fmt.Errorf("Address pool not in use")
ErrNoAvailableAddressPools = fmt.Errorf("No available address pools")
errAddressExists = fmt.Errorf("Address already exists")
errAddressNotFound = fmt.Errorf("Address not found")
errAddressInUse = fmt.Errorf("Address already in use")
errAddressNotInUse = fmt.Errorf("Address not in use")
errNoAvailableAddresses = fmt.Errorf("No available addresses")
errInvalidAddressSpace = fmt.Errorf("Invalid address space")
errInvalidPoolID = fmt.Errorf("Invalid address pool")
errInvalidAddress = fmt.Errorf("Invalid address")
errInvalidScope = fmt.Errorf("Invalid scope")
errInvalidConfiguration = fmt.Errorf("Invalid configuration")
errAddressPoolExists = fmt.Errorf("Address pool already exists")
errAddressPoolNotFound = fmt.Errorf("Address pool not found")
errAddressExists = fmt.Errorf("Address already exists")
errAddressNotFound = fmt.Errorf("Address not found")
errAddressInUse = fmt.Errorf("Address already in use")
errNoAvailableAddresses = fmt.Errorf("No available addresses")

// Options used by AddressManager.
OptInterfaceName = "azure.interface.name"
OptAddressID = "azure.address.id"
OptAddressType = "azure.address.type"
OptAddressTypeGateway = "gateway"
)

// Exportable errors returned by AddressManager
var ErrNoAvailableAddressPools = fmt.Errorf("no available address pools")
4 changes: 2 additions & 2 deletions ipam/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func NewAddressPoolIdFromString(s string) (*addressPoolId, error) {

p := strings.Split(s, "|")
if len(p) > 3 {
return nil, errInvalidPoolId
return nil, errInvalidPoolID
}

pid.AsId = p[0]
Expand Down Expand Up @@ -282,7 +282,7 @@ func (as *addressSpace) newAddressPool(ifName string, priority int, subnet *net.
func (as *addressSpace) getAddressPool(poolId string) (*addressPool, error) {
ap := as.Pools[poolId]
if ap == nil {
return nil, fmt.Errorf("Pool id %v not found :%v", poolId, errInvalidPoolId)
return nil, fmt.Errorf("Pool id %v not found :%w", poolId, errInvalidPoolID)
}

return ap, nil
Expand Down
2 changes: 1 addition & 1 deletion store/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type jsonFileStore struct {
// NewJsonFileStore creates a new jsonFileStore object, accessed as a KeyValueStore.
func NewJsonFileStore(fileName string, lockclient processlock.Interface) (KeyValueStore, error) {
if fileName == "" {
return &jsonFileStore{}, errors.New("Need to pass in a json file path")
return &jsonFileStore{}, errors.New("need to pass in a json file path")
}
kvs := &jsonFileStore{
fileName: fileName,
Expand Down