Skip to content

Commit

Permalink
backport of commit a9b2ac8
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross committed Apr 3, 2023
1 parent d20d16b commit 0db70d6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
10 changes: 10 additions & 0 deletions client/pluginmanager/csimanager/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ type MountInfo struct {
IsDevice bool
}

func (mi *MountInfo) Copy() *MountInfo {
if mi == nil {
return nil
}

nmi := new(MountInfo)
*nmi = *mi
return nmi
}

type UsageOptions struct {
ReadOnly bool
AttachmentMode structs.CSIVolumeAttachmentMode
Expand Down
7 changes: 6 additions & 1 deletion client/structs/allochook.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"sync"

"github.com/hashicorp/nomad/client/pluginmanager/csimanager"
"github.com/hashicorp/nomad/helper"
)

// AllocHookResources contains data that is provided by AllocRunner Hooks for
Expand All @@ -22,13 +23,17 @@ func NewAllocHookResources() *AllocHookResources {
}
}

// GetCSIMounts returns a copy of the CSI mount info previously written by the
// CSI allocrunner hook
func (a *AllocHookResources) GetCSIMounts() map[string]*csimanager.MountInfo {
a.mu.RLock()
defer a.mu.RUnlock()

return a.csiMounts
return helper.DeepCopyMap(a.csiMounts)
}

// SetCSIMounts stores the CSI mount info for later use by the volume taskrunner
// hook
func (a *AllocHookResources) SetCSIMounts(m map[string]*csimanager.MountInfo) {
a.mu.Lock()
defer a.mu.Unlock()
Expand Down

0 comments on commit 0db70d6

Please sign in to comment.