mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
plugins/csi: Implement ConvtrollerValidateCapabilities RPC
This commit is contained in:
committed by
Tim Gross
parent
ae4f59746c
commit
7ffdba7636
@@ -274,6 +274,45 @@ func (c *client) ControllerUnpublishVolume(ctx context.Context, req *ControllerU
|
||||
return &ControllerUnpublishVolumeResponse{}, nil
|
||||
}
|
||||
|
||||
func (c *client) ControllerValidateCapabilties(ctx context.Context, volumeID string, capabilities *VolumeCapability) error {
|
||||
if c == nil {
|
||||
return fmt.Errorf("Client not initialized")
|
||||
}
|
||||
if c.controllerClient == nil {
|
||||
return fmt.Errorf("controllerClient not initialized")
|
||||
}
|
||||
|
||||
if volumeID == "" {
|
||||
return fmt.Errorf("missing VolumeID")
|
||||
}
|
||||
|
||||
if capabilities == nil {
|
||||
return fmt.Errorf("missing Capabilities")
|
||||
}
|
||||
|
||||
req := &csipbv1.ValidateVolumeCapabilitiesRequest{
|
||||
VolumeId: volumeID,
|
||||
VolumeCapabilities: []*csipbv1.VolumeCapability{
|
||||
capabilities.ToCSIRepresentation(),
|
||||
},
|
||||
}
|
||||
|
||||
resp, err := c.controllerClient.ValidateVolumeCapabilities(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if resp.Confirmed == nil {
|
||||
if resp.Message != "" {
|
||||
return fmt.Errorf("Volume validation failed, message: %s", resp.Message)
|
||||
}
|
||||
|
||||
return fmt.Errorf("Volume validation failed")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
//
|
||||
// Node Endpoints
|
||||
//
|
||||
|
||||
@@ -48,6 +48,9 @@ type Client struct {
|
||||
NextControllerUnpublishVolumeErr error
|
||||
ControllerUnpublishVolumeCallCount int64
|
||||
|
||||
NextControllerValidateVolumeErr error
|
||||
ControllerValidateVolumeCallCount int64
|
||||
|
||||
NextNodeGetCapabilitiesResponse *csi.NodeCapabilitySet
|
||||
NextNodeGetCapabilitiesErr error
|
||||
NodeGetCapabilitiesCallCount int64
|
||||
@@ -153,6 +156,15 @@ func (c *Client) ControllerUnpublishVolume(ctx context.Context, req *csi.Control
|
||||
return c.NextControllerUnpublishVolumeResponse, c.NextControllerUnpublishVolumeErr
|
||||
}
|
||||
|
||||
func (c *Client) ControllerValidateCapabilties(ctx context.Context, volumeID string, capabilities *csi.VolumeCapability) error {
|
||||
c.Mu.Lock()
|
||||
defer c.Mu.Unlock()
|
||||
|
||||
c.ControllerValidateVolumeCallCount++
|
||||
|
||||
return c.NextControllerValidateVolumeErr
|
||||
}
|
||||
|
||||
func (c *Client) NodeGetCapabilities(ctx context.Context) (*csi.NodeCapabilitySet, error) {
|
||||
c.Mu.Lock()
|
||||
defer c.Mu.Unlock()
|
||||
|
||||
@@ -40,6 +40,10 @@ type CSIPlugin interface {
|
||||
// ControllerUnpublishVolume is used to deattach a remote volume from a cluster node.
|
||||
ControllerUnpublishVolume(ctx context.Context, req *ControllerUnpublishVolumeRequest) (*ControllerUnpublishVolumeResponse, error)
|
||||
|
||||
// ControllerValidateCapabilities is used to validate that a volume exists and
|
||||
// supports the requested capability.
|
||||
ControllerValidateCapabilties(ctx context.Context, volumeID string, capabilities *VolumeCapability) error
|
||||
|
||||
// NodeGetCapabilities is used to return the available capabilities from the
|
||||
// Node Service.
|
||||
NodeGetCapabilities(ctx context.Context) (*NodeCapabilitySet, error)
|
||||
|
||||
Reference in New Issue
Block a user