Skip to content

Commit

Permalink
[controller] Add thin pool reserved space to the cache
Browse files Browse the repository at this point in the history
Signed-off-by: Viktor Kramarenko <viktor.kramarenko@flant.com>
  • Loading branch information
ViktorKram committed Jul 2, 2024
1 parent 7e8a4a2 commit 9b78b49
Show file tree
Hide file tree
Showing 10 changed files with 173 additions and 227 deletions.
52 changes: 32 additions & 20 deletions images/sds-local-volume-controller/api/v1alpha1/lvm_volume_group.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
/*
Copyright 2024 Flant JSC
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.
Expand Down Expand Up @@ -33,16 +36,24 @@ type LvmVolumeGroup struct {
Status LvmVolumeGroupStatus `json:"status,omitempty"`
}

type SpecThinPool struct {
Name string `json:"name"`
Size resource.Quantity `json:"size"`
type LvmVolumeGroupSpec struct {
ActualVGNameOnTheNode string `json:"actualVGNameOnTheNode"`
BlockDeviceNames []string `json:"blockDeviceNames"`
ThinPools []LvmVolumeGroupThinPoolSpec `json:"thinPools"`
Type string `json:"type"`
}

type LvmVolumeGroupSpec struct {
ActualVGNameOnTheNode string `json:"actualVGNameOnTheNode"`
BlockDeviceNames []string `json:"blockDeviceNames"`
ThinPools []SpecThinPool `json:"thinPools"`
Type string `json:"type"`
type LvmVolumeGroupStatus struct {
AllocatedSize resource.Quantity `json:"allocatedSize"`
Nodes []LvmVolumeGroupNode `json:"nodes"`
ThinPools []LvmVolumeGroupThinPoolStatus `json:"thinPools"`
VGSize resource.Quantity `json:"vgSize"`
VGUuid string `json:"vgUUID"`
Phase string `json:"phase"`
Conditions []metav1.Condition `json:"conditions"`
ThinPoolReady string `json:"thinPoolReady"`
ConfigurationApplied string `json:"configurationApplied"`
VGFree resource.Quantity `json:"vgFree"`
}

type LvmVolumeGroupDevice struct {
Expand All @@ -58,18 +69,19 @@ type LvmVolumeGroupNode struct {
Name string `json:"name"`
}

type StatusThinPool struct {
Name string `json:"name"`
ActualSize resource.Quantity `json:"actualSize"`
UsedSize resource.Quantity `json:"usedSize"`
type LvmVolumeGroupThinPoolStatus struct {
Name string `json:"name"`
ActualSize resource.Quantity `json:"actualSize"`
UsedSize resource.Quantity `json:"usedSize"`
AllocatedSize resource.Quantity `json:"allocatedSize"`
AvailableSpace resource.Quantity `json:"availableSpace"`
AllocationLimit string `json:"allocationLimit"`
Ready bool `json:"ready"`
Message string `json:"message"`
}

type LvmVolumeGroupStatus struct {
AllocatedSize resource.Quantity `json:"allocatedSize"`
Health string `json:"health"`
Message string `json:"message"`
Nodes []LvmVolumeGroupNode `json:"nodes"`
ThinPools []StatusThinPool `json:"thinPools"`
VGSize resource.Quantity `json:"vgSize"`
VGUuid string `json:"vgUUID"`
type LvmVolumeGroupThinPoolSpec struct {
Name string `json:"name"`
Size resource.Quantity `json:"size"`
AllocationLimit string `json:"allocationLimit"`
}
49 changes: 29 additions & 20 deletions images/sds-local-volume-csi/api/v1alpha1/lvm_volume_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,24 @@ type LvmVolumeGroup struct {
Status LvmVolumeGroupStatus `json:"status,omitempty"`
}

type SpecThinPool struct {
Name string `json:"name"`
Size resource.Quantity `json:"size"`
type LvmVolumeGroupSpec struct {
ActualVGNameOnTheNode string `json:"actualVGNameOnTheNode"`
BlockDeviceNames []string `json:"blockDeviceNames"`
ThinPools []LvmVolumeGroupThinPoolSpec `json:"thinPools"`
Type string `json:"type"`
}

type LvmVolumeGroupSpec struct {
ActualVGNameOnTheNode string `json:"actualVGNameOnTheNode"`
BlockDeviceNames []string `json:"blockDeviceNames"`
ThinPools []SpecThinPool `json:"thinPools"`
Type string `json:"type"`
type LvmVolumeGroupStatus struct {
AllocatedSize resource.Quantity `json:"allocatedSize"`
Nodes []LvmVolumeGroupNode `json:"nodes"`
ThinPools []LvmVolumeGroupThinPoolStatus `json:"thinPools"`
VGSize resource.Quantity `json:"vgSize"`
VGUuid string `json:"vgUUID"`
Phase string `json:"phase"`
Conditions []metav1.Condition `json:"conditions"`
ThinPoolReady string `json:"thinPoolReady"`
ConfigurationApplied string `json:"configurationApplied"`
VGFree resource.Quantity `json:"vgFree"`
}

type LvmVolumeGroupDevice struct {
Expand All @@ -61,18 +69,19 @@ type LvmVolumeGroupNode struct {
Name string `json:"name"`
}

type StatusThinPool struct {
Name string `json:"name"`
ActualSize resource.Quantity `json:"actualSize"`
UsedSize resource.Quantity `json:"usedSize"`
type LvmVolumeGroupThinPoolStatus struct {
Name string `json:"name"`
ActualSize resource.Quantity `json:"actualSize"`
UsedSize resource.Quantity `json:"usedSize"`
AllocatedSize resource.Quantity `json:"allocatedSize"`
AvailableSpace resource.Quantity `json:"availableSpace"`
AllocationLimit string `json:"allocationLimit"`
Ready bool `json:"ready"`
Message string `json:"message"`
}

type LvmVolumeGroupStatus struct {
AllocatedSize resource.Quantity `json:"allocatedSize"`
Health string `json:"health"`
Message string `json:"message"`
Nodes []LvmVolumeGroupNode `json:"nodes"`
ThinPools []StatusThinPool `json:"thinPools"`
VGSize resource.Quantity `json:"vgSize"`
VGUuid string `json:"vgUUID"`
type LvmVolumeGroupThinPoolSpec struct {
Name string `json:"name"`
Size resource.Quantity `json:"size"`
AllocationLimit string `json:"allocationLimit"`
}
2 changes: 1 addition & 1 deletion images/sds-local-volume-csi/pkg/utils/func.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func GetLVMVolumeGroupFreeSpace(lvg v1alpha1.LvmVolumeGroup) (vgFreeSpace resour
}

func GetLVMThinPoolFreeSpace(lvg v1alpha1.LvmVolumeGroup, thinPoolName string) (thinPoolFreeSpace resource.Quantity, err error) {
var storagePoolThinPool *v1alpha1.StatusThinPool
var storagePoolThinPool *v1alpha1.LvmVolumeGroupThinPoolStatus
for _, thinPool := range lvg.Status.ThinPools {
if thinPool.Name == thinPoolName {
storagePoolThinPool = &thinPool
Expand Down
Loading

0 comments on commit 9b78b49

Please sign in to comment.