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
13 changes: 7 additions & 6 deletions azurebs/client/storage_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,13 @@ func buildClientOptions(storageConfig config.AZStorageConfig) (*azcore.ClientOpt
return nil, nil
}

// Mirror the default transport built by azcore's runtime package
// (runtime/transport_default_http_client.go). Its defaultHTTPClient and the
// underlying transport are unexported and cannot be reused directly, so we
// replicate the settings here to preserve the SDK's tuned defaults while
// applying our custom timeouts. Keep this in sync with the pinned SDK
// version: github.com/Azure/azure-sdk-for-go/sdk/azcore@v1.23.1.
// Mirror the default transport built by the Azure SDK's shared transport
// package (github.com/Azure/azure-sdk-for-go/sdk/internal transport.go).
// Its DefaultHTTPClient and the underlying transport cannot be reused
// directly while applying our custom timeouts, so we replicate the settings
// here to preserve the SDK's tuned defaults. Keep this in sync with the
// pinned version: github.com/Azure/azure-sdk-for-go/sdk/internal@v1.13.0
// (see the drift-detection test in storage_client_test.go).
transport := &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
Expand Down
35 changes: 21 additions & 14 deletions azurebs/client/storage_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,35 +57,42 @@ var _ = Describe("NewStorageClient", func() {
})
})

// Pinned against github.com/Azure/azure-sdk-for-go/sdk/azcore@v1.23.1.
// If this test fails: diff runtime/transport_default_http_client.go at the new
// version, update buildClientOptions in storage_client.go to reflect any
// changes, then update pinnedHash (and pinnedVersion for clarity) below.
// Pinned against github.com/Azure/azure-sdk-for-go/sdk/internal@v1.13.0.
//
// As of azcore v1.23.3 the default http.Client was moved out of azcore's
// runtime package (runtime/transport_default_http_client.go) into the shared
// sdk/internal module (transport/transport.go). buildClientOptions in
// storage_client.go replicates those defaults, so this test fingerprints the
// upstream source file to catch drift.
//
// If this test fails: diff transport/transport.go at the new version, update
// buildClientOptions in storage_client.go to reflect any changes, then update
// pinnedVersion and pinnedHash below.
var _ = Describe("azcore transport defaults drift detection", func() {
It("transport_default_http_client.go has not changed since it was last reviewed", func() {
const pinnedVersion = "v1.23.1"
const pinnedHash = "e60db6ff9e71a7f778503c3628c8cda73c5fd555436b470696a0c491fb6db20d"
It("transport.go has not changed since it was last reviewed", func() {
const pinnedVersion = "v1.13.0"
const pinnedHash = "c9c688e0af848b51e71dc962539619700db280d0583f102cf8b2fbf772f8babd"

out, err := exec.Command("go", "list", "-m", "-json", "github.com/Azure/azure-sdk-for-go/sdk/azcore").Output()
out, err := exec.Command("go", "list", "-m", "-json", "github.com/Azure/azure-sdk-for-go/sdk/internal").Output()
Expect(err).NotTo(HaveOccurred(), "go list failed: %v", err)

var modInfo struct {
Version string
Dir string
}
Expect(json.Unmarshal(out, &modInfo)).To(Succeed())
Expect(modInfo.Dir).NotTo(BeEmpty(), "azcore module directory not found")
Expect(modInfo.Dir).NotTo(BeEmpty(), "sdk/internal module directory not found")

transportFile := filepath.Join(modInfo.Dir, "runtime", "transport_default_http_client.go")
transportFile := filepath.Join(modInfo.Dir, "transport", "transport.go")
content, err := os.ReadFile(transportFile)
Expect(err).NotTo(HaveOccurred(),
"could not read azcore transport file at %s", transportFile)
"could not read transport file at %s", transportFile)

actualHash := fmt.Sprintf("%x", sha256.Sum256(content))
Expect(actualHash).To(Equal(pinnedHash),
"azcore transport defaults changed in %s (last reviewed at %s).\n"+
"Diff runtime/transport_default_http_client.go, update buildClientOptions "+
"in storage_client.go if needed, then update pinnedVersion and pinnedHash in this test.",
"azcore transport defaults changed in transport/transport.go (%s, last reviewed at %s).\n"+
"Diff the file, update buildClientOptions in storage_client.go if needed, "+
"then update pinnedVersion and pinnedHash in this test.",
modInfo.Version, pinnedVersion,
)
})
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.26.0

require (
cloud.google.com/go/storage v1.69.0
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.23.2
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.23.3
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.8.2
github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible
github.com/aws/aws-sdk-go-v2 v1.47.3
Expand Down Expand Up @@ -32,7 +32,7 @@ require (
cloud.google.com/go/iam v1.12.0 // indirect
cloud.google.com/go/monitoring v1.30.0 // indirect
code.cloudfoundry.org/tlsconfig v0.69.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.12.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.13.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/storage/internal v0.1.0 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.35.0 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.57.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ code.cloudfoundry.org/tlsconfig v0.69.0 h1:bvlvdU2BKiSEcgeiv0Csomzmq7Gn8vGU4yeNX
code.cloudfoundry.org/tlsconfig v0.69.0/go.mod h1:gKv5uSKC6EUgBllA7qDmXPYRz8sJaV3BWpCMsg24R8I=
filippo.io/edwards25519 v1.2.0 h1:crnVqOiS4jqYleHd9vaKZ+HKtHfllngJIiOpNpoJsjo=
filippo.io/edwards25519 v1.2.0/go.mod h1:xzAOLCNug/yB62zG1bQ8uziwrIqIuxhctzJT18Q77mc=
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.23.2 h1:utpeoEeZjd+A8J41zvoLsOOrqXHhX1Kx/X/tCW9dEYQ=
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.23.2/go.mod h1:iptorS+VYKFL2N6PnebpS91dubG35eAOEERnT4PJbQU=
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.23.3 h1:qgnWTiWs1G7AqcKZegFvkJD1bmXJcaDU3uC0ELSgZ5U=
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.23.3/go.mod h1:XtxD48QPInqoj+GMlcRlXHEYsoOxFnP6w2JgIZ9rDS4=
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.14.0 h1:CU4+EJeJi3TKYWEcYuSdWsjzw0nVsK/H0MSQOiPcymU=
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.14.0/go.mod h1:q0+UTSRvShwUCrR/s5HtyInYphN7Wvxb7snFM3u+SLA=
github.com/Azure/azure-sdk-for-go/sdk/internal v1.12.0 h1:fhqpLE3UEXi9lPaBRpQ6XuRW0nU7hgg4zlmZZa+a9q4=
github.com/Azure/azure-sdk-for-go/sdk/internal v1.12.0/go.mod h1:7dCRMLwisfRH3dBupKeNCioWYUZ4SS09Z14H+7i8ZoY=
github.com/Azure/azure-sdk-for-go/sdk/internal v1.13.0 h1:Terj1CMW4+NY5CpWjSRkqLoxh2DkYDdv/FH2z0897Uc=
github.com/Azure/azure-sdk-for-go/sdk/internal v1.13.0/go.mod h1:7Ut2Qw9vcwpLW5Q4MBy43uSxXS7tK2yjs94OJ6j5thE=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.8.1 h1:/Zt+cDPnpC3OVDm/JKLOs7M2DKmLRIIp3XIx9pHHiig=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.8.1/go.mod h1:Ng3urmn6dYe8gnbCMoHHVl5APYz2txho3koEkV2o2HA=
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.8.2 h1:tQJdgQjbKKffEiMOKJmcQPkY01eFHRqWIZVefqP44nI=
Expand Down
Loading