Documentation ¶
Index ¶
- Constants
- func CreateObject(monitors string, cr *Credentials, poolName, namespace, objectName string) error
- func ExecCommand(program string, args ...string) (stdout, stderr []byte, err error)
- func GenerateVolID(monitors string, cr *Credentials, pool, clusterID, objUUID string, ...) (string, error)
- func GetK8sNamespace() string
- func GetMonValFromSecret(secrets map[string]string) (string, error)
- func GetOMapValue(monitors string, cr *Credentials, ...) (string, error)
- func GetPoolID(monitors string, cr *Credentials, poolName string) (int64, error)
- func GetPoolName(monitors string, cr *Credentials, poolID int64) (string, error)
- func Mons(pathToConfig, clusterID string) (string, error)
- func NewK8sClient() *k8s.Clientset
- func RemoveOMapKey(monitors string, cr *Credentials, ...) error
- func RemoveObject(monitors string, cr *Credentials, poolName, namespace, oMapName string) error
- func RoundUpToMiB(size int64) int64
- func SetOMapKeyValue(monitors string, cr *Credentials, ...) error
- func StripSecretInArgs(args []string) []string
- func ValidateDriverName(driverName string) error
- func WriteCephConfig() error
- type CSIIdentifier
- type CSIJournal
- func (cj *CSIJournal) CheckReservation(monitors string, cr *Credentials, pool, reqName, parentName string) (string, error)
- func (cj *CSIJournal) GetObjectUUIDData(monitors string, cr *Credentials, pool, objectUUID string, snapSource bool) (string, string, error)
- func (cj *CSIJournal) NamingPrefix() string
- func (cj *CSIJournal) ReserveName(monitors string, cr *Credentials, pool, reqName, parentName string) (string, error)
- func (cj *CSIJournal) SetCSIDirectorySuffix(suffix string)
- func (cj *CSIJournal) SetNamespace(ns string)
- func (cj *CSIJournal) UndoReservation(monitors string, cr *Credentials, pool, volName, reqName string) error
- type CacheEntryNotFound
- type CachePersister
- type Credentials
- type ErrKeyNotFound
- type ErrObjectExists
- type ErrObjectNotFound
- type ErrSnapNameConflict
- type ForAllFunc
- type IDLock
- type IDLocker
- type K8sCMCache
- type NodeCache
- func (nc *NodeCache) Create(identifier string, data interface{}) error
- func (nc *NodeCache) Delete(identifier string) error
- func (nc *NodeCache) EnsureCacheDirectory(cacheDir string) error
- func (nc *NodeCache) ForAll(pattern string, destObj interface{}, f ForAllFunc) error
- func (nc *NodeCache) Get(identifier string, data interface{}) error
Constants ¶
const (
CephConfigPath = "/etc/ceph/ceph.conf"
)
const (
// MiB - MebiByte size
MiB = 1024 * 1024
)
remove this once kubernetes v1.14.0 release is done https://github.com/kubernetes/cloud-provider/blob/master/volume/helpers/rounding.go
const (
// PluginFolder defines location of plugins
PluginFolder = "/var/lib/kubelet/plugins"
)
Variables ¶
This section is empty.
Functions ¶
func CreateObject ¶
func CreateObject(monitors string, cr *Credentials, poolName, namespace, objectName string) error
CreateObject creates the object name passed in and returns ErrObjectExists if the provided object is already present in rados
func ExecCommand ¶
ExecCommand executes passed in program with args and returns separate stdout and stderr streams
func GenerateVolID ¶
func GenerateVolID(monitors string, cr *Credentials, pool, clusterID, objUUID string, volIDVersion uint16) (string, error)
GenerateVolID generates a volume ID based on passed in parameters and version, to be returned to the CO system
func GetK8sNamespace ¶
func GetK8sNamespace() string
GetK8sNamespace returns pod namespace. if pod namespace is empty it returns default namespace
func GetOMapValue ¶
func GetOMapValue(monitors string, cr *Credentials, poolName, namespace, oMapName, oMapKey string) (string, error)
GetOMapValue gets the value for the given key from the named omap
func GetPoolID ¶
func GetPoolID(monitors string, cr *Credentials, poolName string) (int64, error)
GetPoolID searches a list of pools in a cluster and returns the ID of the pool that matches the passed in poolName parameter
func GetPoolName ¶
func GetPoolName(monitors string, cr *Credentials, poolID int64) (string, error)
GetPoolName lists all pools in a ceph cluster, and matches the pool whose pool ID is equal to the requested poolID parameter
func RemoveOMapKey ¶
func RemoveOMapKey(monitors string, cr *Credentials, poolName, namespace, oMapName, oMapKey string) error
RemoveOMapKey removes the omap key from the given omap name
func RemoveObject ¶
func RemoveObject(monitors string, cr *Credentials, poolName, namespace, oMapName string) error
RemoveObject removes the entire omap name passed in and returns ErrObjectNotFound is provided omap is not found in rados
func RoundUpToMiB ¶
RoundUpToMiB rounds up given quantity upto chunks of MiB
func SetOMapKeyValue ¶
func SetOMapKeyValue(monitors string, cr *Credentials, poolName, namespace, oMapName, oMapKey, keyValue string) error
SetOMapKeyValue sets the given key and value into the provided Ceph omap name
func StripSecretInArgs ¶
StripSecretInArgs strips values of either "--key" or "secret=". `args` is left unchanged. Expects only one occurrence of either "--key" or "secret=".
func ValidateDriverName ¶
ValidateDriverName validates the driver name
Types ¶
type CSIIdentifier ¶
type CSIIdentifier struct { LocationID int64 EncodingVersion uint16 ClusterID string ObjectUUID string }
CSIIdentifier contains the elements that form a CSI ID to be returned by the CSI plugin, and contains enough information to decompose and extract required cluster and pool information to locate the volume that relates to the CSI ID.
The CSI identifier is composed as elaborated in the comment against ComposeCSIID and thus, DecomposeCSIID is the inverse of the same function.
The CSIIdentifier structure carries the following fields,
- LocationID: 64 bit integer identifier determining the location of the volume on the Ceph cluster. It is the ID of the poolname or fsname, for RBD or CephFS backed volumes respectively.
- EncodingVersion: Carries the version number of the encoding scheme used to encode the CSI ID, and is preserved for any future proofing w.r.t changes in the encoding scheme, and to retain ability to parse backward compatible encodings.
- ClusterID: Is a unique ID per cluster that the CSI instance is serving and is restricted to lengths that can be accommodated in the encoding scheme.
- ObjectUUID: Is the on-disk uuid of the object (image/snapshot) name, for the CSI volume that corresponds to this CSI ID.
func (CSIIdentifier) ComposeCSIID ¶
func (ci CSIIdentifier) ComposeCSIID() (string, error)
func (*CSIIdentifier) DecomposeCSIID ¶
func (ci *CSIIdentifier) DecomposeCSIID(composedCSIID string) (err error)
DecomposeCSIID composes a CSIIdentifier from passed in string
type CSIJournal ¶
type CSIJournal struct {
// contains filtered or unexported fields
}
func NewCSISnapshotJournal ¶
func NewCSISnapshotJournal() *CSIJournal
CSISnapshotSnapshot returns an instance of snapshot keys
func NewCSIVolumeJournal ¶
func NewCSIVolumeJournal() *CSIJournal
CSIVolumeJournal returns an instance of volume keys
func (*CSIJournal) CheckReservation ¶
func (cj *CSIJournal) CheckReservation(monitors string, cr *Credentials, pool, reqName, parentName string) (string, error)
CheckReservation checks if given request name contains a valid reservation - If there is a valid reservation, then the corresponding UUID for the volume/snapshot is returned - If there is a reservation that is stale (or not fully cleaned up), it is garbage collected using the UndoReservation call, as appropriate - If a snapshot is being checked, then its source is matched to the parentName that is provided
NOTE: As the function manipulates omaps, it should be called with a lock against the request name held, to prevent parallel operations from modifying the state of the omaps for this request name.
Return values:
- string: Contains the UUID that was reserved for the passed in reqName, empty if there was no reservation found
- error: non-nil in case of any errors
func (*CSIJournal) GetObjectUUIDData ¶
func (cj *CSIJournal) GetObjectUUIDData(monitors string, cr *Credentials, pool, objectUUID string, snapSource bool) (string, string, error)
GetObjectUUIDData fetches all keys from a UUID directory Return values:
- string: Contains the request name for the passed in UUID
- string: Contains the parent image name for the passed in UUID, if it is a snapshot
- error: non-nil in case of any errors
func (*CSIJournal) NamingPrefix ¶
func (cj *CSIJournal) NamingPrefix() string
NamingPrefix returns the value of naming prefix from the journal keys
func (*CSIJournal) ReserveName ¶
func (cj *CSIJournal) ReserveName(monitors string, cr *Credentials, pool, reqName, parentName string) (string, error)
ReserveName adds respective entries to the csiDirectory omaps, post generating a target UUIDDirectory for use. Further, these functions update the UUIDDirectory omaps, to store back pointers to the CSI generated request names.
NOTE: As the function manipulates omaps, it should be called with a lock against the request name held, to prevent parallel operations from modifying the state of the omaps for this request name.
Return values:
- string: Contains the UUID that was reserved for the passed in reqName
- error: non-nil in case of any errors
func (*CSIJournal) SetCSIDirectorySuffix ¶
func (cj *CSIJournal) SetCSIDirectorySuffix(suffix string)
SetCSIDirectorySuffix sets the given suffix for the csiDirectory omap
func (*CSIJournal) SetNamespace ¶
func (cj *CSIJournal) SetNamespace(ns string)
SetNamespace sets the namespace in which all RADOS objects would be created
func (*CSIJournal) UndoReservation ¶
func (cj *CSIJournal) UndoReservation(monitors string, cr *Credentials, pool, volName, reqName string) error
UndoReservation undoes a reservation, in the reverse order of ReserveName - The UUID directory is cleaned up before the VolName key in the csiDirectory is cleaned up
NOTE: Ensure that the Ceph volume (image or FS subvolume) backing the reservation is cleaned up prior to cleaning up the reservation
NOTE: As the function manipulates omaps, it should be called with a lock against the request name held, to prevent parallel operations from modifying the state of the omaps for this request name.
type CacheEntryNotFound ¶
type CacheEntryNotFound struct {
// contains filtered or unexported fields
}
CacheEntryNotFound is an error type for "Not Found" cache errors
type CachePersister ¶
type CachePersister interface { Create(identifier string, data interface{}) error Get(identifier string, data interface{}) error ForAll(pattern string, destObj interface{}, f ForAllFunc) error Delete(identifier string) error }
CachePersister interface implemented for store
func CreatePersistanceStorage ¶
func CreatePersistanceStorage(sPath, metaDataStore, driverName string) (CachePersister, error)
CreatePersistanceStorage creates storage path and initializes new cache
func NewCachePersister ¶
func NewCachePersister(metadataStore, driverName string) (CachePersister, error)
NewCachePersister returns CachePersister based on store
type Credentials ¶
func GetAdminCredentials ¶
func GetAdminCredentials(secrets map[string]string) (*Credentials, error)
func GetUserCredentials ¶
func GetUserCredentials(secrets map[string]string) (*Credentials, error)
type ErrKeyNotFound ¶
type ErrKeyNotFound struct {
// contains filtered or unexported fields
}
ErrKeyNotFound is returned when requested key in omap is not found
func (ErrKeyNotFound) Error ¶
func (e ErrKeyNotFound) Error() string
type ErrObjectExists ¶
type ErrObjectExists struct {
// contains filtered or unexported fields
}
ErrObjectExists is returned when named omap is already present in rados
func (ErrObjectExists) Error ¶
func (e ErrObjectExists) Error() string
type ErrObjectNotFound ¶
type ErrObjectNotFound struct {
// contains filtered or unexported fields
}
ErrObjectNotFound is returned when named omap is not found in rados
func (ErrObjectNotFound) Error ¶
func (e ErrObjectNotFound) Error() string
type ErrSnapNameConflict ¶
type ErrSnapNameConflict struct {
// contains filtered or unexported fields
}
ErrSnapNameConflict is generated when a requested CSI snap name already exists on RBD but with different properties, and hence is in conflict with the passed in CSI volume name
func (ErrSnapNameConflict) Error ¶
func (e ErrSnapNameConflict) Error() string
type ForAllFunc ¶
ForAllFunc is a unary predicate for visiting all cache entries matching the `pattern' in CachePersister's ForAll function.
type IDLock ¶
type IDLock struct {
// contains filtered or unexported fields
}
IDLock is a per identifier lock with a use counter that retains a number of users of the lock. IDLocker is a map of IDLocks holding the IDLocks based on a passed in identifier. Typical usage (post creating an IDLocker) is to Lock/Unlock based on identifiers as per the API.
type IDLocker ¶
type IDLocker struct {
// contains filtered or unexported fields
}
IDLock is a per identifier lock with a use counter that retains a number of users of the lock. IDLocker is a map of IDLocks holding the IDLocks based on a passed in identifier. Typical usage (post creating an IDLocker) is to Lock/Unlock based on identifiers as per the API.
type K8sCMCache ¶
K8sCMCache to store metadata
func (*K8sCMCache) Create ¶
func (k8scm *K8sCMCache) Create(identifier string, data interface{}) error
Create stores the metadata in configmaps with identifier name
func (*K8sCMCache) Delete ¶
func (k8scm *K8sCMCache) Delete(identifier string) error
Delete deletes the metadata in configmaps with identifier name
func (*K8sCMCache) ForAll ¶
func (k8scm *K8sCMCache) ForAll(pattern string, destObj interface{}, f ForAllFunc) error
ForAll list the metadata in configmaps and filters outs based on the pattern
func (*K8sCMCache) Get ¶
func (k8scm *K8sCMCache) Get(identifier string, data interface{}) error
Get retrieves the metadata in configmaps with identifier name
type NodeCache ¶
NodeCache to store metadata
func (*NodeCache) Create ¶
Create creates the metadata file in cache directory with identifier name
func (*NodeCache) Delete ¶
Delete deletes the metadata file from cache directory with identifier name
func (*NodeCache) EnsureCacheDirectory ¶
EnsureCacheDirectory creates cache directory if not present
func (*NodeCache) ForAll ¶
func (nc *NodeCache) ForAll(pattern string, destObj interface{}, f ForAllFunc) error
ForAll list the metadata in Nodecache and filters outs based on the pattern