Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Less verbose logging #908

Merged
merged 2 commits into from
Apr 14, 2020
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
3 changes: 1 addition & 2 deletions cmd/aws-k8s-agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@ const binaryName = "ipamd"

var version string


func main() {
os.Exit(_main())
}

func _main() int {
//Do not add anything before initializing logger
logConfig := logger.Configuration{
BinaryName: binaryName,
BinaryName: binaryName,
}
log := logger.New(&logConfig)

Expand Down
6 changes: 3 additions & 3 deletions cmd/routed-eni-cni-plugin/cni.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
18 changes: 9 additions & 9 deletions cmd/routed-eni-cni-plugin/cni_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 5 additions & 4 deletions cmd/routed-eni-cni-plugin/driver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion cmd/routed-eni-cni-plugin/driver/mocks/driver_mocks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pkg/awsutils/gen_vpc_ip_limits.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions pkg/ipamd/datastore/data_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

Expand All @@ -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
Expand Down Expand Up @@ -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,
}
}

Expand Down
9 changes: 5 additions & 4 deletions pkg/ipamd/datastore/data_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/k8sapi/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func (d *Controller) handlePodUpdate(key string) error {
d.workerPodsLock.Lock()
defer d.workerPodsLock.Unlock()

log.Debugf("Update for pod %s: %+v, %+v", podName, pod.Status, pod.Spec)
log.Debugf("Update for pod %s: %v", podName, pod.Status.Phase)
Copy link
Contributor

Choose a reason for hiding this comment

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

++


// Save pod info
d.workerPods[key] = &K8SPodInfo{
Expand Down
4 changes: 2 additions & 2 deletions pkg/networkutils/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down
16 changes: 8 additions & 8 deletions pkg/utils/logger/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
}
Expand Down