Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
luthermonson committed Dec 2, 2023
2 parents 51a712c + 4084b5e commit 630887d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
IMG ?= linode/linode-cloud-controller-manager:canary
RELEASE_DIR ?= release
GOLANGCI_LINT_IMG := golangci/golangci-lint:v1.44-alpine
GOLANGCI_LINT_IMG := golangci/golangci-lint:v1.55-alpine

export GO111MODULE=on

Expand Down
2 changes: 1 addition & 1 deletion cloud/linode/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (c *linodeCloud) ProviderName() string {
return ProviderName
}

func (c *linodeCloud) ScrubDNS(nameservers, searches []string) (nsOut, srchOut []string) {
func (c *linodeCloud) ScrubDNS(_, _ []string) (nsOut, srchOut []string) {
return nil, nil
}

Expand Down
29 changes: 13 additions & 16 deletions cloud/linode/loadbalancers.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func (l *loadbalancers) cleanupOldNodeBalancer(ctx context.Context, service *v1.
// GetLoadBalancerName returns the name of the load balancer.
//
// GetLoadBalancer will not modify service.
func (l *loadbalancers) GetLoadBalancerName(ctx context.Context, clusterName string, service *v1.Service) string {
func (l *loadbalancers) GetLoadBalancerName(_ context.Context, _ string, _ *v1.Service) string {
unixNano := strconv.FormatInt(time.Now().UnixNano(), 16)
return fmt.Sprintf("ccm-%s", unixNano[len(unixNano)-12:])
}
Expand Down Expand Up @@ -279,7 +279,7 @@ func (l *loadbalancers) updateNodeBalancer(ctx context.Context, service *v1.Serv
}
}

tags := l.getLoadbalancerTags(ctx, service)
tags := l.getLoadBalancerTags(ctx, service)
if !reflect.DeepEqual(nb.Tags, tags) {
update := nb.GetUpdateOptions()
update.Tags = &tags
Expand Down Expand Up @@ -432,7 +432,7 @@ func (l *loadbalancers) EnsureLoadBalancerDeleted(ctx context.Context, clusterNa
serviceNn := getServiceNn(service)

if len(service.Status.LoadBalancer.Ingress) == 0 {
klog.Infof("short-circuting deletion of NodeBalancer for service(%s) as LoadBalancer ingress is not present", serviceNn)
klog.Infof("short-circuiting deletion of NodeBalancer for service(%s) as LoadBalancer ingress is not present", serviceNn)
return nil
}

Expand All @@ -442,7 +442,7 @@ func (l *loadbalancers) EnsureLoadBalancerDeleted(ctx context.Context, clusterNa
break

case lbNotFoundError:
klog.Infof("short-circuting deletion for NodeBalancer for service (%s) as one does not exist: %s", serviceNn, err)
klog.Infof("short-circuiting deletion for NodeBalancer for service (%s) as one does not exist: %s", serviceNn, err)
return nil

default:
Expand All @@ -452,7 +452,7 @@ func (l *loadbalancers) EnsureLoadBalancerDeleted(ctx context.Context, clusterNa
}

if l.shouldPreserveNodeBalancer(service) {
klog.Infof("short-circuting deletion of NodeBalancer (%d) for service (%s) as annotated with %s", nb.ID, serviceNn, annLinodeLoadBalancerPreserve)
klog.Infof("short-circuiting deletion of NodeBalancer (%d) for service (%s) as annotated with %s", nb.ID, serviceNn, annLinodeLoadBalancerPreserve)
return nil
}

Expand Down Expand Up @@ -504,7 +504,7 @@ func (l *loadbalancers) getNodeBalancerByID(ctx context.Context, service *v1.Ser
return nb, nil
}

func (l *loadbalancers) getLoadbalancerTags(ctx context.Context, service *v1.Service) []string {
func (l *loadbalancers) getLoadBalancerTags(_ context.Context, service *v1.Service) []string {
tagStr, ok := getServiceAnnotation(service, annLinodeLoadBalancerTags)
if ok {
return strings.Split(tagStr, ",")
Expand All @@ -516,7 +516,7 @@ func (l *loadbalancers) createNodeBalancer(ctx context.Context, clusterName stri
connThrottle := getConnectionThrottle(service)

label := l.GetLoadBalancerName(ctx, clusterName, service)
tags := l.getLoadbalancerTags(ctx, service)
tags := l.getLoadBalancerTags(ctx, service)
createOpts := linodego.NodeBalancerCreateOptions{
Label: &label,
Region: l.zone,
Expand Down Expand Up @@ -706,23 +706,20 @@ func getPortConfig(service *v1.Service, port int) (portConfig, error) {
}
protocol := portConfigAnnotation.Protocol
if protocol == "" {
var ok bool
protocol, ok = service.Annotations[annLinodeDefaultProtocol]
if !ok {
protocol = "tcp"
protocol = "tcp"
if p, ok := service.Annotations[annLinodeDefaultProtocol]; ok {
protocol = p
}
}
protocol = strings.ToLower(protocol)

proxyProtocol := portConfigAnnotation.ProxyProtocol
if proxyProtocol == "" {
var ok bool
proxyProtocol = string(linodego.ProxyProtocolNone)
for _, ann := range []string{annLinodeDefaultProxyProtocol, annLinodeProxyProtocolDeprecated} {
proxyProtocol, ok = service.Annotations[ann]
if ok {
if pp, ok := service.Annotations[ann]; ok {
proxyProtocol = pp
break
} else {
proxyProtocol = string(linodego.ProxyProtocolNone)
}
}
}
Expand Down
12 changes: 5 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ package main

import (
"context"
goflag "flag"
"flag"
"fmt"
"math/rand"
"os"
"time"

"github.com/linode/linode-cloud-controller-manager/cloud/linode"
"github.com/linode/linode-cloud-controller-manager/sentry"
"github.com/spf13/pflag"

"k8s.io/apimachinery/pkg/util/wait"
cloudprovider "k8s.io/cloud-provider"
"k8s.io/cloud-provider/app"
"k8s.io/cloud-provider/app/config"
"k8s.io/cloud-provider/options"
utilflag "k8s.io/component-base/cli/flag"
"k8s.io/component-base/logs"
"k8s.io/klog"

_ "k8s.io/component-base/metrics/prometheus/clientgo" // for client metric registration
_ "k8s.io/component-base/metrics/prometheus/version" // for version metric registration
"k8s.io/klog"
)

const (
Expand Down Expand Up @@ -67,8 +67,6 @@ func main() {

ctx := sentry.SetHubOnContext(context.Background())

rand.Seed(time.Now().UTC().UnixNano())

ccmOptions, err := options.NewCloudControllerManagerOptions()
if err != nil {
klog.Fatalf("unable to initialize command options: %v", err)
Expand Down Expand Up @@ -111,7 +109,7 @@ func main() {
}

pflag.CommandLine.SetNormalizeFunc(utilflag.WordSepNormalizeFunc)
pflag.CommandLine.AddGoFlagSet(goflag.CommandLine)
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)

logs.InitLogs()
defer logs.FlushLogs()
Expand Down

0 comments on commit 630887d

Please sign in to comment.