mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
following ControllerExpandVolume
in c6dbba7cde,
which expands the disk at e.g. a cloud vendor,
the controller plugin may say that we also need
to issue NodeExpandVolume for the node plugin to
make the new disk space available to task(s) that
have claims on the volume by e.g. expanding
the filesystem on the node.
csi spec:
https://github.com/container-storage-interface/spec/blob/c918b7f/spec.md#nodeexpandvolume
74 lines
2.0 KiB
Go
74 lines
2.0 KiB
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
package csimanager
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/hashicorp/nomad/client/pluginmanager"
|
|
nstructs "github.com/hashicorp/nomad/nomad/structs"
|
|
"github.com/hashicorp/nomad/plugins/csi"
|
|
)
|
|
|
|
var _ Manager = &MockCSIManager{}
|
|
|
|
type MockCSIManager struct {
|
|
VM *MockVolumeManager
|
|
|
|
NextWaitForPluginErr error
|
|
NextManagerForPluginErr error
|
|
}
|
|
|
|
func (m *MockCSIManager) PluginManager() pluginmanager.PluginManager {
|
|
panic("implement me")
|
|
}
|
|
|
|
func (m *MockCSIManager) WaitForPlugin(_ context.Context, pluginType, pluginID string) error {
|
|
return m.NextWaitForPluginErr
|
|
}
|
|
|
|
func (m *MockCSIManager) ManagerForPlugin(_ context.Context, pluginID string) (VolumeManager, error) {
|
|
return m.VM, m.NextManagerForPluginErr
|
|
}
|
|
|
|
func (m *MockCSIManager) Shutdown() {
|
|
panic("implement me")
|
|
}
|
|
|
|
var _ VolumeManager = &MockVolumeManager{}
|
|
|
|
type MockVolumeManager struct {
|
|
NextExpandVolumeErr error
|
|
LastExpandVolumeCall *MockExpandVolumeCall
|
|
}
|
|
|
|
func (m *MockVolumeManager) MountVolume(_ context.Context, vol *nstructs.CSIVolume, alloc *nstructs.Allocation, usageOpts *UsageOptions, publishContext map[string]string) (*MountInfo, error) {
|
|
panic("implement me")
|
|
}
|
|
|
|
func (m *MockVolumeManager) UnmountVolume(_ context.Context, volID, remoteID, allocID string, usageOpts *UsageOptions) error {
|
|
panic("implement me")
|
|
}
|
|
|
|
func (m *MockVolumeManager) HasMount(_ context.Context, mountInfo *MountInfo) (bool, error) {
|
|
panic("implement me")
|
|
}
|
|
|
|
func (m *MockVolumeManager) ExpandVolume(_ context.Context, volID, remoteID, allocID string, usageOpts *UsageOptions, capacity *csi.CapacityRange) (int64, error) {
|
|
m.LastExpandVolumeCall = &MockExpandVolumeCall{
|
|
volID, remoteID, allocID, usageOpts, capacity,
|
|
}
|
|
return capacity.RequiredBytes, m.NextExpandVolumeErr
|
|
}
|
|
|
|
type MockExpandVolumeCall struct {
|
|
VolID, RemoteID, AllocID string
|
|
UsageOpts *UsageOptions
|
|
Capacity *csi.CapacityRange
|
|
}
|
|
|
|
func (m *MockVolumeManager) ExternalID() string {
|
|
return "mock-volume-manager"
|
|
}
|