Skip to content

Commit 974299b

Browse files
authored
remove deprecated vpcname flag (#417)
1 parent 77d65e1 commit 974299b

File tree

5 files changed

+8
-55
lines changed

5 files changed

+8
-55
lines changed

cloud/linode/cloud.go

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,10 @@ var supportedLoadBalancerTypes = []string{ciliumLBType, nodeBalancerLBType}
3535
// We expect it to be initialized with flags external to this package, likely in
3636
// main.go
3737
var Options struct {
38-
KubeconfigFlag *pflag.Flag
39-
LinodeGoDebug bool
40-
EnableRouteController bool
41-
EnableTokenHealthChecker bool
42-
// Deprecated: use VPCNames instead
43-
VPCName string
38+
KubeconfigFlag *pflag.Flag
39+
LinodeGoDebug bool
40+
EnableRouteController bool
41+
EnableTokenHealthChecker bool
4442
VPCNames string
4543
SubnetNames string
4644
LoadBalancerType string
@@ -141,15 +139,6 @@ func newCloud() (cloudprovider.Interface, error) {
141139
healthChecker = newHealthChecker(linodeClient, tokenHealthCheckPeriod, Options.GlobalStopChannel)
142140
}
143141

144-
if Options.VPCName != "" && Options.VPCNames != "" {
145-
return nil, fmt.Errorf("cannot have both vpc-name and vpc-names set")
146-
}
147-
148-
if Options.VPCName != "" {
149-
klog.Warningf("vpc-name flag is deprecated. Use vpc-names instead")
150-
Options.VPCNames = Options.VPCName
151-
}
152-
153142
// SubnetNames can't be used without VPCNames also being set
154143
if Options.SubnetNames != "" && Options.VPCNames == "" {
155144
klog.Warningf("failed to set flag subnet-names: vpc-names must be set to a non-empty value")

cloud/linode/cloud_test.go

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77

88
"github.com/golang/mock/gomock"
99
"github.com/stretchr/testify/assert"
10-
"github.com/stretchr/testify/require"
1110
cloudprovider "k8s.io/cloud-provider"
1211

1312
"github.com/linode/linode-cloud-controller-manager/cloud/linode/client/mocks"
@@ -23,14 +22,14 @@ func TestNewCloudRouteControllerDisabled(t *testing.T) {
2322
Options.NodeBalancerPrefix = "ccm"
2423

2524
t.Run("should not fail if vpc is empty and routecontroller is disabled", func(t *testing.T) {
26-
Options.VPCName = ""
25+
Options.VPCNames = ""
2726
Options.EnableRouteController = false
2827
_, err := newCloud()
2928
assert.NoError(t, err)
3029
})
3130

3231
t.Run("fail if vpcname is empty and routecontroller is enabled", func(t *testing.T) {
33-
Options.VPCName = ""
32+
Options.VPCNames = ""
3433
Options.EnableRouteController = true
3534
_, err := newCloud()
3635
assert.Error(t, err)
@@ -60,28 +59,6 @@ func TestNewCloud(t *testing.T) {
6059
assert.Error(t, err, "expected error when linode region is empty")
6160
})
6261

63-
t.Run("should fail if both vpcname and vpcnames are set", func(t *testing.T) {
64-
Options.VPCName = "tt"
65-
Options.VPCNames = "tt"
66-
defer func() {
67-
Options.VPCName = ""
68-
Options.VPCNames = ""
69-
}()
70-
_, err := newCloud()
71-
assert.Error(t, err, "expected error when both vpcname and vpcnames are set")
72-
})
73-
74-
t.Run("should not fail if deprecated vpcname is set", func(t *testing.T) {
75-
Options.VPCName = "tt"
76-
defer func() {
77-
Options.VPCName = ""
78-
Options.VPCNames = ""
79-
}()
80-
_, err := newCloud()
81-
require.NoError(t, err, "expected no error if deprecated flag vpcname is set")
82-
assert.Equal(t, "tt", Options.VPCNames, "expected vpcnames to be set to vpcname")
83-
})
84-
8562
t.Run("should fail if both nodeBalancerBackendIPv4SubnetID and nodeBalancerBackendIPv4SubnetName are set", func(t *testing.T) {
8663
Options.VPCNames = "tt"
8764
Options.NodeBalancerBackendIPv4SubnetID = 12345

deploy/chart/templates/daemonset.yaml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,6 @@ spec:
7979
{{- if and .Values.routeController .Values.routeController.vpcNames }}
8080
{{- $vpcNames = .Values.routeController.vpcNames }}
8181
{{- end }}
82-
{{- $vpcName := .Values.vpcName }}
83-
{{- if and .Values.routeController .Values.routeController.vpcName }}
84-
{{- $vpcName = .Values.routeController.vpcName }}
85-
{{- end }}
86-
{{- if and $vpcName $vpcNames }}
87-
{{- fail "Both vpcName and vpcNames are set. Please use only vpcNames." }}
88-
{{- end }}
8982
{{- $subnetNames := .Values.subnetNames }}
9083
{{- if and .Values.routeController .Values.routeController.subnetNames }}
9184
{{- $subnetNames = .Values.routeController.subnetNames }}
@@ -106,8 +99,8 @@ spec:
10699
{{- end }}
107100
{{- if .Values.routeController }}
108101
- --enable-route-controller=true
109-
{{- if not (or $vpcName $vpcNames) }}
110-
{{- fail "Neither vpcName nor vpcNames is set. Please set one of them." }}
102+
{{- if not $vpcNames }}
103+
{{- fail "vpcNames not set. Please set it when enabling route_controller for VPCs." }}
111104
{{- end }}
112105
{{- if not $clusterCIDR }}
113106
{{- fail "clusterCIDR is required if route-controller is enabled" }}
@@ -120,9 +113,6 @@ spec:
120113
{{- with $vpcNames }}
121114
- --vpc-names={{ . }}
122115
{{- end }}
123-
{{- with $vpcName }}
124-
- --vpc-name={{ . }}
125-
{{- end }}
126116
{{- with $subnetNames }}
127117
- --subnet-names={{ . }}
128118
{{- end }}

deploy/chart/values.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ tolerations:
7575

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

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

main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ func main() {
8383
command.Flags().BoolVar(&linode.Options.LinodeGoDebug, "linodego-debug", false, "enables debug output for the LinodeAPI wrapper")
8484
command.Flags().BoolVar(&linode.Options.EnableRouteController, "enable-route-controller", false, "enables route_controller for ccm")
8585
command.Flags().BoolVar(&linode.Options.EnableTokenHealthChecker, "enable-token-health-checker", false, "enables Linode API token health checker")
86-
command.Flags().StringVar(&linode.Options.VPCName, "vpc-name", "", "[deprecated: use vpc-names instead] vpc name whose routes will be managed by route-controller")
8786
command.Flags().StringVar(&linode.Options.VPCNames, "vpc-names", "", "comma separated vpc names whose routes will be managed by route-controller")
8887
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)")
8988
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)")

0 commit comments

Comments
 (0)