github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/client/structs/csi.go (about) 1 package structs 2 3 import ( 4 "github.com/hashicorp/nomad/nomad/structs" 5 "github.com/hashicorp/nomad/plugins/csi" 6 ) 7 8 // CSIVolumeMountOptions contains the mount options that should be provided when 9 // attaching and mounting a volume with the CSIVolumeAttachmentModeFilesystem 10 // attachment mode. 11 type CSIVolumeMountOptions struct { 12 // Filesystem is the desired filesystem type that should be used by the volume 13 // (e.g ext4, aufs, zfs). This field is optional. 14 Filesystem string 15 16 // MountFlags contain the mount options that should be used for the volume. 17 // These may contain _sensitive_ data and should not be leaked to logs or 18 // returned in debugging data. 19 // The total size of this field must be under 4KiB. 20 MountFlags []string 21 } 22 23 // CSIControllerQuery is used to specify various flags for queries against CSI 24 // Controllers 25 type CSIControllerQuery struct { 26 // ControllerNodeID is the node that should be targeted by the request 27 ControllerNodeID string 28 29 // PluginID is the plugin that should be targeted on the given node. 30 PluginID string 31 } 32 33 type ClientCSIControllerValidateVolumeRequest struct { 34 VolumeID string // note: this is the external ID 35 36 AttachmentMode structs.CSIVolumeAttachmentMode 37 AccessMode structs.CSIVolumeAccessMode 38 Secrets structs.CSISecrets 39 // Parameters map[string]string // TODO: https://github.com/hashicorp/nomad/issues/7670 40 41 CSIControllerQuery 42 } 43 44 type ClientCSIControllerValidateVolumeResponse struct { 45 } 46 47 type ClientCSIControllerAttachVolumeRequest struct { 48 // The external ID of the volume to be used on a node. 49 // This field is REQUIRED. 50 VolumeID string 51 52 // The ID of the node. This field is REQUIRED. This must match the NodeID that 53 // is fingerprinted by the target node for this plugin name. 54 ClientCSINodeID string 55 56 // AttachmentMode indicates how the volume should be attached and mounted into 57 // a task. 58 AttachmentMode structs.CSIVolumeAttachmentMode 59 60 // AccessMode indicates the desired concurrent access model for the volume 61 AccessMode structs.CSIVolumeAccessMode 62 63 // MountOptions is an optional field that contains additional configuration 64 // when providing an AttachmentMode of CSIVolumeAttachmentModeFilesystem 65 MountOptions *CSIVolumeMountOptions 66 67 // ReadOnly indicates that the volume will be used in a readonly fashion. This 68 // only works when the Controller has the PublishReadonly capability. 69 ReadOnly bool 70 71 // Secrets required by plugin to complete the controller publish 72 // volume request. This field is OPTIONAL. 73 Secrets structs.CSISecrets 74 75 // TODO https://github.com/hashicorp/nomad/issues/7771 76 // Volume context as returned by storage provider in CreateVolumeResponse. 77 // This field is optional. 78 // VolumeContext map[string]string 79 80 CSIControllerQuery 81 } 82 83 func (c *ClientCSIControllerAttachVolumeRequest) ToCSIRequest() (*csi.ControllerPublishVolumeRequest, error) { 84 if c == nil { 85 return &csi.ControllerPublishVolumeRequest{}, nil 86 } 87 88 caps, err := csi.VolumeCapabilityFromStructs(c.AttachmentMode, c.AccessMode) 89 if err != nil { 90 return nil, err 91 } 92 93 return &csi.ControllerPublishVolumeRequest{ 94 ExternalID: c.VolumeID, 95 NodeID: c.ClientCSINodeID, 96 VolumeCapability: caps, 97 ReadOnly: c.ReadOnly, 98 Secrets: c.Secrets, 99 // VolumeContext: c.VolumeContext, TODO: https://github.com/hashicorp/nomad/issues/7771 100 }, nil 101 } 102 103 // ClientCSIControllerDetachVolumeRequest is the RPC made from the server to 104 // a Nomad client to tell a CSI controller plugin on that client to perform 105 // ControllerUnpublish for a volume on a specific client. 106 type ClientCSIControllerAttachVolumeResponse struct { 107 // Opaque static publish properties of the volume. SP MAY use this 108 // field to ensure subsequent `NodeStageVolume` or `NodePublishVolume` 109 // calls calls have contextual information. 110 // The contents of this field SHALL be opaque to nomad. 111 // The contents of this field SHALL NOT be mutable. 112 // The contents of this field SHALL be safe for the nomad to cache. 113 // The contents of this field SHOULD NOT contain sensitive 114 // information. 115 // The contents of this field SHOULD NOT be used for uniquely 116 // identifying a volume. The `volume_id` alone SHOULD be sufficient to 117 // identify the volume. 118 // This field is OPTIONAL and when present MUST be passed to 119 // subsequent `NodeStageVolume` or `NodePublishVolume` calls 120 PublishContext map[string]string 121 } 122 123 type ClientCSIControllerDetachVolumeRequest struct { 124 // The external ID of the volume to be unpublished for the node 125 // This field is REQUIRED. 126 VolumeID string 127 128 // The CSI Node ID for the Node that the volume should be detached from. 129 // This field is REQUIRED. This must match the NodeID that is fingerprinted 130 // by the target node for this plugin name. 131 ClientCSINodeID string 132 133 // Secrets required by plugin to complete the controller unpublish 134 // volume request. This field is OPTIONAL. 135 Secrets structs.CSISecrets 136 137 CSIControllerQuery 138 } 139 140 func (c *ClientCSIControllerDetachVolumeRequest) ToCSIRequest() *csi.ControllerUnpublishVolumeRequest { 141 if c == nil { 142 return &csi.ControllerUnpublishVolumeRequest{} 143 } 144 145 return &csi.ControllerUnpublishVolumeRequest{ 146 ExternalID: c.VolumeID, 147 NodeID: c.ClientCSINodeID, 148 } 149 } 150 151 type ClientCSIControllerDetachVolumeResponse struct{} 152 153 // ClientCSINodeDetachVolumeRequest is the RPC made from the server to 154 // a Nomad client to tell a CSI node plugin on that client to perform 155 // NodeUnpublish and NodeUnstage. 156 type ClientCSINodeDetachVolumeRequest struct { 157 PluginID string // ID of the plugin that manages the volume (required) 158 VolumeID string // ID of the volume to be unpublished (required) 159 AllocID string // ID of the allocation we're unpublishing for (required) 160 NodeID string // ID of the Nomad client targeted 161 ExternalID string // External ID of the volume to be unpublished (required) 162 163 // These fields should match the original volume request so that 164 // we can find the mount points on the client 165 AttachmentMode structs.CSIVolumeAttachmentMode 166 AccessMode structs.CSIVolumeAccessMode 167 ReadOnly bool 168 } 169 170 type ClientCSINodeDetachVolumeResponse struct{}