From 2af93d1805e03ca104b5385dd36adee0b53cec79 Mon Sep 17 00:00:00 2001 From: Claes Mogren Date: Fri, 10 Apr 2020 10:59:25 -0700 Subject: [PATCH] Run make format --- cmd/aws-k8s-agent/main.go | 3 +-- cmd/routed-eni-cni-plugin/cni.go | 6 +++--- cmd/routed-eni-cni-plugin/cni_test.go | 18 +++++++++--------- .../driver/driver_test.go | 9 +++++---- .../driver/mocks/driver_mocks.go | 3 ++- pkg/awsutils/gen_vpc_ip_limits.go | 3 ++- pkg/ipamd/datastore/data_store.go | 8 ++++---- pkg/ipamd/datastore/data_store_test.go | 9 +++++---- pkg/networkutils/network.go | 4 ++-- pkg/utils/logger/config.go | 16 ++++++++-------- 10 files changed, 41 insertions(+), 38 deletions(-) diff --git a/cmd/aws-k8s-agent/main.go b/cmd/aws-k8s-agent/main.go index ae6f82a269..e0da594491 100644 --- a/cmd/aws-k8s-agent/main.go +++ b/cmd/aws-k8s-agent/main.go @@ -26,7 +26,6 @@ const binaryName = "ipamd" var version string - func main() { os.Exit(_main()) } @@ -34,7 +33,7 @@ func main() { func _main() int { //Do not add anything before initializing logger logConfig := logger.Configuration{ - BinaryName: binaryName, + BinaryName: binaryName, } log := logger.New(&logConfig) diff --git a/cmd/routed-eni-cni-plugin/cni.go b/cmd/routed-eni-cni-plugin/cni.go index a28d28cfa1..2a22c852c8 100644 --- a/cmd/routed-eni-cni-plugin/cni.go +++ b/cmd/routed-eni-cni-plugin/cni.go @@ -101,9 +101,9 @@ func LoadNetConf(bytes []byte) (*NetConf, logger.Logger, error) { //logConfig logConfig := logger.Configuration{ - BinaryName: conf.Name, - LogLevel: conf.PluginLogLevel, - LogLocation: conf.PluginLogFile, + BinaryName: conf.Name, + LogLevel: conf.PluginLogLevel, + LogLocation: conf.PluginLogFile, } log := logger.New(&logConfig) diff --git a/cmd/routed-eni-cni-plugin/cni_test.go b/cmd/routed-eni-cni-plugin/cni_test.go index d24562968f..c9f6da7773 100644 --- a/cmd/routed-eni-cni-plugin/cni_test.go +++ b/cmd/routed-eni-cni-plugin/cni_test.go @@ -33,16 +33,16 @@ import ( ) const ( - containerID = "test-container" - netNS = "/proc/ns/1234" - ifName = "eth0" - cniVersion = "1.0" - cniName = "aws-cni" + containerID = "test-container" + netNS = "/proc/ns/1234" + ifName = "eth0" + cniVersion = "1.0" + cniName = "aws-cni" pluginLogLevel = "Debug" - pluginLogFile = "/var/log/aws-routed-eni/plugin.log" - cniType = "aws-cni" - ipAddr = "10.0.1.15" - devNum = 4 + pluginLogFile = "/var/log/aws-routed-eni/plugin.log" + cniType = "aws-cni" + ipAddr = "10.0.1.15" + devNum = 4 ) var netConf = &NetConf{CNIVersion: cniVersion, diff --git a/cmd/routed-eni-cni-plugin/driver/driver_test.go b/cmd/routed-eni-cni-plugin/driver/driver_test.go index c2d4c6c9dc..ab613e2ec4 100644 --- a/cmd/routed-eni-cni-plugin/driver/driver_test.go +++ b/cmd/routed-eni-cni-plugin/driver/driver_test.go @@ -15,11 +15,12 @@ package driver import ( "errors" - "github.com/aws/amazon-vpc-cni-k8s/pkg/utils/logger" "net" "os" "testing" + "github.com/aws/amazon-vpc-cni-k8s/pkg/utils/logger" + "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" @@ -45,9 +46,9 @@ const ( ) var logConfig = logger.Configuration{ - BinaryName: "aws-cni", - LogLevel: "Debug", - LogLocation: "/var/log/test.log", + BinaryName: "aws-cni", + LogLevel: "Debug", + LogLocation: "/var/log/test.log", } var log = logger.New(&logConfig) diff --git a/cmd/routed-eni-cni-plugin/driver/mocks/driver_mocks.go b/cmd/routed-eni-cni-plugin/driver/mocks/driver_mocks.go index 74503e7544..40dc900cc3 100644 --- a/cmd/routed-eni-cni-plugin/driver/mocks/driver_mocks.go +++ b/cmd/routed-eni-cni-plugin/driver/mocks/driver_mocks.go @@ -18,10 +18,11 @@ package mock_driver import ( - "github.com/aws/amazon-vpc-cni-k8s/pkg/utils/logger" net "net" reflect "reflect" + "github.com/aws/amazon-vpc-cni-k8s/pkg/utils/logger" + gomock "github.com/golang/mock/gomock" ) diff --git a/pkg/awsutils/gen_vpc_ip_limits.go b/pkg/awsutils/gen_vpc_ip_limits.go index b4bc80fa2d..7aafd23041 100644 --- a/pkg/awsutils/gen_vpc_ip_limits.go +++ b/pkg/awsutils/gen_vpc_ip_limits.go @@ -18,12 +18,13 @@ package main import ( - "github.com/aws/amazon-vpc-cni-k8s/pkg/utils/logger" "os" "sort" "text/template" "time" + "github.com/aws/amazon-vpc-cni-k8s/pkg/utils/logger" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" diff --git a/pkg/ipamd/datastore/data_store.go b/pkg/ipamd/datastore/data_store.go index f1ad625b41..4a2bda2941 100644 --- a/pkg/ipamd/datastore/data_store.go +++ b/pkg/ipamd/datastore/data_store.go @@ -100,7 +100,7 @@ type ENIIPPool struct { // IsPrimary indicates whether ENI is a primary ENI IsPrimary bool ID string - // DeviceNumber is the device number of ENI + // DeviceNumber is the device number of ENI (0 means the primary ENI) DeviceNumber int // AssignedIPv4Addresses is the number of IP addresses already been assigned AssignedIPv4Addresses int @@ -127,7 +127,7 @@ type PodKey struct { type PodIPInfo struct { // IP is the IP address of pod IP string - // DeviceNumber is the device number of pod + // DeviceNumber is the device number of the ENI DeviceNumber int } @@ -138,7 +138,7 @@ type DataStore struct { eniIPPools map[string]*ENIIPPool podsIP map[PodKey]PodIPInfo lock sync.RWMutex - log logger.Logger + log logger.Logger } // PodInfos contains pods IP information which uses key name_namespace_sandbox @@ -171,7 +171,7 @@ func NewDataStore(log logger.Logger) *DataStore { return &DataStore{ eniIPPools: make(map[string]*ENIIPPool), podsIP: make(map[PodKey]PodIPInfo), - log: log, + log: log, } } diff --git a/pkg/ipamd/datastore/data_store_test.go b/pkg/ipamd/datastore/data_store_test.go index c331a5ff4d..310b66282d 100644 --- a/pkg/ipamd/datastore/data_store_test.go +++ b/pkg/ipamd/datastore/data_store_test.go @@ -14,18 +14,19 @@ package datastore import ( - "github.com/aws/amazon-vpc-cni-k8s/pkg/utils/logger" "testing" "time" + "github.com/aws/amazon-vpc-cni-k8s/pkg/utils/logger" + "github.com/aws/amazon-vpc-cni-k8s/pkg/k8sapi" "github.com/stretchr/testify/assert" ) var logConfig = logger.Configuration{ - BinaryName: "aws-cni", - LogLevel: "Debug", - LogLocation: "/var/log/test.log", + BinaryName: "aws-cni", + LogLevel: "Debug", + LogLocation: "/var/log/test.log", } var log = logger.New(&logConfig) diff --git a/pkg/networkutils/network.go b/pkg/networkutils/network.go index e746319fca..59a3026447 100644 --- a/pkg/networkutils/network.go +++ b/pkg/networkutils/network.go @@ -114,7 +114,7 @@ const ( var log = logger.Get() -// NetworkAPIs defines the host level and the eni level network related operations +// NetworkAPIs defines the host level and the ENI level network related operations type NetworkAPIs interface { // SetupNodeNetwork performs node level network configuration SetupHostNetwork(vpcCIDR *net.IPNet, vpcCIDRs []*string, primaryMAC string, primaryAddr *net.IP) error @@ -254,7 +254,7 @@ func (n *linuxNetwork) SetupHostNetwork(vpcCIDR *net.IPNet, vpcCIDRs []*string, err = n.procSys.Set(primaryIntfRPFilter, rpFilterLoose) if err != nil { return errors.Wrapf(err, "failed to configure %s RPF check", primaryIntf) - } + } } else { log.Infof("Skip updating RPF for primary interface: %s", primaryIntfRPFilter) } diff --git a/pkg/utils/logger/config.go b/pkg/utils/logger/config.go index 4ed19865aa..784d194457 100644 --- a/pkg/utils/logger/config.go +++ b/pkg/utils/logger/config.go @@ -21,21 +21,21 @@ const ( defaultLogFilePath = "/host/var/log/aws-routed-eni/ipamd.log" defaultLogLevel = "Debug" binaryName = "L-IPamD" - envLogLevel = "AWS_VPC_K8S_CNI_LOGLEVEL" - envLogFilePath = "AWS_VPC_K8S_CNI_LOG_FILE" + envLogLevel = "AWS_VPC_K8S_CNI_LOGLEVEL" + envLogFilePath = "AWS_VPC_K8S_CNI_LOG_FILE" ) // Configuration stores the config for the logger type Configuration struct { - BinaryName string - LogLevel string - LogLocation string + BinaryName string + LogLevel string + LogLocation string } func LoadLogConfig() *Configuration { - return &Configuration{ - BinaryName: binaryName, - LogLevel: getLogLevel(), + return &Configuration{ + BinaryName: binaryName, + LogLevel: getLogLevel(), LogLocation: getLogFileLocation(), } }