Documentation ¶
Overview ¶
Copyright 2022/9/2 Alibaba Cloud.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2022/8/26 Alibaba Cloud.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2022/9/6 Alibaba Cloud.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2022/8/27 Alibaba Cloud.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func CheckMountPointOptions(mp *nodelocalstorage.MountPoint) bool
- func ContainInlineVolumes(pod *corev1.Pod) (contain bool, node string)
- func ContainsProvisioner(name string) bool
- func ContainsString(s []string, e string) bool
- func CreateNode(nodeInfo *TestNodeInfo) *corev1.Node
- func CreatePVsBound() []*corev1.PersistentVolume
- func CreatePod(podInfo *TestPodInfo) *corev1.Pod
- func CreateTestNodeLocalStorage() (crds []*localv1alpha1.NodeLocalStorage)
- func CreateTestNodeLocalStorage1() *localv1alpha1.NodeLocalStorage
- func CreateTestNodeLocalStorage2() *localv1alpha1.NodeLocalStorage
- func CreateTestNodeLocalStorage3() *localv1alpha1.NodeLocalStorage
- func CreateTestNodeLocalStorage4() *localv1alpha1.NodeLocalStorage
- func CreateTestPersistentVolume(pvInfos []TestPVInfo) (pvs []*corev1.PersistentVolume)
- func CreateTestPersistentVolumeClaim(pvcInfos []TestPVCInfo) (pvcs []*corev1.PersistentVolumeClaim)
- func CreateTestStorageClass() (scs []*storagev1.StorageClass)
- func CreateVolumeSnapshot(info *TestVolumeSnapshotInfo) *volumesnapshotv1.VolumeSnapshot
- func CreateVolumeSnapshotClass(info *TestVolumeSnapshotClassInfo) *volumesnapshotv1.VolumeSnapshotClass
- func EnsureBlock(target string) error
- func Format(source, fsType string) error
- func FormatBlockDevice(dev, fsType string) error
- func FsInfo(path string) (int64, int64, int64, int64, int64, int64, error)
- func GeneratePVPatch(oldPV, newPV *corev1.PersistentVolume) ([]byte, error)
- func GeneratePodPatch(oldPod, newPod *corev1.Pod) ([]byte, error)
- func GetAccessModes(caps []*csilib.VolumeCapability) *[]string
- func GetAddedAndRemovedItems(newList, oldList []string) (addedItems, unchangedItems, removedItems []string)
- func GetClusterID(kubeclient kubernetes.Interface) (string, error)
- func GetDeviceNameFromCsiPV(pv *corev1.PersistentVolume) string
- func GetInlineVolumeInfoFromParam(attributes map[string]string) (vgName string, size int64)
- func GetMediaTypeFromPVC(pvc *corev1.PersistentVolumeClaim, scLister storagelisters.StorageClassLister) (localtype.MediaType, error)
- func GetMetrics(path string) (*csilib.NodeGetVolumeStatsResponse, error)
- func GetMountPointFromCsiPV(pv *corev1.PersistentVolume) string
- func GetName(meta metav1.ObjectMeta) string
- func GetNameKey(nameSpace, name string) string
- func GetNodeNameFromCsiPV(pv *corev1.PersistentVolume) string
- func GetPVCRequested(pvc *corev1.PersistentVolumeClaim) int64
- func GetPVFromBoundPVC(pvc *corev1.PersistentVolumeClaim) (name string)
- func GetPVSize(pv *corev1.PersistentVolume) int64
- func GetPVStorageSize(pv *corev1.PersistentVolume) int64
- func GetStorageClassFromPV(pv *corev1.PersistentVolume, p storagev1informers.Interface) *storagev1.StorageClass
- func GetStorageClassFromPVC(pvc *corev1.PersistentVolumeClaim, scLister storagelisters.StorageClassLister) (*storagev1.StorageClass, error)
- func GetVGNameFromCsiPV(pv *corev1.PersistentVolume) string
- func GetVGNameFromPVC(pvc *corev1.PersistentVolumeClaim, scLister storagelisters.StorageClassLister) (string, error)
- func GetVGRequested(localPVs map[string]corev1.PersistentVolume, vgName string) (requested int64)
- func GetVolumeSnapshotContent(snapclient snapshot.Interface, snapshotContentID string) (*snapshotapi.VolumeSnapshotContent, error)
- func HashSpec(storage *nodelocalstorage.NodeLocalStorage) uint64
- func HashStorageSpec(obj interface{}) uint64
- func HashWithoutState(storage *nodelocalstorage.NodeLocalStorage) uint64
- func HttpJSON(w http.ResponseWriter, code int, result interface{})
- func HttpResponse(w http.ResponseWriter, code int, msg []byte)
- func IsBlockDevice(fullPath string) (bool, error)
- func IsEmpty(r string) bool
- func IsLocalPV(pv *corev1.PersistentVolume) (isLocalPV bool, node string)
- func IsLocalPVC(claim *corev1.PersistentVolumeClaim, ...) (bool, localtype.VolumeType)
- func IsOpenLocalPV(pv *corev1.PersistentVolume) (bool, localtype.VolumeType)
- func IsPodNeedAllocate(pod *corev1.Pod) bool
- func IsReadOnlyPV(pv *corev1.PersistentVolume) bool
- func IsReadOnlySnapshotPVC(claim *corev1.PersistentVolumeClaim, ...) bool
- func IsReadOnlySnapshotPVC2(claim *corev1.PersistentVolumeClaim, snapClient snapshot.Interface) bool
- func IsSnapshotClassReadOnly(className string, snapInformer volumesnapshotinformers.Interface) bool
- func IsSnapshotClassReadOnly2(className string, snapClient snapshot.Interface) bool
- func LocalPVType(sc *storagev1.StorageClass) localtype.VolumeType
- func MountBlock(source, target string, opts ...string) error
- func NeedSkip(args schedulerapi.ExtenderArgs) bool
- func NodeNameFromPV(pv *corev1.PersistentVolume) string
- func NodeNameFromPVC(pvc *corev1.PersistentVolumeClaim) string
- func PVCName(storageObj interface{}) string
- func PVCNameFromPV(pv *corev1.PersistentVolume) (pvcName, pvcNamespace string)
- func ParseWeight(nodeAntiAffinity string) (weights *pkg.NodeAntiAffinityWeight, err error)
- func PatchAllocateInfoToPV(ctx context.Context, kubeclientset kubernetes.Interface, ...) error
- func PodPvcAllowReschedule(pvcs []*corev1.PersistentVolumeClaim, fakeNow *time.Time) bool
- func PvcContainsSelectedNode(pvc *corev1.PersistentVolumeClaim) bool
- func Run(cmd string) (string, error)
- func SetupCgroupPathFormatter(driver CgroupDriverType)
- func SliceEquals(src interface{}, dst interface{}) bool
- func StringsContains(array []string, val string) (index int)
- func TimeTrack(start time.Time, name string)
- func WordSepNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName
- type CgroupDriverType
- type CommandRunFunc
- type TestInlineVolumeInfo
- type TestNodeInfo
- type TestPVCInfo
- type TestPVCPVInfo
- type TestPVCPVInfoList
- type TestPVInfo
- type TestPodInfo
- type TestVolumeSnapshotClassInfo
- type TestVolumeSnapshotInfo
Constants ¶
const ( Cgroupfs CgroupDriverType = "cgroupfs" Systemd CgroupDriverType = "systemd" KubeRootNameSystemd = "kubepods.slice/" KubeBurstableNameSystemd = "kubepods-burstable.slice/" KubeBesteffortNameSystemd = "kubepods-besteffort.slice/" KubeRootNameCgroupfs = "kubepods/" KubeBurstableNameCgroupfs = "burstable/" KubeBesteffortNameCgroupfs = "besteffort/" )
const ( DefaultNodeAffinityWeight int = 5 MinScore int = 0 MaxScore int = 10 )
const ( // General LocalGi uint64 = 1024 * 1024 * 1024 LocalMi uint64 = 1024 * 1024 TestPort int32 = 23000 LocalNameSpace string = "default" // Node NodeName1 string = "node-192.168.0.1" NodeName2 string = "node-192.168.0.2" NodeName3 string = "node-192.168.0.3" NodeName4 string = "node-192.168.0.4" //Pod InvolumePodName string = "involume_pod" // VG VGSSD string = "ssd" VGHDD string = "hdd" // StorageClass SCLVMWithVG string = "sc-vg" SCLVMWithoutVG string = "sc-novg" SCWithMP string = "sc-mp" SCWithDevice string = "sc-device" SCNoLocal string = "sc-nolocal" // PVC PVCWithVG string = "pvc-vg" PVCWithoutVG string = "pvc-novg" PVCSnapshot string = "pvc-snapshot" PVCWithVGError string = "pvc-vg-error" PVCWithMountPoint string = "pvc-mp" PVCWithDevice string = "pvc-device" PVCNoLocal string = "pvc-nolocal" // Pod TestPodName string = "testpod" )
Variables ¶
var CgroupPathFormatter = cgroupPathFormatterInSystemd
default use Systemd cgroup path format
Functions ¶
func CheckMountPointOptions ¶
func CheckMountPointOptions(mp *nodelocalstorage.MountPoint) bool
CheckDiskOptions excludes mp which is readyonly or with unsupported fs type
func ContainInlineVolumes ¶ added in v0.5.0
func ContainsProvisioner ¶
func CreateNode ¶ added in v0.6.0
func CreateNode(nodeInfo *TestNodeInfo) *corev1.Node
func CreatePVsBound ¶ added in v0.6.0
func CreatePVsBound() []*corev1.PersistentVolume
func CreatePod ¶ added in v0.6.0
func CreatePod(podInfo *TestPodInfo) *corev1.Pod
func CreateTestNodeLocalStorage ¶ added in v0.6.0
func CreateTestNodeLocalStorage() (crds []*localv1alpha1.NodeLocalStorage)
func CreateTestNodeLocalStorage1 ¶ added in v0.6.0
func CreateTestNodeLocalStorage1() *localv1alpha1.NodeLocalStorage
func CreateTestNodeLocalStorage2 ¶ added in v0.6.0
func CreateTestNodeLocalStorage2() *localv1alpha1.NodeLocalStorage
func CreateTestNodeLocalStorage3 ¶ added in v0.6.0
func CreateTestNodeLocalStorage3() *localv1alpha1.NodeLocalStorage
func CreateTestNodeLocalStorage4 ¶ added in v0.6.0
func CreateTestNodeLocalStorage4() *localv1alpha1.NodeLocalStorage
func CreateTestPersistentVolume ¶ added in v0.6.0
func CreateTestPersistentVolume(pvInfos []TestPVInfo) (pvs []*corev1.PersistentVolume)
func CreateTestPersistentVolumeClaim ¶ added in v0.6.0
func CreateTestPersistentVolumeClaim(pvcInfos []TestPVCInfo) (pvcs []*corev1.PersistentVolumeClaim)
func CreateTestStorageClass ¶ added in v0.6.0
func CreateTestStorageClass() (scs []*storagev1.StorageClass)
func CreateVolumeSnapshot ¶ added in v0.7.0
func CreateVolumeSnapshot(info *TestVolumeSnapshotInfo) *volumesnapshotv1.VolumeSnapshot
func CreateVolumeSnapshotClass ¶ added in v0.7.0
func CreateVolumeSnapshotClass(info *TestVolumeSnapshotClassInfo) *volumesnapshotv1.VolumeSnapshotClass
func EnsureBlock ¶ added in v0.6.0
func FormatBlockDevice ¶ added in v0.6.0
func FsInfo ¶ added in v0.7.0
FsInfo linux returns (available bytes, byte capacity, byte usage, total inodes, inodes free, inode usage, error) for the filesystem that path resides upon.
func GeneratePVPatch ¶ added in v0.6.0
func GeneratePVPatch(oldPV, newPV *corev1.PersistentVolume) ([]byte, error)
func GeneratePodPatch ¶ added in v0.6.0
func GetAccessModes ¶ added in v0.6.0
func GetAccessModes(caps []*csilib.VolumeCapability) *[]string
GetAccessModes returns a slice containing all of the access modes defined in the passed in VolumeCapabilities.
func GetAddedAndRemovedItems ¶
func GetClusterID ¶ added in v0.7.0
func GetClusterID(kubeclient kubernetes.Interface) (string, error)
func GetDeviceNameFromCsiPV ¶
func GetDeviceNameFromCsiPV(pv *corev1.PersistentVolume) string
GetDeviceNameFromCsiPV extracts Device Name from open-local csi PV via VolumeAttributes
func GetInlineVolumeInfoFromParam ¶ added in v0.5.0
func GetMediaTypeFromPVC ¶
func GetMediaTypeFromPVC(pvc *corev1.PersistentVolumeClaim, scLister storagelisters.StorageClassLister) (localtype.MediaType, error)
func GetMetrics ¶
func GetMetrics(path string) (*csilib.NodeGetVolumeStatsResponse, error)
GetMetrics get path metric
func GetMountPointFromCsiPV ¶
func GetMountPointFromCsiPV(pv *corev1.PersistentVolume) string
GetMountPointFromCsiPV extracts MountPoint from open-local csi PV via VolumeAttributes
func GetName ¶ added in v0.7.1
func GetName(meta metav1.ObjectMeta) string
func GetNameKey ¶ added in v0.7.1
func GetNodeNameFromCsiPV ¶ added in v0.6.0
func GetNodeNameFromCsiPV(pv *corev1.PersistentVolume) string
func GetPVCRequested ¶
func GetPVCRequested(pvc *corev1.PersistentVolumeClaim) int64
func GetPVFromBoundPVC ¶
func GetPVFromBoundPVC(pvc *corev1.PersistentVolumeClaim) (name string)
func GetPVSize ¶
func GetPVSize(pv *corev1.PersistentVolume) int64
func GetPVStorageSize ¶
func GetPVStorageSize(pv *corev1.PersistentVolume) int64
func GetStorageClassFromPV ¶
func GetStorageClassFromPV(pv *corev1.PersistentVolume, p storagev1informers.Interface) *storagev1.StorageClass
func GetStorageClassFromPVC ¶
func GetStorageClassFromPVC(pvc *corev1.PersistentVolumeClaim, scLister storagelisters.StorageClassLister) (*storagev1.StorageClass, error)
func GetVGNameFromCsiPV ¶
func GetVGNameFromCsiPV(pv *corev1.PersistentVolume) string
GetVGNameFromCsiPV extracts vgName from open-local csi PV via VolumeAttributes
func GetVGNameFromPVC ¶
func GetVGNameFromPVC(pvc *corev1.PersistentVolumeClaim, scLister storagelisters.StorageClassLister) (string, error)
func GetVGRequested ¶
func GetVGRequested(localPVs map[string]corev1.PersistentVolume, vgName string) (requested int64)
func GetVolumeSnapshotContent ¶ added in v0.7.0
func GetVolumeSnapshotContent(snapclient snapshot.Interface, snapshotContentID string) (*snapshotapi.VolumeSnapshotContent, error)
func HashSpec ¶
func HashSpec(storage *nodelocalstorage.NodeLocalStorage) uint64
func HashStorageSpec ¶
func HashStorageSpec(obj interface{}) uint64
func HashWithoutState ¶
func HashWithoutState(storage *nodelocalstorage.NodeLocalStorage) uint64
HashWithoutState remove the state field then compare
func HttpJSON ¶
func HttpJSON(w http.ResponseWriter, code int, result interface{})
func HttpResponse ¶
func HttpResponse(w http.ResponseWriter, code int, msg []byte)
func IsBlockDevice ¶ added in v0.6.0
IsBlockDevice checks if the given path is a block device
func IsLocalPVC ¶
func IsLocalPVC(claim *corev1.PersistentVolumeClaim, scLister storagelisters.StorageClassLister) (bool, localtype.VolumeType)
func IsOpenLocalPV ¶ added in v0.2.2
func IsOpenLocalPV(pv *corev1.PersistentVolume) (bool, localtype.VolumeType)
func IsPodNeedAllocate ¶ added in v0.6.0
func IsReadOnlyPV ¶ added in v0.7.0
func IsReadOnlyPV(pv *corev1.PersistentVolume) bool
func IsReadOnlySnapshotPVC ¶ added in v0.7.0
func IsReadOnlySnapshotPVC(claim *corev1.PersistentVolumeClaim, snapInformer volumesnapshotinformers.Interface) bool
func IsReadOnlySnapshotPVC2 ¶ added in v0.7.0
func IsReadOnlySnapshotPVC2(claim *corev1.PersistentVolumeClaim, snapClient snapshot.Interface) bool
func IsSnapshotClassReadOnly ¶ added in v0.7.0
func IsSnapshotClassReadOnly(className string, snapInformer volumesnapshotinformers.Interface) bool
func IsSnapshotClassReadOnly2 ¶ added in v0.7.0
func LocalPVType ¶ added in v0.2.2
func LocalPVType(sc *storagev1.StorageClass) localtype.VolumeType
func MountBlock ¶ added in v0.6.0
func NeedSkip ¶ added in v0.3.0
func NeedSkip(args schedulerapi.ExtenderArgs) bool
func NodeNameFromPV ¶ added in v0.6.0
func NodeNameFromPV(pv *corev1.PersistentVolume) string
func NodeNameFromPVC ¶ added in v0.6.0
func NodeNameFromPVC(pvc *corev1.PersistentVolumeClaim) string
func PVCNameFromPV ¶ added in v0.6.0
func PVCNameFromPV(pv *corev1.PersistentVolume) (pvcName, pvcNamespace string)
func ParseWeight ¶ added in v0.6.0
func ParseWeight(nodeAntiAffinity string) (weights *pkg.NodeAntiAffinityWeight, err error)
func PatchAllocateInfoToPV ¶ added in v0.6.0
func PatchAllocateInfoToPV(ctx context.Context, kubeclientset kubernetes.Interface, originPV *corev1.PersistentVolume, pvAllocatedInfo *localtype.PVAllocatedInfo) error
func PodPvcAllowReschedule ¶
func PodPvcAllowReschedule(pvcs []*corev1.PersistentVolumeClaim, fakeNow *time.Time) bool
PodPvcAllowReschedule returns true if any of pvcs has in pending status for more than 5 minutes the fakeNow is parameter for unit testing
func PvcContainsSelectedNode ¶
func PvcContainsSelectedNode(pvc *corev1.PersistentVolumeClaim) bool
func SetupCgroupPathFormatter ¶ added in v0.6.0
func SetupCgroupPathFormatter(driver CgroupDriverType)
func SliceEquals ¶
func SliceEquals(src interface{}, dst interface{}) bool
func StringsContains ¶
StringsContains check val exist in array
func WordSepNormalizeFunc ¶
func WordSepNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName
WordSepNormalizeFunc changes all flags that contain "_" separators
Types ¶
type CgroupDriverType ¶ added in v0.6.0
type CgroupDriverType string
func (CgroupDriverType) Validate ¶ added in v0.6.0
func (c CgroupDriverType) Validate() bool
type CommandRunFunc ¶
CommandRunFunc define the run function in utils for ut
type TestInlineVolumeInfo ¶ added in v0.6.0
type TestNodeInfo ¶ added in v0.6.0
type TestPVCInfo ¶ added in v0.6.0
type TestPVCPVInfo ¶ added in v0.6.0
type TestPVCPVInfo struct { PVCPending *TestPVCInfo PVCBounding *TestPVCInfo PVBounding *TestPVInfo }
func GetTestPVCPVDevice ¶ added in v0.6.0
func GetTestPVCPVDevice() *TestPVCPVInfo
func GetTestPVCPVNotLocal ¶ added in v0.6.0
func GetTestPVCPVNotLocal() *TestPVCPVInfo
func GetTestPVCPVSnapshot ¶ added in v0.6.0
func GetTestPVCPVSnapshot() *TestPVCPVInfo
func GetTestPVCPVWithVG ¶ added in v0.6.0
func GetTestPVCPVWithVG() *TestPVCPVInfo
func GetTestPVCPVWithoutVG ¶ added in v0.6.0
func GetTestPVCPVWithoutVG() *TestPVCPVInfo
func (*TestPVCPVInfo) SetSize ¶ added in v0.6.0
func (info *TestPVCPVInfo) SetSize(size string)
type TestPVCPVInfoList ¶ added in v0.6.0
type TestPVCPVInfoList []*TestPVCPVInfo
func (TestPVCPVInfoList) GetTestPVBounding ¶ added in v0.6.0
func (list TestPVCPVInfoList) GetTestPVBounding() []TestPVInfo
func (TestPVCPVInfoList) GetTestPVCBounding ¶ added in v0.6.0
func (list TestPVCPVInfoList) GetTestPVCBounding() []TestPVCInfo
func (TestPVCPVInfoList) GetTestPVCPending ¶ added in v0.6.0
func (list TestPVCPVInfoList) GetTestPVCPending() []TestPVCInfo
type TestPVInfo ¶ added in v0.6.0
type TestPodInfo ¶ added in v0.6.0
type TestPodInfo struct { PodName string PodNameSpace string NodeName string PodStatus corev1.PodPhase PVCInfos []*TestPVCInfo InlineVolumeInfos []*TestInlineVolumeInfo }