csi_util

package
v1.33.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2025 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LOAD_LNET_KERNEL_MODULE_COMMAND       = "modprobe lnet"
	CONFIGURE_LNET_KERNEL_SERVICE_COMMAND = "lnetctl lnet configure"
	SHOW_CONFIGURED_LNET                  = "lnetctl net show --net %s"
	DELETE_LNET_INTERFACE                 = "lnetctl net del --net %s"
	CONFIGURE_LNET_INTERFACE              = "lnetctl net add --net %s --if %s --peer-timeout 180 --peer-credits 120 --credits 1024"
	LCTL_SET_PARAM                        = "lctl set_param %s=%s"
	LFS_VERSION_COMMAND                   = "lfs --version"
)
View Source
const (
	// minimumVolumeSizeInBytes is used to validate that the user is not trying
	// to create a volume that is smaller than what we support
	MinimumVolumeSizeInBytes int64 = 50 * client.GiB

	// maximumVolumeSizeInBytes is used to validate that the user is not trying
	// to create a volume that is larger than what we support
	MaximumVolumeSizeInBytes int64 = 32 * client.TiB

	// Block Volume Performance Units
	VpusPerGB                     = "vpusPerGB"
	LowCostPerformanceOption      = 0
	BalancedPerformanceOption     = 10
	HigherPerformanceOption       = 20
	MaxUltraHighPerformanceOption = 120

	InTransitEncryptionPackageName = "oci-fss-utils"
	FIPS_ENABLED_FILE_PATH         = "/host/proc/sys/crypto/fips_enabled"
	CAT_COMMAND                    = "cat"
	RPM_COMMAND                    = "rpm-host"
	LabelIpFamilyPreferred         = "oci.oraclecloud.com/ip-family-preferred"
	LabelIpFamilyIpv4              = "oci.oraclecloud.com/ip-family-ipv4"
	LabelIpFamilyIpv6              = "oci.oraclecloud.com/ip-family-ipv6"
	IscsiIpv6Prefix                = "fd00:00c1::"

	Ipv6Stack = "IPv6"
	Ipv4Stack = "IPv4"

	// For Raw Block Volumes, the name of the bind-mounted file inside StagingTargetPath
	RawBlockStagingFile = "mountfile"

	AvailabilityDomainLabel = "csi-ipv6-full-ad-name"
)

Variables

View Source
var (
	DiskByPathPatternPV    = `/dev/disk/by-path/pci-\w{4}:\w{2}:\w{2}\.\d+-scsi-\d+:\d+:\d+:\d+$`
	DiskByPathPatternISCSI = `/dev/disk/by-path/ip-[[?\w\.\:]+]?:\d+-iscsi-[\w\.\-:]+-lun-\d+$`
)

Functions

func ConvertIscsiIpFromIpv4ToIpv6 added in v1.28.2

func ConvertIscsiIpFromIpv4ToIpv6(ipv4IscsiIp string) (string, error)

func CreateFilePath added in v1.28.2

func CreateFilePath(logger *zap.SugaredLogger, path string) error

Creates a file on the specified path after creating the containing directory

func ExtractBlockVolumePerformanceLevel added in v1.19.12

func ExtractBlockVolumePerformanceLevel(attribute string) (int64, error)

Extracts the vpusPerGB as int64 from given string input

func ExtractISCSIInformation

func ExtractISCSIInformation(attributes map[string]string) (*disk.Disk, error)

func ExtractISCSIInformationFromMountPath

func ExtractISCSIInformationFromMountPath(logger *zap.SugaredLogger, diskPath []string) (*disk.Disk, error)

func ExtractStorage

func ExtractStorage(capRange *csi.CapacityRange) (int64, error)

extractStorage extracts the storage size in bytes from the given capacity range. If the capacity range is not satisfied it returns the default volume size. If the capacity range is below or above supported sizes, it returns an error.

func FormatBytes

func FormatBytes(inputBytes int64) string

func FormatValidIp added in v1.28.2

func FormatValidIp(ipAddress string) string

func FormatValidIpStackInK8SConvention added in v1.28.2

func FormatValidIpStackInK8SConvention(ipStack string) string

func GetBlockSizeBytes added in v1.24.0

func GetBlockSizeBytes(logger *zap.SugaredLogger, devicePath string) (int64, error)

func GetIsFeatureEnabledFromEnv added in v1.26.4

func GetIsFeatureEnabledFromEnv(logger *zap.SugaredLogger, featureName string, defaultValue bool) bool

func GetKubeClient

func GetKubeClient(logger *zap.SugaredLogger, master, kubeconfig string) *kubernetes.Clientset

func GetPathForBlock added in v1.28.2

func GetPathForBlock(volumePath string) string

Get the staging target filepath inside the given stagingTargetPath, to be used for raw block volume support

func IsDualStackSubnet added in v1.28.2

func IsDualStackSubnet(subnet *core.Subnet) bool

func IsFipsEnabled added in v1.24.0

func IsFipsEnabled() (string, error)

func IsInTransitEncryptionPackageInstalled added in v1.24.0

func IsInTransitEncryptionPackageInstalled() (bool, error)

func IsIpv4 added in v1.28.2

func IsIpv4(ipAddress string) bool

func IsIpv4SingleStackSubnet added in v1.28.2

func IsIpv4SingleStackSubnet(subnet *core.Subnet) bool

func IsIpv6 added in v1.28.2

func IsIpv6(ipAddress string) bool

func IsIpv6SingleStackNode added in v1.29.2

func IsIpv6SingleStackNode(nodeMetadata *NodeMetadata) bool

func IsIpv6SingleStackSubnet added in v1.28.2

func IsIpv6SingleStackSubnet(subnet *core.Subnet) bool

func IsValidIpFamilyPresentInClusterIpFamily added in v1.28.2

func IsValidIpFamilyPresentInClusterIpFamily(clusterIpFamily string) bool

func LoadCSIConfigFromConfigMap added in v1.30.2

func LoadCSIConfigFromConfigMap(csiConfig *CSIConfig, k kubernetes.Interface, configMapName string, logger *zap.SugaredLogger)

func MaxOfInt

func MaxOfInt(a, b int64) int64

func RoundUpMinSize

func RoundUpMinSize() int64

func RoundUpSize

func RoundUpSize(volumeSizeBytes int64, allocationUnitBytes int64) int64

func ValidateDNSName added in v1.28.2

func ValidateDNSName(name string) bool

func ValidateFsType

func ValidateFsType(logger *zap.SugaredLogger, fsType string) string

func ValidateLustreParameters added in v1.30.2

func ValidateLustreParameters(logger *zap.SugaredLogger, lustreParamsJson string) error

func ValidateLustreVolumeId added in v1.28.2

func ValidateLustreVolumeId(lusterVolumeId string) (bool, string)

ValidateLustreVolumeId takes lustreVolumeId as input and returns if its valid or not along with lnetLabel Ex. volume handle : 10.112.10.6@tcp1:/fsname

volume handle : <MGS NID>[:<MGS NID>]:/<fsname>

Types

type CSIConfig added in v1.30.2

type CSIConfig struct {
	Lustre   *DriverConfig `yaml:"lustre"`
	IsLoaded bool
}

CSIConfig represents the structure of the ConfigMap data.

type DriverConfig added in v1.30.2

type DriverConfig struct {
	SkipNodeUnstage      bool `yaml:"skipNodeUnstage"`
	SkipLustreParameters bool `yaml:"skipLustreParameters"`
}

DriverConfig represents driver-specific configurations.

type FSSVolumeHandler added in v1.24.1

type FSSVolumeHandler struct {
	FilesystemOcid       string
	MountTargetIPAddress string
	FsExportPath         string
}

func ValidateFssId added in v1.24.1

func ValidateFssId(id string) *FSSVolumeHandler

type LnetConfigurator added in v1.30.2

type LnetConfigurator interface {
	GetNetInterfacesInSubnet(subnetCIDR string) ([]NetInterface, error)
	IsLustreClientPackagesInstalled(logger *zap.SugaredLogger) bool
	GetLnetInfoByLnetLabel(lnetLabel string) (NetInfo, error)
	ConfigureLnet(logger *zap.SugaredLogger, ifaces []NetInterface, lnetLabel string, netInfo NetInfo) error
	VerifyLnetConfiguration(logger *zap.SugaredLogger, ifaces []NetInterface, lnetLabel string, netInfo NetInfo, err error) error
	ExecuteCommandOnWorkerNode(args ...string) (string, error)
}

type LnetService added in v1.30.2

type LnetService struct {
	Configurator LnetConfigurator
}

func NewLnetService added in v1.30.2

func NewLnetService() *LnetService

func (*LnetService) ApplyLustreParameters added in v1.30.2

func (ls *LnetService) ApplyLustreParameters(logger *zap.SugaredLogger, lustreParamsJson string) error

func (*LnetService) IsLnetActive added in v1.30.2

func (ls *LnetService) IsLnetActive(logger *zap.SugaredLogger, lnetLabel string) bool

IsLnetActive takes lnetLabel (ex. tcp0, tcp1) as input and tries to check if at leaset one lnet interface is active to consider lnet as active. It returns true when active lnet interface is identified else returns false singling down lnet.

func (*LnetService) SetupLnet added in v1.30.2

func (ls *LnetService) SetupLnet(logger *zap.SugaredLogger, lustreSubnetCIDR string, lnetLabel string) error

type NetInfo added in v1.28.2

type NetInfo struct {
	Net []struct {
		NetType string `yaml:"net type"`
		LocalNI []struct {
			NID        string         `yaml:"nid"`
			Status     string         `yaml:"status"`
			Interfaces map[int]string `yaml:"interfaces"`
		} `yaml:"local NI(s)"`
	} `yaml:"net"`
}

type NetInterface added in v1.28.2

type NetInterface struct {
	InterfaceIPv4  string
	InterfaceName  string
	LnetConfigured bool
}

type NodeMetadata added in v1.30.2

type NodeMetadata struct {
	PreferredNodeIpFamily  string
	Ipv4Enabled            bool
	Ipv6Enabled            bool
	AvailabilityDomain     string
	FullAvailabilityDomain string
	IsNodeMetadataLoaded   bool
}

type OCILnetConfigurator added in v1.30.2

type OCILnetConfigurator struct{}

func (*OCILnetConfigurator) ConfigureLnet added in v1.30.2

func (olc *OCILnetConfigurator) ConfigureLnet(logger *zap.SugaredLogger, interfacesInLustreSubnet []NetInterface, lnetLabel string, netInfo NetInfo) error

func (*OCILnetConfigurator) ExecuteCommandOnWorkerNode added in v1.30.2

func (olc *OCILnetConfigurator) ExecuteCommandOnWorkerNode(args ...string) (string, error)

func (*OCILnetConfigurator) GetLnetInfoByLnetLabel added in v1.30.2

func (olc *OCILnetConfigurator) GetLnetInfoByLnetLabel(lnetLabel string) (NetInfo, error)

func (*OCILnetConfigurator) GetNetInterfacesInSubnet added in v1.30.2

func (olc *OCILnetConfigurator) GetNetInterfacesInSubnet(subnetCIDR string) ([]NetInterface, error)

func (*OCILnetConfigurator) IsLustreClientPackagesInstalled added in v1.30.2

func (olc *OCILnetConfigurator) IsLustreClientPackagesInstalled(logger *zap.SugaredLogger) bool

func (*OCILnetConfigurator) VerifyLnetConfiguration added in v1.30.2

func (olc *OCILnetConfigurator) VerifyLnetConfiguration(logger *zap.SugaredLogger, interfacesInLustreSubnet []NetInterface, lnetLabel string, netInfo NetInfo, err error) error

type Parameter added in v1.30.2

type Parameter map[string]interface{}

type Util

type Util struct {
	Logger *zap.SugaredLogger
}

Util interface

func (*Util) GetAvailableDomainInNodeLabel

func (u *Util) GetAvailableDomainInNodeLabel(fullAD string) string

convert "zkJl:US-ASHBURN-AD-1" to "US-ASHBURN-AD-1"

func (*Util) LoadNodeMetadataFromApiServer added in v1.30.2

func (u *Util) LoadNodeMetadataFromApiServer(ctx context.Context, k kubernetes.Interface, nodeID string, nodeMetadata *NodeMetadata) error

func (*Util) LookupNodeID

func (u *Util) LookupNodeID(k kubernetes.Interface, nodeName string) (string, error)

func (*Util) WaitForKubeApiServerToBeReachableWithContext added in v1.30.2

func (u *Util) WaitForKubeApiServerToBeReachableWithContext(ctx context.Context, k kubernetes.Interface, backOffCap time.Duration)

func (*Util) WaitForPathToExist

func (u *Util) WaitForPathToExist(path string, maxRetries int) bool

waitForPathToExist waits for for a given filesystem path to exist.

type VolumeLocks

type VolumeLocks struct {
	// contains filtered or unexported fields
}

func NewVolumeLocks

func NewVolumeLocks() *VolumeLocks

func (*VolumeLocks) Release

func (vl *VolumeLocks) Release(volumeID string)

func (*VolumeLocks) TryAcquire

func (vl *VolumeLocks) TryAcquire(volumeID string) bool

Jump to

Keyboard shortcuts

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