return early if CNI state exist and add some style fixes (#1412)
* style: format issues * style: lint issues * style: lint issues * style: moved to new block Co-authored-by: Keith Nguyen <keithnguyen@microsoft.com>
This commit is contained in:
Родитель
b27fb6c281
Коммит
08b07d885e
|
@ -102,6 +102,10 @@ func (invoker *AzureIPAMInvoker) deleteIpamState() {
|
|||
return
|
||||
}
|
||||
|
||||
if cniStateExists {
|
||||
return
|
||||
}
|
||||
|
||||
ipamStateExists, err := platform.CheckIfFileExists(platform.CNIIpamStatePath)
|
||||
if err != nil {
|
||||
log.Printf("[cni] Error checking IPAM state exist: %v", err)
|
||||
|
|
29
ipam/api.go
29
ipam/api.go
|
@ -9,21 +9,17 @@ 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"
|
||||
|
@ -31,3 +27,6 @@ var (
|
|||
OptAddressType = "azure.address.type"
|
||||
OptAddressTypeGateway = "gateway"
|
||||
)
|
||||
|
||||
// Exportable errors returned by AddressManager
|
||||
var ErrNoAvailableAddressPools = fmt.Errorf("no available address pools")
|
||||
|
|
|
@ -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]
|
||||
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
Загрузка…
Ссылка в новой задаче