Skip to content

Commit

Permalink
backport fix for PR #17996 to 1.4.x (#18019)
Browse files Browse the repository at this point in the history
The backport for #17996 was automatically merged by BPA but the build did not
work due to missing imports and changes to the signatures of some our RPC
structs. Fix the backport.
  • Loading branch information
tgross authored Jul 20, 2023
1 parent 04a5248 commit a4b69ab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions nomad/client_csi_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
log "github.com/hashicorp/go-hclog"
memdb "github.com/hashicorp/go-memdb"
cstructs "github.com/hashicorp/nomad/client/structs"
"github.com/hashicorp/nomad/nomad/structs"
)

// ClientCSI is used to forward RPC requests to the targed Nomad client's
Expand Down
17 changes: 11 additions & 6 deletions nomad/csi_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
cconfig "github.com/hashicorp/nomad/client/config"
cstructs "github.com/hashicorp/nomad/client/structs"
"github.com/hashicorp/nomad/helper/uuid"
"github.com/hashicorp/nomad/lib/lang"
"github.com/hashicorp/nomad/nomad/mock"
"github.com/hashicorp/nomad/nomad/state"
"github.com/hashicorp/nomad/nomad/structs"
Expand Down Expand Up @@ -1981,18 +1980,24 @@ func TestCSI_SerializedControllerRPC(t *testing.T) {
var wg sync.WaitGroup
wg.Add(3)

timeCh := make(chan lang.Pair[string, time.Duration])
timeCh := make(chan struct {
pluginID string
dur time.Duration
})

testFn := func(pluginID string, dur time.Duration) {
defer wg.Done()
c := NewCSIVolumeEndpoint(srv, nil)
c := &CSIVolume{srv: srv, logger: nil}
now := time.Now()
err := c.serializedControllerRPC(pluginID, func() error {
time.Sleep(dur)
return nil
})
elapsed := time.Since(now)
timeCh <- lang.Pair[string, time.Duration]{pluginID, elapsed}
timeCh <- struct {
pluginID string
dur time.Duration
}{pluginID, elapsed}
must.NoError(t, err)
}

Expand All @@ -2002,8 +2007,8 @@ func TestCSI_SerializedControllerRPC(t *testing.T) {

totals := map[string]time.Duration{}
for i := 0; i < 3; i++ {
pair := <-timeCh
totals[pair.First] += pair.Second
result := <-timeCh
totals[result.pluginID] += result.dur
}

wg.Wait()
Expand Down

0 comments on commit a4b69ab

Please sign in to comment.