Skip to content

Commit

Permalink
fixed the logger issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jeswinkoshyninan committed May 14, 2024
1 parent 7b3f80d commit 663315e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package main

import (
"os"

elbv2deploy "sigs.k8s.io/aws-load-balancer-controller/pkg/deploy/elbv2"

"github.com/go-logr/logr"
Expand Down Expand Up @@ -76,7 +77,7 @@ func main() {
}
ctrl.SetLogger(getLoggerWithLogLevel(controllerCFG.LogLevel))

cloud, err := aws.NewCloud(controllerCFG.AWSConfig, metrics.Registry)
cloud, err := aws.NewCloud(controllerCFG.AWSConfig, metrics.Registry, ctrl.Log)
if err != nil {
setupLog.Error(err, "unable to initialize AWS cloud")
os.Exit(1)
Expand Down
9 changes: 4 additions & 5 deletions pkg/aws/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type Cloud interface {
}

// NewCloud constructs new Cloud implementation.
func NewCloud(cfg CloudConfig, metricsRegisterer prometheus.Registerer) (Cloud, error) {
func NewCloud(cfg CloudConfig, metricsRegisterer prometheus.Registerer, logger logr.Logger) (Cloud, error) {
hasIPv4 := true
addrs, err := net.InterfaceAddrs()
if err == nil {
Expand Down Expand Up @@ -114,7 +114,7 @@ func NewCloud(cfg CloudConfig, metricsRegisterer prometheus.Registerer) (Cloud,

ec2Service := services.NewEC2(sess)

vpcID, err := getVpcID(cfg, ec2Service, metadata)
vpcID, err := getVpcID(cfg, ec2Service, metadata, logger)
if err != nil {
return nil, errors.Wrap(err, "failed to get VPC ID")
}
Expand All @@ -131,11 +131,10 @@ func NewCloud(cfg CloudConfig, metricsRegisterer prometheus.Registerer) (Cloud,
}, nil
}

func getVpcID(cfg CloudConfig, ec2Service services.EC2, metadata services.EC2Metadata) (string, error) {
func getVpcID(cfg CloudConfig, ec2Service services.EC2, metadata services.EC2Metadata, logger logr.Logger) (string, error) {

logger := logr.Logger{}
if cfg.VpcID != "" {
logger.V(1).Info("vpcid is specified using flag --aws-vpc-id, controller will use the value %s", cfg.VpcID)
logger.V(1).Info("vpcid is specified using flag --aws-vpc-id, controller will use the value", "vpc: ", cfg.VpcID)
return cfg.VpcID, nil
}

Expand Down

0 comments on commit 663315e

Please sign in to comment.