Skip to content
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
19 changes: 4 additions & 15 deletions cloud/linode/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@ var supportedLoadBalancerTypes = []string{ciliumLBType, nodeBalancerLBType}
// We expect it to be initialized with flags external to this package, likely in
// main.go
var Options struct {
KubeconfigFlag *pflag.Flag
LinodeGoDebug bool
EnableRouteController bool
EnableTokenHealthChecker bool
// Deprecated: use VPCNames instead
VPCName string
KubeconfigFlag *pflag.Flag
LinodeGoDebug bool
EnableRouteController bool
EnableTokenHealthChecker bool
VPCNames string
SubnetNames string
LoadBalancerType string
Expand Down Expand Up @@ -138,15 +136,6 @@ func newCloud() (cloudprovider.Interface, error) {
healthChecker = newHealthChecker(linodeClient, tokenHealthCheckPeriod, Options.GlobalStopChannel)
}

if Options.VPCName != "" && Options.VPCNames != "" {
return nil, fmt.Errorf("cannot have both vpc-name and vpc-names set")
}

if Options.VPCName != "" {
klog.Warningf("vpc-name flag is deprecated. Use vpc-names instead")
Options.VPCNames = Options.VPCName
}

// SubnetNames can't be used without VPCNames also being set
if Options.SubnetNames != "" && Options.VPCNames == "" {
klog.Warningf("failed to set flag subnet-names: vpc-names must be set to a non-empty value")
Expand Down
27 changes: 2 additions & 25 deletions cloud/linode/cloud_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
cloudprovider "k8s.io/cloud-provider"

"github.com/linode/linode-cloud-controller-manager/cloud/linode/client/mocks"
Expand All @@ -22,14 +21,14 @@ func TestNewCloudRouteControllerDisabled(t *testing.T) {
t.Setenv("LINODE_REQUEST_TIMEOUT_SECONDS", "10")

t.Run("should not fail if vpc is empty and routecontroller is disabled", func(t *testing.T) {
Options.VPCName = ""
Options.VPCNames = ""
Options.EnableRouteController = false
_, err := newCloud()
assert.NoError(t, err)
})

t.Run("fail if vpcname is empty and routecontroller is enabled", func(t *testing.T) {
Options.VPCName = ""
Options.VPCNames = ""
Options.EnableRouteController = true
_, err := newCloud()
assert.Error(t, err)
Expand Down Expand Up @@ -58,28 +57,6 @@ func TestNewCloud(t *testing.T) {
assert.Error(t, err, "expected error when linode region is empty")
})

t.Run("should fail if both vpcname and vpcnames are set", func(t *testing.T) {
Options.VPCName = "tt"
Options.VPCNames = "tt"
defer func() {
Options.VPCName = ""
Options.VPCNames = ""
}()
_, err := newCloud()
assert.Error(t, err, "expected error when both vpcname and vpcnames are set")
})

t.Run("should not fail if deprecated vpcname is set", func(t *testing.T) {
Options.VPCName = "tt"
defer func() {
Options.VPCName = ""
Options.VPCNames = ""
}()
_, err := newCloud()
require.NoError(t, err, "expected no error if deprecated flag vpcname is set")
assert.Equal(t, "tt", Options.VPCNames, "expected vpcnames to be set to vpcname")
})

t.Run("should fail if both nodeBalancerBackendIPv4SubnetID and nodeBalancerBackendIPv4SubnetName are set", func(t *testing.T) {
Options.VPCNames = "tt"
Options.NodeBalancerBackendIPv4SubnetID = 12345
Expand Down
14 changes: 2 additions & 12 deletions deploy/chart/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,6 @@ spec:
{{- if and .Values.routeController .Values.routeController.vpcNames }}
{{- $vpcNames = .Values.routeController.vpcNames }}
{{- end }}
{{- $vpcName := .Values.vpcName }}
{{- if and .Values.routeController .Values.routeController.vpcName }}
{{- $vpcName = .Values.routeController.vpcName }}
{{- end }}
{{- if and $vpcName $vpcNames }}
{{- fail "Both vpcName and vpcNames are set. Please use only vpcNames." }}
{{- end }}
{{- $subnetNames := .Values.subnetNames }}
{{- if and .Values.routeController .Values.routeController.subnetNames }}
{{- $subnetNames = .Values.routeController.subnetNames }}
Expand All @@ -106,8 +99,8 @@ spec:
{{- end }}
{{- if .Values.routeController }}
- --enable-route-controller=true
{{- if not (or $vpcName $vpcNames) }}
{{- fail "Neither vpcName nor vpcNames is set. Please set one of them." }}
{{- if not $vpcNames }}
{{- fail "vpcNames not set. Please set it when enabling route_controller for VPCs." }}
{{- end }}
{{- if not $clusterCIDR }}
{{- fail "clusterCIDR is required if route-controller is enabled" }}
Expand All @@ -120,9 +113,6 @@ spec:
{{- with $vpcNames }}
- --vpc-names={{ . }}
{{- end }}
{{- with $vpcName }}
- --vpc-name={{ . }}
{{- end }}
{{- with $subnetNames }}
- --subnet-names={{ . }}
{{- end }}
Expand Down
2 changes: 0 additions & 2 deletions deploy/chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ tolerations:

# This section adds ability to enable route-controller for ccm
# routeController:
# vpcName: <name of VPC> [Deprecated: use vpcNames instead]
# vpcNames: <comma separated list of vpc names>
# subnetNames: <comma separated list of subnet names>
# clusterCIDR: 10.192.0.0/10
Expand All @@ -88,7 +87,6 @@ tolerations:
# nodeCIDRMaskSizeIPv6: 64

# vpcs and subnets that node internal IPs will be assigned from (not required if already specified in routeController)
# vpcName: <name of VPC> [Deprecated: use vpcNames instead]
# vpcNames: <comma separated list of vpc names>
# subnetNames: <comma separated list of subnet names>

Expand Down
1 change: 0 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ func main() {
command.Flags().BoolVar(&linode.Options.LinodeGoDebug, "linodego-debug", false, "enables debug output for the LinodeAPI wrapper")
command.Flags().BoolVar(&linode.Options.EnableRouteController, "enable-route-controller", false, "enables route_controller for ccm")
command.Flags().BoolVar(&linode.Options.EnableTokenHealthChecker, "enable-token-health-checker", false, "enables Linode API token health checker")
command.Flags().StringVar(&linode.Options.VPCName, "vpc-name", "", "[deprecated: use vpc-names instead] vpc name whose routes will be managed by route-controller")
command.Flags().StringVar(&linode.Options.VPCNames, "vpc-names", "", "comma separated vpc names whose routes will be managed by route-controller")
command.Flags().StringVar(&linode.Options.SubnetNames, "subnet-names", "default", "comma separated subnet names whose routes will be managed by route-controller (requires vpc-names flag to also be set)")
command.Flags().StringVar(&linode.Options.LoadBalancerType, "load-balancer-type", "nodebalancer", "configures which type of load-balancing to use for LoadBalancer Services (options: nodebalancer, cilium-bgp)")
Expand Down
Loading