Documentation
¶
Index ¶
Constants ¶
const ( DefaultTokenExpirySeconds = int64(600) // See "Service account tokens" in // https://kubernetes.io/docs/reference/access-authn-authz/authentication/. // It turns out that a service account name starts with a well defined prefix // that is guaranteed not to match any other user name. K8sServiceAccountUserNamePrefix = "system:serviceaccount:" )
Variables ¶
var ( ErrFailedToSeek = errors.New("failed to seek") ErrContentsDoNotMatch = errors.New("source and target device contents do not match") )
Functions ¶
func GetSnapshotMetadata ¶
GetSnapshotMetadata enumerates either the allocated blocks of a VolumeSnapshot object, or the blocks changed between a pair of VolumeSnapshot objects.
Metadata is returned via an emitter interface specified in the invocation arguments. Iteration terminates on the first error encountered, or if requested by the emitter.
Types ¶
type Args ¶
type Args struct {
// Client interfaces are obtained from BuildClients.
Clients
// Emitter is an interface used to return metadata to the invoker.
Emitter IteratorEmitter
// Specify the namespace of the VolumeSnapshot objects.
Namespace string
// SnapshotName identifies a VolumeSnaphot.
SnapshotName string
// PrevSnapshotID is the CSI handle of a VolumeSnapshot, set in
// the Status.SnapshotHandle field of its associated
// VolumeSnapshotContent object.
//
// The field is optional, and if specified will result in
// enumeration of the changed blocks between the VolumeSnapshot
// identified by it and that identified by the SnapshotName field.
//
// If both PrevSnapshotID and PrevSnapshotName are specified then
// the latter is ignored.
// If neither are specified then the allocated blocks of the VolumeSnapshot
// identified by SnapshotName will be enumerated.
PrevSnapshotID string
// PrevSnapshotName is optional, and if specified will result in
// enumeration of the changed blocks between the VolumeSnapshot
// identified by it and that identified by the SnapshotName field.
//
// If both PrevSnapshotID and PrevSnapshotName are specified then
// the latter is ignored.
// If neither are specified then the allocated blocks of the VolumeSnapshot
// identified by SnapshotName will be enumerated.
//
// If PrevSnapshotName is specified and PrevSnapshotID is not specified
// then the VolumeSnapshotContent object associated with the named
// VolumeSnapshot object will be used to obtain its CSI handle.
PrevSnapshotName string
// StartingOffset is the initial byte offset.
StartingOffset int64
// MaxResults is the number of tuples to return in each record.
// If 0 then the CSI driver decides the value.
MaxResults int32
// CSIDriver specifies the name of the CSI driver and is used to
// load the associated SnapshotMetadataService CR.
// The field is optional. If not specified then it
// will be fetched from the VolumeSnapshotContent of
// the VolumeSnapshot specified by the SnapshotName field.
CSIDriver string
// Specify the ServiceAccount object used to construct a security token
// with the audience string from the SnapshotMetadataService CR.
// If either of the following fields are unspecified, the default for the given client will be used.
SANamespace string
SAName string
// TokenExpirySecs specifies the time in seconds after which the
// security token will expire.
// If unspecified then the value of DefaultTokenExpirySeconds is used.
TokenExpirySecs int64
}
Args contains the arguments to the GetSnapshotMetadata function.
type Clients ¶
type Clients struct {
KubeClient kubernetes.Interface
SnapshotClient snapshot.Interface
SmsCRClient smsCR.Interface
}
func BuildClients ¶
BuildClients constructs the necessary client interfaces from the given configuration.
type IteratorEmitter ¶
type IteratorEmitter interface {
// SnapshotMetadataIteratorRecord is invoked for each record received
// from the gRPC stream.
SnapshotMetadataIteratorRecord(recordNumber int, metadata IteratorMetadata) error
// SnapshotMetadataIteratorDone is called prior to termination as long as
// no error was encountered.
SnapshotMetadataIteratorDone(numberRecords int) error
}
type IteratorMetadata ¶
type IteratorMetadata struct {
BlockMetadataType api.BlockMetadataType `json:"block_metadata_type"`
VolumeCapacityBytes int64 `json:"volume_capacity_bytes"`
BlockMetadata []*api.BlockMetadata `json:"block_metadata"`
}
IteratorMetadata returns a single metadata record. These fields are fetched from the stream returned by either GetMetadataAllocated or GetMetadataDelta.
type JSONEmitter ¶
JSONEmitter formats the metadata in JSON.
func (*JSONEmitter) SnapshotMetadataIteratorDone ¶
func (e *JSONEmitter) SnapshotMetadataIteratorDone(_ int) error
func (*JSONEmitter) SnapshotMetadataIteratorRecord ¶
func (e *JSONEmitter) SnapshotMetadataIteratorRecord(recordNumber int, metadata IteratorMetadata) error
type TableEmitter ¶
TableEmitter formats the metadata as a table.
func (*TableEmitter) SnapshotMetadataIteratorDone ¶
func (e *TableEmitter) SnapshotMetadataIteratorDone(_ int) error
func (*TableEmitter) SnapshotMetadataIteratorRecord ¶
func (e *TableEmitter) SnapshotMetadataIteratorRecord(recordNumber int, metadata IteratorMetadata) error
type VerifierEmitter ¶ added in v0.2.0
type VerifierEmitter struct {
// SourceDevice contains the source device file descriptor.
SourceDevice *os.File
// TargetDevice contains the target device file descriptor.
TargetDevice *os.File
}
VerifierEmitter will write the changed blocks from the source device to the target device at the designated offset and compare the contents of the source and target devices at the end.
func (*VerifierEmitter) SnapshotMetadataIteratorDone ¶ added in v0.2.0
func (verifierEmitter *VerifierEmitter) SnapshotMetadataIteratorDone(_ int) error
SnapshotMetadataIteratorDone will compare the contents of the source and target devices.
func (*VerifierEmitter) SnapshotMetadataIteratorRecord ¶ added in v0.2.0
func (verifierEmitter *VerifierEmitter) SnapshotMetadataIteratorRecord(_ int, metadata IteratorMetadata) error
SnapshotMetadataIteratorRecord will write the block from the source device to the target device at the designated offset.