Skip to content

Commit

Permalink
Fix unused version variable (#2566)
Browse files Browse the repository at this point in the history
  • Loading branch information
jchen6585 authored Sep 15, 2023
1 parent 73ccf51 commit a774eb8
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 14 deletions.
1 change: 1 addition & 0 deletions charts/aws-vpc-cni/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ env:
DISABLE_NETWORK_RESOURCE_PROVISIONING: "false"
ENABLE_IPv4: "true"
ENABLE_IPv6: "false"
VPC_CNI_VERSION: "v1.15.0"

# this flag enables you to use the match label that was present in the original daemonset deployed by EKS
# You can then annotate and label the original aws-node resources and 'adopt' them into a helm release
Expand Down
2 changes: 1 addition & 1 deletion cmd/aws-k8s-agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func _main() int {
version.RegisterMetric()

// Check API Server Connectivity
if err := k8sapi.CheckAPIServerConnectivity(appName); err != nil {
if err := k8sapi.CheckAPIServerConnectivity(); err != nil {
log.Errorf("Failed to check API server connectivity: %s", err)
return 1
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/cni-metrics-helper/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func main() {

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

clientSet, err := k8sapi.GetKubeClientSet(appName)
clientSet, err := k8sapi.GetKubeClientSet()
if err != nil {
log.Fatalf("Error Fetching Kubernetes Client: %s", err)
os.Exit(1)
Expand Down
2 changes: 2 additions & 0 deletions config/master/aws-k8s-cni-cn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,8 @@ spec:
value: "false"
- name: ENABLE_PREFIX_DELEGATION
value: "false"
- name: VPC_CNI_VERSION
value: "v1.15.0"
- name: WARM_ENI_TARGET
value: "1"
- name: WARM_PREFIX_TARGET
Expand Down
2 changes: 2 additions & 0 deletions config/master/aws-k8s-cni-us-gov-east-1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,8 @@ spec:
value: "false"
- name: ENABLE_PREFIX_DELEGATION
value: "false"
- name: VPC_CNI_VERSION
value: "v1.15.0"
- name: WARM_ENI_TARGET
value: "1"
- name: WARM_PREFIX_TARGET
Expand Down
2 changes: 2 additions & 0 deletions config/master/aws-k8s-cni-us-gov-west-1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,8 @@ spec:
value: "false"
- name: ENABLE_PREFIX_DELEGATION
value: "false"
- name: VPC_CNI_VERSION
value: "v1.15.0"
- name: WARM_ENI_TARGET
value: "1"
- name: WARM_PREFIX_TARGET
Expand Down
2 changes: 2 additions & 0 deletions config/master/aws-k8s-cni.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,8 @@ spec:
value: "false"
- name: ENABLE_PREFIX_DELEGATION
value: "false"
- name: VPC_CNI_VERSION
value: "v1.15.0"
- name: WARM_ENI_TARGET
value: "1"
- name: WARM_PREFIX_TARGET
Expand Down
10 changes: 6 additions & 4 deletions pkg/awsutils/awssession/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"time"

"github.com/aws/amazon-vpc-cni-k8s/pkg/utils/logger"
"github.com/aws/amazon-vpc-cni-k8s/utils"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/endpoints"
"github.com/aws/aws-sdk-go/aws/request"
Expand All @@ -31,13 +32,13 @@ import (

// Http client timeout env for sessions
const (
httpTimeoutEnv = "HTTP_TIMEOUT"
maxRetries = 10
httpTimeoutEnv = "HTTP_TIMEOUT"
maxRetries = 10
envVpcCniVersion = "VPC_CNI_VERSION"
)

var (
version string
log = logger.Get()
log = logger.Get()
// HTTP timeout default value in seconds (10 seconds)
httpTimeoutValue = 10 * time.Second
)
Expand Down Expand Up @@ -89,6 +90,7 @@ func New() *session.Session {

// injectUserAgent will inject app specific user-agent into awsSDK
func injectUserAgent(handlers *request.Handlers) {
version := utils.GetEnv(envVpcCniVersion, "")
handlers.Build.PushFrontNamed(request.NamedHandler{
Name: fmt.Sprintf("%s/user-agent", "amazon-vpc-cni-k8s"),
Fn: request.MakeAddToUserAgentHandler(
Expand Down
15 changes: 8 additions & 7 deletions pkg/k8sapi/k8sutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

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

// CreateKubeClient creates a k8s client
func CreateKubeClient(appName string) (client.Client, error) {
restCfg, err := getRestConfig(appName)
restCfg, err := getRestConfig()
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -122,9 +123,9 @@ func CreateKubeClient(appName string) (client.Client, error) {
return k8sClient, nil
}

func GetKubeClientSet(appName string) (kubernetes.Interface, error) {
func GetKubeClientSet() (kubernetes.Interface, error) {
// creates the in-cluster config
config, err := getRestConfig(appName)
config, err := getRestConfig()
if err != nil {
return nil, err
}
Expand All @@ -137,8 +138,8 @@ func GetKubeClientSet(appName string) (kubernetes.Interface, error) {
return clientSet, nil
}

func CheckAPIServerConnectivity(appName string) error {
restCfg, err := getRestConfig(appName)
func CheckAPIServerConnectivity() error {
restCfg, err := getRestConfig()
if err != nil {
return err
}
Expand Down Expand Up @@ -166,12 +167,12 @@ func CheckAPIServerConnectivity(appName string) error {
})
}

func getRestConfig(appName string) (*rest.Config, error) {
func getRestConfig() (*rest.Config, error) {
restCfg, err := ctrl.GetConfig()
if err != nil {
return nil, err
}
restCfg.UserAgent = appName
restCfg.UserAgent = os.Args[0] + "-" + utils.GetEnv("VPC_CNI_VERSION", "")
if endpoint, ok := os.LookupEnv("CLUSTER_ENDPOINT"); ok {
restCfg.Host = endpoint
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/eventrecorder/eventrecorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type EventRecorder struct {
}

func Init(k8sClient client.Client) error {
clientSet, err := k8sapi.GetKubeClientSet(appName)
clientSet, err := k8sapi.GetKubeClientSet()
if err != nil {
log.Fatalf("Error Fetching Kubernetes Client: %s", err)
return err
Expand Down
1 change: 1 addition & 0 deletions scripts/generate-cni-yaml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ jq -c '.[]' $REGIONS_FILE | while read i; do
--set nodeAgent.image.region=$ecrRegion \
--set nodeAgent.image.domain=$ecrDomain \
--set nodeAgent.image.tag=$NODE_AGENT_VERSION \
--set env.VPC_CNI_VERSION=$VPC_CNI_VERSION \
--namespace $NAMESPACE \
$SCRIPTPATH/../charts/aws-vpc-cni > $NEW_CNI_RESOURCES_YAML
# Remove 'managed-by: Helm' annotation
Expand Down

0 comments on commit a774eb8

Please sign in to comment.