Documentation ¶
Index ¶
- Constants
- Variables
- func CombineTwoStrings(s1 string, s2 string, sign string) string
- func GetAccessMode(req *csi.ControllerPublishVolumeRequest) (*csi.VolumeCapability_AccessMode_Mode, error)
- func GetCurrentLogLevel() logrus.Level
- func GetExportIDFromConflictMessage(message string) int
- func GetFQDNByIP(ctx context.Context, ip string) (string, error)
- func GetIsiPathFromExportPath(exportPath string) string
- func GetIsiPathFromPgID(exportPath string) string
- func GetLogger() *logrus.Logger
- func GetMessageWithRunID(runid string, format string, args ...interface{}) string
- func GetNewUUID() (string, error)
- func GetNormalizedSnapshotID(ctx context.Context, snapshotID, clusterName string) string
- func GetNormalizedVolumeID(ctx context.Context, volName string, exportID int, ...) string
- func GetOwnFQDN() (string, error)
- func GetPathForVolume(isiPath, volName string) string
- func GetQuotaIDFromDescription(ctx context.Context, export isi.Export) (string, error)
- func GetQuotaIDWithCSITag(quotaID string) string
- func GetRunIDLogger(ctx context.Context) *logrus.Entry
- func GetVolumeNameFromExportPath(exportPath string) string
- func IsStringInSlice(str string, list []string) bool
- func IsStringInSlices(str string, list ...[]string) bool
- func LogMap(ctx context.Context, mapName string, m map[string]string)
- func ParseArrayFromContext(ctx context.Context, key string) ([]string, error)
- func ParseBooleanFromContext(ctx context.Context, key string) bool
- func ParseInt64FromContext(ctx context.Context, key string) (int64, error)
- func ParseLogLevel(lvl string) (logrus.Level, error)
- func ParseNodeID(ctx context.Context, nodeID string) (string, string, string, error)
- func ParseNormalizedSnapshotID(ctx context.Context, snapID string) (string, string, error)
- func ParseNormalizedVolumeID(ctx context.Context, volID string) (string, int, string, string, error)
- func ParseUintFromContext(ctx context.Context, key string) uint
- func RemoveExistingCSISockFile() error
- func RemoveStringFromSlice(str string, list []string) []string
- func RemoveStringsFromSlice(filters []string, list []string) []string
- func RemoveSurroundingQuotes(s string) string
- func UpdateLogLevel(lvl logrus.Level)
- type Formatter
- type LogConst
Constants ¶
const ( ClusterName = "clusterName" PowerScaleLogger LogConst = "powerscalelog" LogFields LogConst = "fields" RequestID = "requestid" RunID = "runid" )
Constants used for logging
Variables ¶
var CSIQuotaIDPrefix = "CSI_QUOTA_ID:"
CSIQuotaIDPrefix is the CSI tag for quota id stored in the export's description field set by csi driver
var DummyHostNodeID = "localhost=#=#=localhost=#=#=127.0.0.1"
DummyHostNodeID is nodeID used for adding dummy client in client field of export
var ExportConflictMessagePattern = regexp.MustCompile(fmt.Sprintf("^Export rules (\\d+) and (\\d+) conflict on '(.+)'$"))
ExportConflictMessagePattern is the regex pattern that identifies the error message of export conflict
var NodeIDPattern = regexp.MustCompile(fmt.Sprintf("^(.+)%s(.+)%s(.+)$", NodeIDSeparator, NodeIDSeparator))
NodeIDPattern is the regex pattern that identifies the NodeID
var NodeIDSeparator = "=#=#="
NodeIDSeparator is the separator that separates node name and IP Address
var QuotaIDPattern = regexp.MustCompile(fmt.Sprintf("^%s(.*)", CSIQuotaIDPrefix))
QuotaIDPattern the regex pattern that identifies the quota id set in the export's description field set by csi driver
var SnapshotIDSeparator = "=_=_="
SnapshotIDSeparator is the separator that separates snapshot id and cluster name (two components that a normalized snapshot ID is comprised of)
var VolumeIDPattern = regexp.MustCompile(fmt.Sprintf("^(.+)%s(\\d+)%s(.+)$", VolumeIDSeparator, VolumeIDSeparator))
VolumeIDPattern is the regex pattern that identifies the quota id set in the export's description field set by csi driver
var VolumeIDSeparator = "=_=_="
VolumeIDSeparator is the separator that separates volume name and export ID (two components that a normalized volume ID is comprised of)
Functions ¶
func CombineTwoStrings ¶
CombineTwoStrings combines two string variables isolated by defined sign
func GetAccessMode ¶
func GetAccessMode(req *csi.ControllerPublishVolumeRequest) (*csi.VolumeCapability_AccessMode_Mode, error)
GetAccessMode extracts the access mode from the given *csi.ControllerPublishVolumeRequest instance
func GetCurrentLogLevel ¶
GetCurrentLogLevel updates the log level
func GetExportIDFromConflictMessage ¶
GetExportIDFromConflictMessage returns the export id of the export which is creating or just created when there occurs a conflict
func GetFQDNByIP ¶
GetFQDNByIP returns the FQDN based on the parsed ip address
func GetIsiPathFromExportPath ¶
GetIsiPathFromExportPath returns isiPath based on the export path
func GetIsiPathFromPgID ¶
GetIsiPathFromPgID returns isiPath based on the pg id
func GetMessageWithRunID ¶
GetMessageWithRunID returns message with runID information
func GetNormalizedSnapshotID ¶
GetNormalizedSnapshotID combines snapshotID ID and cluster name to form the normalized snapshot ID e.g. 12345 + cluster1 => 12345=_=_=cluster1
func GetNormalizedVolumeID ¶
func GetNormalizedVolumeID(ctx context.Context, volName string, exportID int, accessZone, clusterName string) string
GetNormalizedVolumeID combines volume name (i.e. the directory name), export ID, access zone and clusterName to form the normalized volume ID e.g. k8s-e89c9d089e + 19 + csi0zone + cluster1 => k8s-e89c9d089e=_=_=19=_=_=csi0zone=_=_=cluster1
func GetOwnFQDN ¶
GetOwnFQDN returns the FQDN of the node or controller itself
func GetPathForVolume ¶
GetPathForVolume gets the volume full path by the combination of isiPath and volumeName
func GetQuotaIDFromDescription ¶
GetQuotaIDFromDescription extracts quota id from the description field of export
func GetQuotaIDWithCSITag ¶
GetQuotaIDWithCSITag formats a given quota id with the CSI tag, e.g. AABpAQEAAAAAAAAAAAAAQA0AAAAAAAAA -> CSI_QUOTA_ID:AABpAQEAAAAAAAAAAAAAQA0AAAAAAAAA
func GetRunIDLogger ¶
GetRunIDLogger returns the current runID logger
func GetVolumeNameFromExportPath ¶
GetVolumeNameFromExportPath returns volume name based on the export path
func IsStringInSlice ¶
IsStringInSlice checks if a string is an element of a string slice
func IsStringInSlices ¶
IsStringInSlices checks if a string is an element of a any of the string slices
func ParseArrayFromContext ¶
ParseArrayFromContext parses an environment variable into an array of string
func ParseBooleanFromContext ¶
ParseBooleanFromContext parses an environment variable into a boolean value. If an error is encountered, default is set to false, and error is logged
func ParseInt64FromContext ¶
ParseInt64FromContext parses an environment variable into an int64 value.
func ParseLogLevel ¶
ParseLogLevel returns the logrus.Level of input log level string
func ParseNodeID ¶
ParseNodeID parses NodeID to node name, node FQDN and IP address using pattern '^(.+)=#=#=(.+)=#=#=(.+)'
func ParseNormalizedSnapshotID ¶
ParseNormalizedSnapshotID parses the normalized snapshot ID(using SnapshotIDSeparator) to extract the snapshot ID and cluster name(optional) that make up the normalized snapshot ID e.g. 12345 => 12345, "" e.g. 12345=_=_=cluster1 => 12345, cluster1
func ParseNormalizedVolumeID ¶
func ParseNormalizedVolumeID(ctx context.Context, volID string) (string, int, string, string, error)
ParseNormalizedVolumeID parses the volume ID(using VolumeIDSeparator) to extract the volume name, export ID, access zone and cluster name(optional) that make up the volume ID e.g. k8s-e89c9d089e=_=_=19=_=_=csi0zone => k8s-e89c9d089e, 19, csi0zone, "" e.g. k8s-e89c9d089e=_=_=19=_=_=csi0zone=_=_=cluster1 => k8s-e89c9d089e, 19, csi0zone, cluster1
func ParseUintFromContext ¶
ParseUintFromContext parses an environment variable into a uint value. If an error is encountered, default is set to 0, and error is logged
func RemoveExistingCSISockFile ¶
func RemoveExistingCSISockFile() error
RemoveExistingCSISockFile When the sock file that the gRPC server is going to be listening on already exists, error will be thrown saying the address is already in use, thus remove it first
func RemoveStringFromSlice ¶
RemoveStringFromSlice returns a slice that is a copy of the input "list" slice with the input "str" string removed
func RemoveStringsFromSlice ¶
RemoveStringsFromSlice generates a slice that is a copy of the input "list" slice with elements from the input "strs" slice removed
func RemoveSurroundingQuotes ¶
RemoveSurroundingQuotes removes the surrounding double quotes of a given string (if there are no surrounding quotes, do nothing)
Types ¶
type Formatter ¶
type Formatter struct { //logrus.TextFormatter // Timestamp format TimestampFormat string // Available standard keys: time, msg, lvl // Also can include custom fields but limited to strings. // All of fields need to be wrapped inside %% i.e %time% %msg% LogFormat string CallerPrettyfier func(*runtime.Frame) (function string, file string) }
Formatter implements logrus.Formatter interface.