Skip to content

Commit

Permalink
Merge pull request #910 from vdhanan/useragent
Browse files Browse the repository at this point in the history
add custom useragent suffix
  • Loading branch information
wongma7 authored Jun 2, 2021
2 parents 0476edc + d7cdc89 commit 2b61230
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ VERSION=v1.0.0
VERSION_AMAZONLINUX=$(VERSION)-amazonlinux
GIT_COMMIT?=$(shell git rev-parse HEAD)
BUILD_DATE?=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS?="-X ${PKG}/pkg/driver.driverVersion=${VERSION} -X ${PKG}/pkg/driver.gitCommit=${GIT_COMMIT} -X ${PKG}/pkg/driver.buildDate=${BUILD_DATE} -s -w"
LDFLAGS?="-X ${PKG}/pkg/driver.driverVersion=${VERSION} -X ${PKG}/pkg/cloud.driverVersion=${VERSION} -X ${PKG}/pkg/driver.gitCommit=${GIT_COMMIT} -X ${PKG}/pkg/driver.buildDate=${BUILD_DATE} -s -w"
GO111MODULE=on
GOPROXY=direct
GOPATH=$(shell go env GOPATH)
Expand Down
6 changes: 6 additions & 0 deletions pkg/cloud/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ var (
VolumeNotBeingModified = fmt.Errorf("volume is not being modified")
)

// Set during build time via -ldflags
var driverVersion string

// Disk represents a EBS volume
type Disk struct {
VolumeID string
Expand Down Expand Up @@ -239,6 +242,9 @@ func newEC2Cloud(region string, awsSdkDebugLog bool) (Cloud, error) {
awsConfig.WithLogLevel(aws.LogDebugWithRequestErrors)
}

// Set the env var so that the session appends custom user agent string
os.Setenv("AWS_EXECUTION_ENV", "aws-ebs-csi-driver-"+driverVersion)

svc := ec2.New(session.Must(session.NewSession(awsConfig)))
svc.Handlers.AfterRetry.PushFrontNamed(request.NamedHandler{
Name: "recordThrottledRequestsHandler",
Expand Down

0 comments on commit 2b61230

Please sign in to comment.