gocsi

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2017 License: Apache-2.0 Imports: 17 Imported by: 0

README

GoCSI

The Container Storage Interface (CSI) is an industry standard specification for creating storage plug-ins for container orchestrators. GoCSI aids in the development and testing of CSI plug-ins and provides the following:

Component Description
GoCSI CSI Go library
csc CSI command line interface (CLI) client
mock CSI mock plug-in

Library

The root of the GoCSI project is a general purpose library for CSI that contains package-level functions for invoking the CSI Controller, Identity, and Node RPCs in addition to the following gRPC client and server interceptors:

Type Name Description
Unary, client interceptor ClientCheckResponseError Parses CSI errors into Go errors
ClientResponseValidator Validates responses
Unary, server interceptor RequestIDInjector Injects a unique ID into a gRPC request
ServerRequestLogger Logs requests
ServerResponseLogger Logs responses
ServerRequestVersionValidator Validates request versions
ServerRequestValidator Validates requests
IdempotentInterceptor Provides serial access and idempotency for volume-related CSI RPCs

Examples illustrating the above interceptors and invoking the CSI RPCs may be found in the GoCSI test suite, the CSI client, and the CSI mock plug-in.

Client

The CSI client csc is useful when developing and testing CSI plug-ins because csc can easily and directly invoke any of CSI's RPCs directly from the command line.

Please see the csc package for additional documentation.

Mock Plug-in

The mock plug-in is a stand-alone binary that implements the CSI Controller, Identity, and Node RPCs in addition to the specification's requirements regarding idempotency.

Please see the mock package for additional documentation.

CSI Specification Version

GoCSI references the CSI spec project in order to obtain the CSI specification.

Please see the csi package for additional documentation.

Build Reference

GoCSI is go gettable - that means it is possible to build GoCSI with the following command:

$ go get github.com/codedellemc/gocsi

If GoCSI has already been cloned locally via Git or the aforementioned go get command then there are two ways to build GoCSI:

  1. Build with Go
  2. Build with Make
Building with Go

The following commands will build GoCSI's client and mock plug-in:

$ go build -o csc/csc ./csc && go build -o mock/mock ./mock

The above command produces CSI client and mock plug-in binaries at csc/csc and mock/mock.

Building with Make

Make can be used to build all of GoCSI's components with a single command:

$ make

The above command will verify that the generated protobuf and Go language bindings are up-to-date and that the GoCSI library, client, and mock plug-in all build successfully.

Testing

The GoCSI test suite makes use of the Mock plug-in in order to provide a CSI endpoint that hosts the Controller, Identity, and Node services. The following command can be used to execute the test suite:

$ go test

The above command is the simplest way to run the GoCSI tests. However, there are more advanced test scenarios:

Test Scenario Description
Ginkgo Using the Ginkgo test runner
CSI_ENDPOINT Using an external server endpoint
GOCSI_MOCK Specifying the path to the server binary
GOCSI_TEST_DEBUG Showing the server process output
Ginkgo

The GoCSI tests are written using the Ginkgo natural language testing domain-specific-language (DSL). To take full advantage of GoCSI's test capabilities the Ginkgo and Gomega dependencies are required and are included in the GoCSI's vendor directory.

Either of the following two commands may be used to build the Ginkgo test runner:

  1. $ go build ./vendor/github.com/onsi/ginkgo/ginkgo
  2. $ make ginkgo

Both of the above commands will place the ginkgo binary in the GoCSI project's root directory.

To execute the GoCSI test suite with Ginkgo please use one of the two commands below:

  1. $ ./ginkgo
  2. $ make test

The first command produces output nearly identical to the output of go test. Use ./ginkgo -? to print a list of all the flags and options available to the Ginkgo test runner.

The second command simply ensures that GoCSI's generated sources and client and mock binaries are up-to-date before executing ./ginkgo -v. The -v flag executes the tests in verbose mode, printing the names of each of the test cases as they're executed.

CSI_ENDPOINT

When the GoCSI test suite is executed the first thing that occurs is checking for the value of the environment variable CSI_ENDPOINT. If CSI_ENDPOINT is set then the test suite will not create a new server for every test case using the mock plug-in. Instead all test cases are executed against the server specified by CSI_ENDPOINT.

Please note that using an external CSI server with the test suite will likely result in failure as the test cases expect a new Mock server instance at the start of each test case. Still, this is a helpful feature when wanting to run the Mock plug-in separately in order to watch its output when executing a specific test case against it.

GOCSI_MOCK

If the CSI_ENDPOINT environment variable is not set the environment variable GOCSI_MOCK is checked. This variable's value should be the fully-qualified to a binary that starts a CSI plug-in. The binary is started with a clean environment except for a single environment variable, CSI_ENDPOINT, which points to a temporary file that the server should use as the UNIX socket for serving the CSI gRPC services.

If the GOCSI_MOCK environment variable is not set then the GoCSI test suite will automatically build the GoCSI Mock plug-in binary before executing any test cases:

$ go build -o mock github.com/codedellemc/gocsi/mock

The above command builds the Mock plug-in binary in the working, temporary directory of the test process. The GoCSI test suite then uses this binary to launch a new CSI server for each test case. This binary is removed when the test execution completes and the temporary test directory and its contents are removed.

Because the Mock plug-in binary is built automatically if GOCSI_MOCK is not set, it means the following two commands are in fact identical:

# Build the Mock plug-in binary and then launch the test suite while
# specifying the path to the binary with GOCSI_MOCK
$ go build -o mock/mock ./mock && GOCSI_MOCK=$(pwd)/mock/mock go test

# Launch the GoCSI test suite without specifying GOCSI_MOCK. This causes
# the test process to automatically build the Mock plug-in binary and
# use it for the test run
$ go test
GOCSI_TEST_DEBUG

Setting the environment variable GOCSI_TEST_DEBUG to true causes the GoCSI test suite to read the STDOUT and STDERR pipes of the server process launched with each test case and copy the contents of the streams to the test process's own STDOUT and STDERR pipes.

This will clutter the test output with the output of the CSI server processes, but it is useful when debugging.

Still, a cleaner solution for viewing the server output might be to launch the Mock plug-in in a stand-alone process and then run the test suite while setting CSI_ENDPOINT to the same UNIX socket used by the stand-alone Mock plug-in instance.

Please note that GOCSI_TEST_DEBUG is not supported when used in conjunction with CSI_ENDPOINT as the test suite cannot read the STDOUT and STDERR pipes of an existing process.

Documentation

Overview

Package gocsi provides a Container Storage Interface (CSI) library, client, and other helpful utilities.

Index

Constants

View Source
const (
	// FMCreateVolume is the full method name for the
	// eponymous RPC message.
	FMCreateVolume = "/" + Namespace +
		".Controller/" +
		"CreateVolume"

	// FMDeleteVolume is the full method name for the
	// eponymous RPC message.
	FMDeleteVolume = "/" + Namespace +
		".Controller/" +
		"DeleteVolume"

	// FMControllerPublishVolume is the full method name for the
	// eponymous RPC message.
	FMControllerPublishVolume = "/" + Namespace +
		".Controller/" +
		"ControllerPublishVolume"

	// FMControllerUnpublishVolume is the full method name for the
	// eponymous RPC message.
	FMControllerUnpublishVolume = "/" + Namespace +
		".Controller/" +
		"ControllerUnpublishVolume"

	// FMValidateVolumeCapabilities is the full method name for the
	// eponymous RPC message.
	FMValidateVolumeCapabilities = "/" + Namespace +
		".Controller/" +
		"ValidateVolumeCapabilities"

	// FMListVolumes is the full method name for the
	// eponymous RPC message.
	FMListVolumes = "/" + Namespace +
		".Controller/" +
		"ListVolumes"

	// FMGetCapacity is the full method name for the
	// eponymous RPC message.
	FMGetCapacity = "/" + Namespace +
		".Controller/" +
		"GetCapacity"

	// FMControllerGetCapabilities is the full method name for the
	// eponymous RPC message.
	FMControllerGetCapabilities = "/" + Namespace +
		".Controller/" +
		"ControllerGetCapabilities"
)
View Source
const (
	// Namespace is the namesapce used by the protobuf.
	Namespace = "csi"

	// CSIEndpoint is the name of the environment variable that
	// contains the CSI endpoint.
	CSIEndpoint = "CSI_ENDPOINT"
)
View Source
const (
	// FMGetSupportedVersions is the full method name for the
	// eponymous RPC message.
	FMGetSupportedVersions = "/" + Namespace +
		".Identity/" +
		"GetSupportedVersions"

	// FMGetPluginInfo is the full method name for the
	// eponymous RPC message.
	FMGetPluginInfo = "/" + Namespace +
		".Identity/" +
		"GetPluginInfo"
)
View Source
const (
	// FMGetNodeID is the full method name for the
	// eponymous RPC message.
	FMGetNodeID = "/" + Namespace +
		".Node/" +
		"GetNodeID"

	// FMNodePublishVolume is the full method name for the
	// eponymous RPC message.
	FMNodePublishVolume = "/" + Namespace +
		".Node/" +
		"NodePublishVolume"

	// FMNodeUnpublishVolume is the full method name for the
	// eponymous RPC message.
	FMNodeUnpublishVolume = "/" + Namespace +
		".Node/" +
		"NodeUnpublishVolume"

	// FMProbeNode is the full method name for the
	// eponymous RPC message.
	FMProbeNode = "/" + Namespace +
		".Node/" +
		"ProbeNode"

	// FMNodeGetCapabilities is the full method name for the
	// eponymous RPC message.
	FMNodeGetCapabilities = "/" + Namespace +
		".Node/" +
		"NodeGetCapabilities"
)
View Source
const ErrorNoCode int32 = -1

ErrorNoCode is the value that indicates the error code is not set.

Variables

View Source
var ErrEmptyPublishVolumeInfo = errors.New("publishVolumeInfo is empty")

ErrEmptyPublishVolumeInfo occurs when a gRPC call returns a PublishVolumeInfo with an empty Values field.

View Source
var ErrEmptyServices = errors.New("services list is empty")

ErrEmptyServices occurs when a Server's Services list is empty.

View Source
var ErrInvalidProvider = errors.New("invalid service provider")

ErrInvalidProvider is returned from NewService if the specified provider name is unknown.

View Source
var ErrInvalidTargetPath = errors.New("invalid targetPath")

ErrInvalidTargetPath occurs when an RPC call is made with an invalid targetPath argument.

View Source
var ErrMissingCSIEndpoint = errors.New("missing CSI_ENDPOINT")

ErrMissingCSIEndpoint occurs when the value for the environment variable CSI_ENDPOINT is not set.

View Source
var ErrNilNodeID = errors.New("nodeID is nil")

ErrNilNodeID occurs when a gRPC call returns a nil NodeID.

View Source
var ErrNilPublishVolumeInfo = errors.New("publishVolumeInfo is nil")

ErrNilPublishVolumeInfo occurs when a gRPC call returns a nil PublishVolumeInfo.

View Source
var ErrNilResult = errors.New("result is nil")

ErrNilResult occurs when a gRPC call returns a nil Result.

View Source
var ErrNilSupportedVersions = errors.New("supportedVersions is nil")

ErrNilSupportedVersions occurs when a gRPC call returns nil SupportedVersions

View Source
var ErrNilVolumeID = errors.New("volumeInfo.Id is nil")

ErrNilVolumeID occurs when a gRPC call returns a VolumeInfo with a nil Id field.

View Source
var ErrNilVolumeInfo = errors.New("volumeInfo is nil")

ErrNilVolumeInfo occurs when a gRPC call returns a nil VolumeInfo.

View Source
var ErrParseProtoAddrRequired = errors.New(
	"non-empty network address is required")

ErrParseProtoAddrRequired occurs when an empty string is provided to ParseProtoAddr.

View Source
var ErrVersionRequired = errors.New("version is required")

ErrVersionRequired occurs when an RPC call is made with a nil version argument.

View Source
var ErrVolumeCapabilityRequired = errors.New("volumeCapability is required")

ErrVolumeCapabilityRequired occurs when an RPC call is made with a nil volumeCapability argument.

View Source
var ErrVolumeIDRequired = errors.New("volumeID is required")

ErrVolumeIDRequired occurs when an RPC call is made with a nil volumeID argument.

View Source
var ErrVolumeInfoRequired = errors.New("volumeInfo is required")

ErrVolumeInfoRequired occurs when an RPC call is made with a nil volumeI argument.

Functions

func ChainUnaryClient

ChainUnaryClient chains one or more unary, client interceptors together into a left-to-right series that can be provided to a new gRPC client.

func ChainUnaryServer

ChainUnaryServer chains one or more unary, server interceptors together into a left-to-right series that can be provided to a new gRPC server.

func CheckResponseErrControllerGetCapabilities

func CheckResponseErrControllerGetCapabilities(
	ctx context.Context,
	method string,
	response *csi.ControllerGetCapabilitiesResponse) error

CheckResponseErrControllerGetCapabilities returns a Go error for the error message inside of a CSI response if present; otherwise nil is returned.

func CheckResponseErrControllerPublishVolume

func CheckResponseErrControllerPublishVolume(
	ctx context.Context,
	method string,
	response *csi.ControllerPublishVolumeResponse) error

CheckResponseErrControllerPublishVolume returns a Go error for the error message inside of a CSI response if present; otherwise nil is returned.

func CheckResponseErrControllerUnpublishVolume

func CheckResponseErrControllerUnpublishVolume(
	ctx context.Context,
	method string,
	response *csi.ControllerUnpublishVolumeResponse) error

CheckResponseErrControllerUnpublishVolume returns a Go error for the error message inside of a CSI response if present; otherwise nil is returned.

func CheckResponseErrCreateVolume

func CheckResponseErrCreateVolume(
	ctx context.Context,
	method string,
	response *csi.CreateVolumeResponse) error

CheckResponseErrCreateVolume returns a Go error for the error message inside of a CSI response if present; otherwise nil is returned.

func CheckResponseErrDeleteVolume

func CheckResponseErrDeleteVolume(
	ctx context.Context,
	method string,
	response *csi.DeleteVolumeResponse) error

CheckResponseErrDeleteVolume returns a Go error for the error message inside of a CSI response if present; otherwise nil is returned.

func CheckResponseErrGetCapacity

func CheckResponseErrGetCapacity(
	ctx context.Context,
	method string,
	response *csi.GetCapacityResponse) error

CheckResponseErrGetCapacity returns a Go error for the error message inside of a CSI response if present; otherwise nil is returned.

func CheckResponseErrGetNodeID

func CheckResponseErrGetNodeID(
	ctx context.Context,
	method string,
	response *csi.GetNodeIDResponse) error

CheckResponseErrGetNodeID returns a Go error for the error message inside of a CSI response if present; otherwise nil is returned.

func CheckResponseErrGetPluginInfo

func CheckResponseErrGetPluginInfo(
	ctx context.Context,
	method string,
	response *csi.GetPluginInfoResponse) error

CheckResponseErrGetPluginInfo returns a Go error for the error message inside of a CSI response if present; otherwise nil is returned.

func CheckResponseErrGetSupportedVersions

func CheckResponseErrGetSupportedVersions(
	ctx context.Context,
	method string,
	response *csi.GetSupportedVersionsResponse) error

CheckResponseErrGetSupportedVersions returns a Go error for the error message inside of a CSI response if present; otherwise nil is returned.

func CheckResponseErrListVolumes

func CheckResponseErrListVolumes(
	ctx context.Context,
	method string,
	response *csi.ListVolumesResponse) error

CheckResponseErrListVolumes returns a Go error for the error message inside of a CSI response if present; otherwise nil is returned.

func CheckResponseErrNodeGetCapabilities

func CheckResponseErrNodeGetCapabilities(
	ctx context.Context,
	method string,
	response *csi.NodeGetCapabilitiesResponse) error

CheckResponseErrNodeGetCapabilities returns a Go error for the error message inside of a CSI response if present; otherwise nil is returned.

func CheckResponseErrNodePublishVolume

func CheckResponseErrNodePublishVolume(
	ctx context.Context,
	method string,
	response *csi.NodePublishVolumeResponse) error

CheckResponseErrNodePublishVolume returns a Go error for the error message inside of a CSI response if present; otherwise nil is returned.

func CheckResponseErrNodeUnpublishVolume

func CheckResponseErrNodeUnpublishVolume(
	ctx context.Context,
	method string,
	response *csi.NodeUnpublishVolumeResponse) error

CheckResponseErrNodeUnpublishVolume returns a Go error for the error message inside of a CSI response if present; otherwise nil is returned.

func CheckResponseErrProbeNode

func CheckResponseErrProbeNode(
	ctx context.Context,
	method string,
	response *csi.ProbeNodeResponse) error

CheckResponseErrProbeNode returns a Go error for the error message inside of a CSI response if present; otherwise nil is returned.

func CheckResponseErrValidateVolumeCapabilities

func CheckResponseErrValidateVolumeCapabilities(
	ctx context.Context,
	method string,
	response *csi.ValidateVolumeCapabilitiesResponse) error

CheckResponseErrValidateVolumeCapabilities returns a Go error for the error message inside of a CSI response if present; otherwise nil is returned.

func ClientCheckReponseError

func ClientCheckReponseError(
	ctx context.Context,
	method string,
	req, rep interface{},
	cc *grpc.ClientConn,
	invoker grpc.UnaryInvoker,
	opts ...grpc.CallOption) error

ClientCheckReponseError is a unary, client validator that checks a reply's message to see if it contains an error and transforms it into an *Error object, which adheres to Go's Error interface.

func ClientResponseValidator

func ClientResponseValidator(
	ctx context.Context,
	method string,
	req, rep interface{},
	cc *grpc.ClientConn,
	invoker grpc.UnaryInvoker,
	opts ...grpc.CallOption) error

ClientResponseValidator is a unary, client validator for validating replies from a CSI plug-in.

func CompareVersions

func CompareVersions(a, b Version) int8

CompareVersions compares two versions and returns:

-1 if a > b
 0 if a = b
 1 if a < b

func ControllerGetCapabilities

func ControllerGetCapabilities(
	ctx context.Context,
	c csi.ControllerClient,
	version *csi.Version,
	callOpts ...grpc.CallOption) (
	capabilties []*csi.ControllerServiceCapability, err error)

ControllerGetCapabilities issues a ControllerGetCapabilities request to a CSI controller.

func ControllerPublishVolume

func ControllerPublishVolume(
	ctx context.Context,
	c csi.ControllerClient,
	version *csi.Version,
	volumeID *csi.VolumeID,
	volumeMetadata *csi.VolumeMetadata,
	nodeID *csi.NodeID,
	volumeCapability *csi.VolumeCapability,
	readonly bool,
	callOpts ...grpc.CallOption) (
	*csi.PublishVolumeInfo, error)

ControllerPublishVolume issues a ControllerPublishVolume request to a CSI controller.

func ControllerUnpublishVolume

func ControllerUnpublishVolume(
	ctx context.Context,
	c csi.ControllerClient,
	version *csi.Version,
	volumeID *csi.VolumeID,
	volumeMetadata *csi.VolumeMetadata,
	nodeID *csi.NodeID,
	callOpts ...grpc.CallOption) error

ControllerUnpublishVolume issues a ControllerUnpublishVolume request to a CSI controller.

func CreateVolume

func CreateVolume(
	ctx context.Context,
	c csi.ControllerClient,
	version *csi.Version,
	name string,
	requiredBytes, limitBytes uint64,
	capabilities []*csi.VolumeCapability,
	params map[string]string,
	callOpts ...grpc.CallOption) (volume *csi.VolumeInfo, err error)

CreateVolume issues a CreateVolume request to a CSI controller.

func DeleteVolume

func DeleteVolume(
	ctx context.Context,
	c csi.ControllerClient,
	version *csi.Version,
	volumeID *csi.VolumeID,
	volumeMetadata *csi.VolumeMetadata,
	callOpts ...grpc.CallOption) error

DeleteVolume issues a DeleteVolume request to a CSI controller.

func ErrControllerGetCapabilities

ErrControllerGetCapabilities returns a ControllerGetCapabilitiesResponse with a GeneralError.

func ErrControllerPublishVolume

ErrControllerPublishVolume returns a ControllerPublishVolumeResponse with a ControllerPublishVolumeVolumeError.

func ErrControllerPublishVolumeGeneral

func ErrControllerPublishVolumeGeneral(
	code csi.Error_GeneralError_GeneralErrorCode,
	msg string) *csi.ControllerPublishVolumeResponse

ErrControllerPublishVolumeGeneral returns a ControllerPublishVolumeResponse with a GeneralError.

func ErrControllerUnpublishVolume

ErrControllerUnpublishVolume returns a ControllerUnpublishVolumeResponse with a ControllerUnpublishVolumeVolumeError.

func ErrControllerUnpublishVolumeGeneral

func ErrControllerUnpublishVolumeGeneral(
	code csi.Error_GeneralError_GeneralErrorCode,
	msg string) *csi.ControllerUnpublishVolumeResponse

ErrControllerUnpublishVolumeGeneral returns a ControllerUnpublishVolumeResponse with a GeneralError.

func ErrCreateVolume

ErrCreateVolume returns a CreateVolumeResponse with a CreateVolumeError.

func ErrCreateVolumeGeneral

func ErrCreateVolumeGeneral(
	code csi.Error_GeneralError_GeneralErrorCode,
	msg string) *csi.CreateVolumeResponse

ErrCreateVolumeGeneral returns a CreateVolumeResponse with a GeneralError.

func ErrDeleteVolume

ErrDeleteVolume returns a DeleteVolumeResponse with a DeleteVolumeError.

func ErrDeleteVolumeGeneral

func ErrDeleteVolumeGeneral(
	code csi.Error_GeneralError_GeneralErrorCode,
	msg string) *csi.DeleteVolumeResponse

ErrDeleteVolumeGeneral returns a DeleteVolumeResponse with a GeneralError.

func ErrGetCapacity

ErrGetCapacity returns a GetCapacityResponse with a GeneralError.

func ErrGetNodeID

ErrGetNodeID returns a GetNodeIDResponse with a GetNodeIDError.

func ErrGetNodeIDGeneral

func ErrGetNodeIDGeneral(
	code csi.Error_GeneralError_GeneralErrorCode,
	msg string) *csi.GetNodeIDResponse

ErrGetNodeIDGeneral returns a GetNodeIDResponse with a GeneralError.

func ErrGetPluginInfo

ErrGetPluginInfo returns a GetPluginInfoResponse with a GeneralError.

func ErrGetSupportedVersions

ErrGetSupportedVersions returns a GetSupportedVersionsResponse with a GeneralError.

func ErrListVolumes

ErrListVolumes returns a ListVolumesResponse with a GeneralError.

func ErrNodeGetCapabilities

ErrNodeGetCapabilities returns a NodeGetCapabilitiesResponse with a GeneralError.

func ErrNodePublishVolume

ErrNodePublishVolume returns a NodePublishVolumeResponse with a NodePublishVolumeError.

func ErrNodePublishVolumeGeneral

func ErrNodePublishVolumeGeneral(
	code csi.Error_GeneralError_GeneralErrorCode,
	msg string) *csi.NodePublishVolumeResponse

ErrNodePublishVolumeGeneral returns a NodePublishVolumeResponse with a GeneralError.

func ErrNodeUnpublishVolume

ErrNodeUnpublishVolume returns a NodeUnpublishVolumeResponse with a NodeUnpublishVolumeError.

func ErrNodeUnpublishVolumeGeneral

func ErrNodeUnpublishVolumeGeneral(
	code csi.Error_GeneralError_GeneralErrorCode,
	msg string) *csi.NodeUnpublishVolumeResponse

ErrNodeUnpublishVolumeGeneral returns a NodeUnpublishVolumeResponse with a GeneralError.

func ErrProbeNode

ErrProbeNode returns a ProbeNodeResponse with a ProbeNodeError.

func ErrProbeNodeGeneral

func ErrProbeNodeGeneral(
	code csi.Error_GeneralError_GeneralErrorCode,
	msg string) *csi.ProbeNodeResponse

ErrProbeNodeGeneral returns a ProbeNodeResponse with a GeneralError.

func ErrValidateVolumeCapabilities

ErrValidateVolumeCapabilities returns a ValidateVolumeCapabilitiesResponse with a ValidateVolumeCapabilitiesError.

func ErrValidateVolumeCapabilitiesGeneral

func ErrValidateVolumeCapabilitiesGeneral(
	code csi.Error_GeneralError_GeneralErrorCode,
	msg string) *csi.ValidateVolumeCapabilitiesResponse

ErrValidateVolumeCapabilitiesGeneral returns a ValidateVolumeCapabilitiesResponse with a GeneralError.

func GetCSIEndpoint

func GetCSIEndpoint() (network, addr string, err error)

GetCSIEndpoint returns the network address specified by the environment variable CSI_ENDPOINT.

func GetCSIEndpointListener

func GetCSIEndpointListener() (net.Listener, error)

GetCSIEndpointListener returns the net.Listener for the endpoint specified by the environment variable CSI_ENDPOINT.

func GetCapacity

func GetCapacity(
	ctx context.Context,
	c csi.ControllerClient,
	version *csi.Version,
	volumeCapabilities []*csi.VolumeCapability,
	callOpts ...grpc.CallOption) (uint64, error)

GetCapacity issues a GetCapacity request to a CSI controller

func GetNodeID

func GetNodeID(
	ctx context.Context,
	c csi.NodeClient,
	version *csi.Version,
	callOpts ...grpc.CallOption) (*csi.NodeID, error)

GetNodeID issues a GetNodeID request to a CSI controller.

func GetPluginInfo

func GetPluginInfo(
	ctx context.Context,
	c csi.IdentityClient,
	version *csi.Version,
	callOpts ...grpc.CallOption) (*csi.GetPluginInfoResponse_Result, error)

GetPluginInfo issues a GetPluginInfo request to a CSI controller.

func GetRequestID

func GetRequestID(ctx context.Context) (uint64, bool)

GetRequestID gets the gRPC request ID from the provided context.

func GetSupportedVersions

func GetSupportedVersions(
	ctx context.Context,
	c csi.IdentityClient,
	callOpts ...grpc.CallOption) ([]*csi.Version, error)

GetSupportedVersions issues a GetSupportedVersions request to a CSI controller.

func ListVolumes

func ListVolumes(
	ctx context.Context,
	c csi.ControllerClient,
	version *csi.Version,
	maxEntries uint32,
	startingToken string,
	callOpts ...grpc.CallOption) (
	volumes []*csi.VolumeInfo, nextToken string, err error)

ListVolumes issues a ListVolumes request to a CSI controller.

func NewBlockCapability

func NewBlockCapability(
	mode csi.VolumeCapability_AccessMode_Mode) *csi.VolumeCapability

NewBlockCapability returns a new *csi.VolumeCapability for a volume that is to be accessed as a raw device.

func NewIdempotentInterceptor

func NewIdempotentInterceptor(
	p IdempotencyProvider,
	timeout time.Duration) grpc.UnaryServerInterceptor

NewIdempotentInterceptor returns a new server-side, gRPC interceptor that can be used in conjunction with an IdempotencyProvider to provide serialized, idempotent access to the following CSI RPCs:

  • CreateVolume
  • DeleteVolume
  • ControllerPublishVolume
  • ControllerUnpublishVolume
  • NodePublishVolume
  • NodeUnpublishVolume

func NewMountCapability

func NewMountCapability(
	mode csi.VolumeCapability_AccessMode_Mode,
	fsType string,
	mountFlags []string) *csi.VolumeCapability

NewMountCapability returns a new *csi.VolumeCapability for a volume that is to be mounted.

func NewServerRequestLogger

func NewServerRequestLogger(
	stdout, stderr io.Writer) grpc.UnaryServerInterceptor

NewServerRequestLogger initializes a new unary, server interceptor that logs request details.

func NewServerRequestVersionValidator

func NewServerRequestVersionValidator(
	supported []*csi.Version) grpc.UnaryServerInterceptor

NewServerRequestVersionValidator initializes a new unary server interceptor that validates request versions against the list of supported versions.

func NewServerResponseLogger

func NewServerResponseLogger(
	stdout, stderr io.Writer) grpc.UnaryServerInterceptor

NewServerResponseLogger initializes a new unary, server interceptor that logs reply details.

func NodeGetCapabilities

func NodeGetCapabilities(
	ctx context.Context,
	c csi.NodeClient,
	version *csi.Version,
	callOpts ...grpc.CallOption) (
	capabilties []*csi.NodeServiceCapability, err error)

NodeGetCapabilities issues a NodeGetCapabilities request to a CSI controller.

func NodePublishVolume

func NodePublishVolume(
	ctx context.Context,
	c csi.NodeClient,
	version *csi.Version,
	volumeID *csi.VolumeID,
	volumeMetadata *csi.VolumeMetadata,
	publishVolumeInfo *csi.PublishVolumeInfo,
	targetPath string,
	volumeCapability *csi.VolumeCapability,
	readonly bool,
	callOpts ...grpc.CallOption) error

NodePublishVolume issues a NodePublishVolume request to a CSI controller.

func NodeUnpublishVolume

func NodeUnpublishVolume(
	ctx context.Context,
	c csi.NodeClient,
	version *csi.Version,
	volumeID *csi.VolumeID,
	volumeMetadata *csi.VolumeMetadata,
	targetPath string,
	callOpts ...grpc.CallOption) error

NodeUnpublishVolume issues a NodeUnpublishVolume request to a CSI controller.

func ParseProtoAddr

func ParseProtoAddr(protoAddr string) (proto string, addr string, err error)

ParseProtoAddr parses a Golang network address.

func ProbeNode

func ProbeNode(
	ctx context.Context,
	c csi.NodeClient,
	version *csi.Version,
	callOpts ...grpc.CallOption) error

ProbeNode issues a ProbeNode request to a CSI controller.

func ServerRequestIDInjector

func ServerRequestIDInjector(
	ctx context.Context,
	req interface{},
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler) (interface{}, error)

ServerRequestIDInjector is a unary server interceptor that injects request contexts with a unique request ID.

func ServerRequestValidator

func ServerRequestValidator(
	ctx context.Context,
	req interface{},
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler) (interface{}, error)

ServerRequestValidator is a UnaryServerInterceptor that validates server request data.

func SprintfVersion

func SprintfVersion(v Version) string

SprintfVersion formats a Version as a string.

func ValidateVolumeCapabilities

func ValidateVolumeCapabilities(
	ctx context.Context,
	c csi.ControllerClient,
	version *csi.Version,
	volumeInfo *csi.VolumeInfo,
	volumeCapabilities []*csi.VolumeCapability,
	callOpts ...grpc.CallOption) (*csi.ValidateVolumeCapabilitiesResponse_Result, error)

ValidateVolumeCapabilities issues a ValidateVolumeCapabilities request to a CSI controller

Types

type Error

type Error struct {
	// Code is the error code.
	Code int32
	// Description is the error description.
	Description string
	// FullMethod is the full name of the CSI method that returned the error.
	FullMethod string
	// InnerError is an optional inner error wrapped by this error.
	InnerError error
}

Error is a client-side representation of the error message data returned from a CSI endpoint.

func (*Error) Error

func (e *Error) Error() string

func (*Error) ErrorCode

func (e *Error) ErrorCode() int32

ErrorCode returns the CSI error code.

func (*Error) ErrorDescription

func (e *Error) ErrorDescription() string

ErrorDescription returns the CSI error description.

func (*Error) ErrorFullMethod

func (e *Error) ErrorFullMethod() string

ErrorFullMethod returns the full name of the CSI method that returned the error.

func (*Error) ErrorMethod

func (e *Error) ErrorMethod() string

ErrorMethod returns the name-only of the CSI method that returned the error.

func (*Error) MarshalText

func (e *Error) MarshalText() (text []byte, err error)

MarshalText encodes the receiver into UTF-8-encoded text and returns the result.

func (*Error) String

func (e *Error) String() string

type IdempotencyProvider

type IdempotencyProvider interface {
	// GetVolumeName should return the name of the volume specified
	// by the provided volume ID. If the volume does not exist then
	// an empty string should be returned.
	GetVolumeName(
		ctx context.Context,
		id *csi.VolumeID) (string, error)

	// GetVolumeInfo should return information about the volume
	// specified by the provided volume name. If the volume does not
	// exist then a nil value should be returned.
	GetVolumeInfo(
		ctx context.Context,
		name string) (*csi.VolumeInfo, error)

	// IsControllerPublished should return publication info about
	// the volume specified by the provided volume name or ID.
	IsControllerPublished(
		ctx context.Context,
		id *csi.VolumeID) (*csi.PublishVolumeInfo, error)

	// IsNodePublished should return a flag indicating whether or
	// not the volume exists and is published on the current host.
	IsNodePublished(
		ctx context.Context,
		id *csi.VolumeID,
		pubVolInfo *csi.PublishVolumeInfo,
		targetPath string) (bool, error)
}

IdempotencyProvider is the interface that works with a server-side, gRPC interceptor to provide serial access and idempotency for CSI's volume resources.

type MutexWithTryLock

type MutexWithTryLock interface {
	// Lock locks the mutex.
	Lock()
	// Unlock unlocks the mutex.
	Unlock()
	// TryLock attempts to obtain a lock but times out if no lock
	// can be obtained in the specified duration. A flag is returned
	// indicating whether or not the lock was obtained.
	TryLock(timeout time.Duration) bool
}

MutexWithTryLock is a lock object that implements the semantics of a sync.Mutex in addition to a TryLock function.

func NewMutexWithTryLock

func NewMutexWithTryLock() MutexWithTryLock

NewMutexWithTryLock returns a new mutex that implements TryLock.

type Version

type Version interface {
	GetMajor() uint32
	GetMinor() uint32
	GetPatch() uint32
}

Version is a type that responds with Major, Minor, and Patch information typical of a semantic version.

func ParseVersion

func ParseVersion(s string) (Version, error)

ParseVersion parses any string that matches \d+\.\d+\.\d+ and returns a Version.

Directories

Path Synopsis
Package csi is a generated protocol buffer package.
Package csi is a generated protocol buffer package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL