Skip to content

Commit

Permalink
bump lint version
Browse files Browse the repository at this point in the history
Signed-off-by: Avi Deitcher <[email protected]>
  • Loading branch information
deitch committed Nov 29, 2024
1 parent e2d2336 commit 87043a4
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 27 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ jobs:
- name: build
run: go build ./...
- name: lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v6
with:
version: v1.55.2
skip-pkg-cache: true
- name: test # requires building binaries and running them; sufficient to run on native arch
version: v1.61.0
- name: test
# build binaries and run them to test; sufficient to run on native arch
if: matrix.target.arch == 'amd64' && matrix.target.os == 'linux'
run: go test ./... -race
15 changes: 15 additions & 0 deletions nettrace/dial.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,18 @@ func newTracedDialer(tracer tracerWithDial, log Logger, sourceIP net.IP,
}
}

// dial implement DialContext method of the net.Dialer interface.
func (td *tracedDialer) dial(ctx context.Context, network, address string) (net.Conn, error) {
// Note that if the overall timeout to the http.Client is reached, this dial() method
// may simply be abandoned. You cannot expect any goroutine or defer to be reached.
// This matters in that this routine expects to set the following parameters:
// - dialTrace.DialTrace.CtxCloseAt
// - dialTrace.DialEndAt
// - dialTrace.ctxClosed
//
// Anything that expects those to be set, should *not* expect them to be set
// if http.Client times out.

// Prepare the original Dialer from the net package.
var sourceAddr net.Addr
if td.sourceIP != nil {
Expand Down Expand Up @@ -146,6 +157,10 @@ func (td *tracedDialer) dial(ctx context.Context, network, address string) (net.
dial.SourceIP = td.sourceIP.String()
}
td.tracer.publishTrace(dial)

// if the http.Client.Timeout is reached, this will *not* return an error.
// It simply will be abandoned. Listening for a ctx.Done() or setting a defer()
// will not help either.
conn, err := netDialer.DialContext(ctx, network, address)
resolver.close()
dial.justBegan = false
Expand Down
8 changes: 5 additions & 3 deletions nettrace/httpclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ func TestTLSCertErrors(test *testing.T) {
t.Expect(tlsTun.PeerCerts).To(HaveLen(1))
peerCert = tlsTun.PeerCerts[0]
t.Expect(peerCert.IsCA).To(BeFalse())
t.Expect(peerCert.Issuer).To(Equal("CN=R3,O=Let's Encrypt,C=US"))
t.Expect(peerCert.Issuer).To(Equal("CN=R11,O=Let's Encrypt,C=US"))
t.Expect(peerCert.Subject).To(Equal("CN=*.badssl.com"))
t.Expect(peerCert.NotBefore.Abs.Before(time.Now())).To(BeTrue())
t.Expect(peerCert.NotAfter.Abs.After(time.Now())).To(BeTrue())
Expand Down Expand Up @@ -481,8 +481,10 @@ func TestUnresponsiveDest(test *testing.T) {
dial := trace.Dials[0]
t.Expect(dial.TraceID).ToNot(BeZero())
relTimeIsInBetween(t, dial.DialBeginAt, traceBeginAsRel, trace.TraceEndAt)
relTimeIsInBetween(t, dial.DialEndAt, dial.DialBeginAt, trace.TraceEndAt)
relTimeIsInBetween(t, dial.CtxCloseAt, dial.DialBeginAt, trace.TraceEndAt)
// DialEndAt and CtxCloseAt never get set, because when the http.Client.Timeout
// is reached, all dialers are dropped. The dialer itself does not return an error.
//relTimeIsInBetween(t, dial.DialEndAt, dial.DialBeginAt, trace.TraceEndAt)
//relTimeIsInBetween(t, dial.CtxCloseAt, dial.DialBeginAt, trace.TraceEndAt)
t.Expect(dial.DstAddress).To(Equal("198.51.100.100:443"))
t.Expect(dial.ResolverDials).To(BeEmpty())
t.Expect(dial.DialErr).ToNot(BeZero())
Expand Down
4 changes: 2 additions & 2 deletions zedUpload/azureutil/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func newPipeline(accountName, accountKey string, httpClient *http.Client) (pipel
}
credential, err := azblob.NewSharedKeyCredential(accountName, accountKey)
if err != nil {
return nil, fmt.Errorf("Invalid credentials with error: " + err.Error())
return nil, fmt.Errorf("invalid credentials with error: %s", err.Error())
}
p := azblob.NewPipeline(credential, azblob.PipelineOptions{
HTTPSender: sender,
Expand Down Expand Up @@ -457,7 +457,7 @@ func GetAzureBlobMetaData(accountURL, accountName, accountKey, containerName, re
func GenerateBlobSasURI(accountURL, accountName, accountKey, containerName, remoteFile string, httpClient *http.Client, duration time.Duration) (string, error) {
credential, err := azblob.NewSharedKeyCredential(accountName, accountKey)
if err != nil {
return "", fmt.Errorf("Invalid credentials with error: " + err.Error())
return "", fmt.Errorf("invalid credentials with error: %s", err.Error())
}

// Checking whether blob exists or not before generating SAS URI
Expand Down
9 changes: 5 additions & 4 deletions zedUpload/datastore_aws_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package zedUpload_test

import (
"errors"
"fmt"
"os"
"testing"
Expand Down Expand Up @@ -190,11 +191,11 @@ func getAwsS3ObjectMetaData(t *testing.T, objloc string, objkey string) (bool, s
func testAwsS3ObjectWithFile(t *testing.T, objloc string, objkey string) error {
statusUpload, msgUpload := operationAwsS3(t, objloc, objkey, zedUpload.SyncOpUpload)
if statusUpload {
return fmt.Errorf(msgUpload)
return errors.New(msgUpload)
}
statusMeta, msgMeta, size, remoteFileMD5 := getAwsS3ObjectMetaData(t, objloc, objkey)
if statusMeta {
return fmt.Errorf(msgMeta)
return errors.New(msgMeta)
}
stat, err := os.Stat(objloc)
if err == nil {
Expand All @@ -213,7 +214,7 @@ func testAwsS3ObjectWithFile(t *testing.T, objloc string, objkey string) error {
}
statusDownload, msgDownload := operationAwsS3(t, awsDownloadDir+objkey, objkey, zedUpload.SyncOpDownload)
if statusDownload {
return fmt.Errorf(msgDownload)
return errors.New(msgDownload)
}
downloadFileMD5, err := calculateMd5(awsDownloadDir+objkey, 5242880)
if err != nil {
Expand All @@ -224,7 +225,7 @@ func testAwsS3ObjectWithFile(t *testing.T, objloc string, objkey string) error {
}
statusDelete, msgDelete := operationAwsS3(t, objloc, objkey, zedUpload.SyncOpDelete)
if statusDelete {
return fmt.Errorf(msgDelete)
return errors.New(msgDelete)
}
return nil

Expand Down
9 changes: 5 additions & 4 deletions zedUpload/datastore_azure_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package zedUpload_test

import (
"errors"
"fmt"
"os"
"testing"
Expand Down Expand Up @@ -169,11 +170,11 @@ func getAzureBlobMetaData(t *testing.T, objloc string, objkey string) (bool, str
func testAzureBlobWithFile(t *testing.T, objloc string, objkey string) error {
statusUpload, msgUpload := operationAzureBlob(t, objloc, objkey, zedUpload.SyncOpUpload)
if statusUpload {
return fmt.Errorf(msgUpload)
return errors.New(msgUpload)
}
statusMeta, msgMeta, size, remoteFileMD5 := getAzureBlobMetaData(t, objloc, objkey)
if statusMeta {
return fmt.Errorf(msgMeta)
return errors.New(msgMeta)
}
stat, err := os.Stat(objloc)
if err == nil {
Expand All @@ -192,7 +193,7 @@ func testAzureBlobWithFile(t *testing.T, objloc string, objkey string) error {
}
statusDownload, msgDownload := operationAzureBlob(t, azureDownloadDir+objkey, objkey, zedUpload.SyncOpDownload)
if statusDownload {
return fmt.Errorf(msgDownload)
return errors.New(msgDownload)
}
downloadFileMD5, err := hashFileMd5(azureDownloadDir + objkey)
if err != nil {
Expand All @@ -203,7 +204,7 @@ func testAzureBlobWithFile(t *testing.T, objloc string, objkey string) error {
}
statusDelete, msgDelete := operationAzureBlob(t, objloc, objkey, zedUpload.SyncOpDelete)
if statusDelete {
return fmt.Errorf(msgDelete)
return errors.New(msgDelete)
}
return nil

Expand Down
9 changes: 5 additions & 4 deletions zedUpload/datastore_gs_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package zedUpload_test

import (
"errors"
"fmt"
"net"
"os"
Expand Down Expand Up @@ -192,11 +193,11 @@ func getGSObjectMetaData(t *testing.T, objloc string, objkey string) (bool, stri
func testGSObjectWithFile(t *testing.T, objloc string, objkey string) error {
statusUpload, msgUpload := operationGS(t, objloc, objkey, zedUpload.SyncOpUpload)
if statusUpload {
return fmt.Errorf(msgUpload)
return errors.New(msgUpload)
}
statusMeta, msgMeta, size, remoteFileMD5 := getGSObjectMetaData(t, objloc, objkey)
if statusMeta {
return fmt.Errorf(msgMeta)
return errors.New(msgMeta)
}
stat, err := os.Stat(objloc)
if err == nil {
Expand All @@ -215,7 +216,7 @@ func testGSObjectWithFile(t *testing.T, objloc string, objkey string) error {
}
statusDownload, msgDownload := operationGS(t, gsDownloadDir+objkey, objkey, zedUpload.SyncOpDownload)
if statusDownload {
return fmt.Errorf(msgDownload)
return errors.New(msgDownload)
}
downloadFileMD5, err := calculateMd5(gsDownloadDir+objkey, 5242880)
if err != nil {
Expand All @@ -226,7 +227,7 @@ func testGSObjectWithFile(t *testing.T, objloc string, objkey string) error {
}
statusDelete, msgDelete := operationGS(t, objloc, objkey, zedUpload.SyncOpDelete)
if statusDelete {
return fmt.Errorf(msgDelete)
return errors.New(msgDelete)
}
return nil

Expand Down
5 changes: 3 additions & 2 deletions zedUpload/datastore_http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package zedUpload_test
import (
"crypto/sha256"
"encoding/hex"
"errors"
"fmt"
"io"
"math/rand"
Expand Down Expand Up @@ -372,11 +373,11 @@ func testHTTPObjectWithFile(t *testing.T, localPath string, size int) error {
}
statusMeta, msgMeta, remoteSize := getHTTPObjectMetaData(t, localPath, filename, ts.URL, "")
if statusMeta {
return fmt.Errorf(msgMeta)
return errors.New(msgMeta)
}
statusDownload, msgDownload := operationHTTP(t, zedUpload.SyncOpDownload, ts.URL, "", filename, localPath, false)
if statusDownload {
return fmt.Errorf(msgDownload)
return errors.New(msgDownload)
}
stat, err := os.Stat(localPath)
if err != nil {
Expand Down
9 changes: 5 additions & 4 deletions zedUpload/datastore_sftp_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package zedUpload_test

import (
"errors"
"fmt"
"os"
"testing"
Expand Down Expand Up @@ -171,11 +172,11 @@ func getSFTPObjectMetaData(t *testing.T, objloc string, objkey string) (bool, st
func testSFTPObjectWithFile(t *testing.T, objloc string, objkey string) error {
statusUpload, msgUpload := operationSFTP(t, objloc, objkey, zedUpload.SyncOpUpload)
if statusUpload {
return fmt.Errorf(msgUpload)
return errors.New(msgUpload)
}
statusMeta, msgMeta, size := getSFTPObjectMetaData(t, objloc, objkey)
if statusMeta {
return fmt.Errorf(msgMeta)
return errors.New(msgMeta)
}
stat, err := os.Stat(objloc)
if err == nil {
Expand All @@ -187,7 +188,7 @@ func testSFTPObjectWithFile(t *testing.T, objloc string, objkey string) error {
}
statusDownload, msgDownload := operationSFTP(t, sftpDownloadDir+objkey, objkey, zedUpload.SyncOpDownload)
if statusDownload {
return fmt.Errorf(msgDownload)
return errors.New(msgDownload)
}
downloadFileStat, err := os.Stat(sftpDownloadDir + objkey)
if err == nil {
Expand All @@ -199,7 +200,7 @@ func testSFTPObjectWithFile(t *testing.T, objloc string, objkey string) error {
}
statusDelete, msgDelete := operationSFTP(t, objloc, objkey, zedUpload.SyncOpDelete)
if statusDelete {
return fmt.Errorf(msgDelete)
return errors.New(msgDelete)
}
return nil
}
Expand Down

0 comments on commit 87043a4

Please sign in to comment.