Skip to content

Commit 61b081f

Browse files
jchen6585jdn5126
authored andcommitted
Fix unused version variable
1 parent 73ccf51 commit 61b081f

File tree

11 files changed

+27
-14
lines changed

11 files changed

+27
-14
lines changed

charts/aws-vpc-cni/values.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ env:
7878
DISABLE_NETWORK_RESOURCE_PROVISIONING: "false"
7979
ENABLE_IPv4: "true"
8080
ENABLE_IPv6: "false"
81+
VPC_CNI_VERSION: "v1.15.0"
8182

8283
# this flag enables you to use the match label that was present in the original daemonset deployed by EKS
8384
# You can then annotate and label the original aws-node resources and 'adopt' them into a helm release

cmd/aws-k8s-agent/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func _main() int {
4040
version.RegisterMetric()
4141

4242
// Check API Server Connectivity
43-
if err := k8sapi.CheckAPIServerConnectivity(appName); err != nil {
43+
if err := k8sapi.CheckAPIServerConnectivity(); err != nil {
4444
log.Errorf("Failed to check API server connectivity: %s", err)
4545
return 1
4646
}

cmd/cni-metrics-helper/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func main() {
105105

106106
log.Infof("Starting CNIMetricsHelper. Sending metrics to CloudWatch: %v, LogLevel %s, metricUpdateInterval %d", options.submitCW, logConfig.LogLevel, metricUpdateInterval)
107107

108-
clientSet, err := k8sapi.GetKubeClientSet(appName)
108+
clientSet, err := k8sapi.GetKubeClientSet()
109109
if err != nil {
110110
log.Fatalf("Error Fetching Kubernetes Client: %s", err)
111111
os.Exit(1)

config/master/aws-k8s-cni-cn.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,8 @@ spec:
459459
value: "false"
460460
- name: ENABLE_PREFIX_DELEGATION
461461
value: "false"
462+
- name: VPC_CNI_VERSION
463+
value: "v1.15.0"
462464
- name: WARM_ENI_TARGET
463465
value: "1"
464466
- name: WARM_PREFIX_TARGET

config/master/aws-k8s-cni-us-gov-east-1.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,8 @@ spec:
459459
value: "false"
460460
- name: ENABLE_PREFIX_DELEGATION
461461
value: "false"
462+
- name: VPC_CNI_VERSION
463+
value: "v1.15.0"
462464
- name: WARM_ENI_TARGET
463465
value: "1"
464466
- name: WARM_PREFIX_TARGET

config/master/aws-k8s-cni-us-gov-west-1.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,8 @@ spec:
459459
value: "false"
460460
- name: ENABLE_PREFIX_DELEGATION
461461
value: "false"
462+
- name: VPC_CNI_VERSION
463+
value: "v1.15.0"
462464
- name: WARM_ENI_TARGET
463465
value: "1"
464466
- name: WARM_PREFIX_TARGET

config/master/aws-k8s-cni.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,8 @@ spec:
459459
value: "false"
460460
- name: ENABLE_PREFIX_DELEGATION
461461
value: "false"
462+
- name: VPC_CNI_VERSION
463+
value: "v1.15.0"
462464
- name: WARM_ENI_TARGET
463465
value: "1"
464466
- name: WARM_PREFIX_TARGET

pkg/awsutils/awssession/session.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"time"
2323

2424
"github.com/aws/amazon-vpc-cni-k8s/pkg/utils/logger"
25+
"github.com/aws/amazon-vpc-cni-k8s/utils"
2526
"github.com/aws/aws-sdk-go/aws"
2627
"github.com/aws/aws-sdk-go/aws/endpoints"
2728
"github.com/aws/aws-sdk-go/aws/request"
@@ -31,13 +32,13 @@ import (
3132

3233
// Http client timeout env for sessions
3334
const (
34-
httpTimeoutEnv = "HTTP_TIMEOUT"
35-
maxRetries = 10
35+
httpTimeoutEnv = "HTTP_TIMEOUT"
36+
maxRetries = 10
37+
envVpcCniVersion = "VPC_CNI_VERSION"
3638
)
3739

3840
var (
39-
version string
40-
log = logger.Get()
41+
log = logger.Get()
4142
// HTTP timeout default value in seconds (10 seconds)
4243
httpTimeoutValue = 10 * time.Second
4344
)
@@ -89,6 +90,7 @@ func New() *session.Session {
8990

9091
// injectUserAgent will inject app specific user-agent into awsSDK
9192
func injectUserAgent(handlers *request.Handlers) {
93+
version := utils.GetEnv(envVpcCniVersion, "")
9294
handlers.Build.PushFrontNamed(request.NamedHandler{
9395
Name: fmt.Sprintf("%s/user-agent", "amazon-vpc-cni-k8s"),
9496
Fn: request.MakeAddToUserAgentHandler(

pkg/k8sapi/k8sutils.go

+8-7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
eniconfigscheme "github.com/aws/amazon-vpc-cni-k8s/pkg/apis/crd/v1alpha1"
1515
"github.com/aws/amazon-vpc-cni-k8s/pkg/utils/logger"
16+
"github.com/aws/amazon-vpc-cni-k8s/utils"
1617
rcscheme "github.com/aws/amazon-vpc-resource-controller-k8s/apis/vpcresources/v1alpha1"
1718
"k8s.io/apimachinery/pkg/runtime"
1819
"k8s.io/apimachinery/pkg/util/wait"
@@ -86,7 +87,7 @@ func StartKubeClientCache(cache cache.Cache) {
8687

8788
// CreateKubeClient creates a k8s client
8889
func CreateKubeClient(appName string) (client.Client, error) {
89-
restCfg, err := getRestConfig(appName)
90+
restCfg, err := getRestConfig()
9091
if err != nil {
9192
return nil, err
9293
}
@@ -122,9 +123,9 @@ func CreateKubeClient(appName string) (client.Client, error) {
122123
return k8sClient, nil
123124
}
124125

125-
func GetKubeClientSet(appName string) (kubernetes.Interface, error) {
126+
func GetKubeClientSet() (kubernetes.Interface, error) {
126127
// creates the in-cluster config
127-
config, err := getRestConfig(appName)
128+
config, err := getRestConfig()
128129
if err != nil {
129130
return nil, err
130131
}
@@ -137,8 +138,8 @@ func GetKubeClientSet(appName string) (kubernetes.Interface, error) {
137138
return clientSet, nil
138139
}
139140

140-
func CheckAPIServerConnectivity(appName string) error {
141-
restCfg, err := getRestConfig(appName)
141+
func CheckAPIServerConnectivity() error {
142+
restCfg, err := getRestConfig()
142143
if err != nil {
143144
return err
144145
}
@@ -166,12 +167,12 @@ func CheckAPIServerConnectivity(appName string) error {
166167
})
167168
}
168169

169-
func getRestConfig(appName string) (*rest.Config, error) {
170+
func getRestConfig() (*rest.Config, error) {
170171
restCfg, err := ctrl.GetConfig()
171172
if err != nil {
172173
return nil, err
173174
}
174-
restCfg.UserAgent = appName
175+
restCfg.UserAgent = os.Args[0] + "-" + utils.GetEnv("VPC_CNI_VERSION", "")
175176
if endpoint, ok := os.LookupEnv("CLUSTER_ENDPOINT"); ok {
176177
restCfg.Host = endpoint
177178
}

pkg/utils/eventrecorder/eventrecorder.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ type EventRecorder struct {
5050
}
5151

5252
func Init(k8sClient client.Client) error {
53-
clientSet, err := k8sapi.GetKubeClientSet(appName)
53+
clientSet, err := k8sapi.GetKubeClientSet()
5454
if err != nil {
5555
log.Fatalf("Error Fetching Kubernetes Client: %s", err)
5656
return err

scripts/generate-cni-yaml.sh

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ jq -c '.[]' $REGIONS_FILE | while read i; do
7979
--set nodeAgent.image.region=$ecrRegion \
8080
--set nodeAgent.image.domain=$ecrDomain \
8181
--set nodeAgent.image.tag=$NODE_AGENT_VERSION \
82+
--set env.VPC_CNI_VERSION=$VPC_CNI_VERSION \
8283
--namespace $NAMESPACE \
8384
$SCRIPTPATH/../charts/aws-vpc-cni > $NEW_CNI_RESOURCES_YAML
8485
# Remove 'managed-by: Helm' annotation

0 commit comments

Comments
 (0)