Skip to content

Commit

Permalink
[controller] Add BlockDevice resource selector for LVMVolumeGroups (#90)
Browse files Browse the repository at this point in the history
Signed-off-by: Viktor Kramarenko <viktor.kramarenko@flant.com>
Signed-off-by: v.oleynikov <vasily.oleynikov@flant.com>
Co-authored-by: v.oleynikov <vasily.oleynikov@flant.com>
  • Loading branch information
ViktorKram and duckhawk authored Sep 25, 2024
1 parent 56b1644 commit 249de28
Show file tree
Hide file tree
Showing 43 changed files with 2,188 additions and 917 deletions.
18 changes: 11 additions & 7 deletions .github/workflows/go_modules_check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,34 +37,38 @@ jobs:
echo "Processing $go_mod_file"
while IFS= read -r line; do
if [[ "line" =~ ^replace ]]; then
continue
fi
if [[ "$line" == *github.com/deckhouse/sds-* || "$line" == *github.com/deckhouse/csi-* || "$line" == *github.com/deckhouse/virtualization ]]; then
repository=$(echo "$line" | awk '{print $1}' | awk -F'/' '{ print "https://"$1"/"$2"/"$3".git" }')
pseudo_tag=$(echo "$line" | awk '{print $2}')
echo "Cloning repo $repository into $temp_dir"
git clone "$repository" "$temp_dir/$repository" >/dev/null 2>&1
if [ -d "$temp_dir/$repository/api" ]; then
cd "$temp_dir/$repository" || continue
commit_info=$(git log -1 --pretty=format:"%H %cd" --date=iso-strict -- api/*)
short_hash=$(echo "$commit_info" | awk '{print substr($1,1,12)}')
commit_date=$(echo "$commit_info" | awk '{print $2}')
commit_date=$(date -u -d "$commit_date" +"%Y%m%d%H%M%S")
actual_pseudo_tag="v0.0.0-"$commit_date"-"$short_hash
pseudo_tag_date=$(echo $pseudo_tag | awk -F'-' '{ print $2 }')
echo "Latest commit in $repository: $short_hash $commit_date"
if [[ "$pseudo_tag_date" < "$commit_date" ]]; then
echo "Incorrect pseudo tag for repo $repository in file "$go_mod_file" (current: "$pseudo_tag", actual:"$actual_pseudo_tag")"
echo "Incorrect pseudo tag for repo $repository in file "$go_mod_file" (current: "$pseudo_tag", actual:"$actual_pseudo_tag")" >> $temp_dir"/incorrect_alert"
fi
cd - >/dev/null 2>&1
else
echo "No api directory in $repository"
fi
rm -rf "$temp_dir/$repository"
fi
done < "$go_mod_file"
Expand All @@ -75,4 +79,4 @@ jobs:
if [ $alert_lines_count != 0 ]; then
echo "We have non-actual pseudo-tags in repository's go.mod files"
exit 1
fi
fi
2 changes: 1 addition & 1 deletion .werf/bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
---
image: bundle
from: registry.deckhouse.io/base_images/scratch@sha256:b054705fcc9f2205777d80a558d920c0b4209efdc3163c22b5bfcb5dda1db5fc
fromCacheVersion: 20240821092325
fromCacheVersion: 20240830154106
import:
# Rendering .werf/images-digests.yaml is required!
- image: images-digests
Expand Down
2 changes: 1 addition & 1 deletion .werf/python-deps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
---
image: python-dependencies
from: registry.deckhouse.io/base_images/alpine:3.16.3
fromCacheVersion: 20240821092325
fromCacheVersion: 20240830154106
git:
- add: /
to: /
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/block_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type BlockDeviceStatus struct {
PVUuid string `json:"pvUUID"`
VGUuid string `json:"vgUUID"`
PartUUID string `json:"partUUID"`
LvmVolumeGroupName string `json:"lvmVolumeGroupName"`
LVMVolumeGroupName string `json:"lvmVolumeGroupName"`
ActualVGNameOnTheNode string `json:"actualVGNameOnTheNode"`
Wwn string `json:"wwn"`
Serial string `json:"serial"`
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/lvm_logical_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type LVMLogicalVolumeSpec struct {
ActualLVNameOnTheNode string `json:"actualLVNameOnTheNode"`
Type string `json:"type"`
Size string `json:"size"`
LvmVolumeGroupName string `json:"lvmVolumeGroupName"`
LVMVolumeGroupName string `json:"lvmVolumeGroupName"`
Thin *LVMLogicalVolumeThinSpec `json:"thin"`
Thick *LVMLogicalVolumeThickSpec `json:"thick"`
}
Expand Down
37 changes: 21 additions & 16 deletions api/v1alpha1/lvm_volume_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,33 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type LvmVolumeGroupList struct {
type LVMVolumeGroupList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`

Items []LvmVolumeGroup `json:"items"`
Items []LVMVolumeGroup `json:"items"`
}

type LvmVolumeGroup struct {
type LVMVolumeGroup struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec LvmVolumeGroupSpec `json:"spec"`
Status LvmVolumeGroupStatus `json:"status,omitempty"`
Spec LVMVolumeGroupSpec `json:"spec"`
Status LVMVolumeGroupStatus `json:"status,omitempty"`
}

type LvmVolumeGroupSpec struct {
type LVMVolumeGroupSpec struct {
ActualVGNameOnTheNode string `json:"actualVGNameOnTheNode"`
BlockDeviceNames []string `json:"blockDeviceNames"`
ThinPools []LvmVolumeGroupThinPoolSpec `json:"thinPools"`
BlockDeviceSelector *metav1.LabelSelector `json:"blockDeviceSelector"`
ThinPools []LVMVolumeGroupThinPoolSpec `json:"thinPools"`
Type string `json:"type"`
Local LVMVolumeGroupLocalSpec `json:"local"`
}

type LvmVolumeGroupStatus struct {
type LVMVolumeGroupStatus struct {
AllocatedSize resource.Quantity `json:"allocatedSize"`
Nodes []LvmVolumeGroupNode `json:"nodes"`
ThinPools []LvmVolumeGroupThinPoolStatus `json:"thinPools"`
Nodes []LVMVolumeGroupNode `json:"nodes"`
ThinPools []LVMVolumeGroupThinPoolStatus `json:"thinPools"`
VGSize resource.Quantity `json:"vgSize"`
VGUuid string `json:"vgUUID"`
Phase string `json:"phase"`
Expand All @@ -56,20 +57,20 @@ type LvmVolumeGroupStatus struct {
VGFree resource.Quantity `json:"vgFree"`
}

type LvmVolumeGroupDevice struct {
type LVMVolumeGroupDevice struct {
BlockDevice string `json:"blockDevice"`
DevSize resource.Quantity `json:"devSize"`
PVSize resource.Quantity `json:"pvSize"`
PVUuid string `json:"pvUUID"`
Path string `json:"path"`
}

type LvmVolumeGroupNode struct {
Devices []LvmVolumeGroupDevice `json:"devices"`
type LVMVolumeGroupNode struct {
Devices []LVMVolumeGroupDevice `json:"devices"`
Name string `json:"name"`
}

type LvmVolumeGroupThinPoolStatus struct {
type LVMVolumeGroupThinPoolStatus struct {
Name string `json:"name"`
ActualSize resource.Quantity `json:"actualSize"`
UsedSize resource.Quantity `json:"usedSize"`
Expand All @@ -80,8 +81,12 @@ type LvmVolumeGroupThinPoolStatus struct {
Message string `json:"message"`
}

type LvmVolumeGroupThinPoolSpec struct {
type LVMVolumeGroupThinPoolSpec struct {
Name string `json:"name"`
Size string `json:"size"`
AllocationLimit string `json:"allocationLimit"`
}

type LVMVolumeGroupLocalSpec struct {
NodeName string `json:"nodeName"`
}
4 changes: 2 additions & 2 deletions api/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&BlockDevice{},
&BlockDeviceList{},
&LvmVolumeGroup{},
&LvmVolumeGroupList{},
&LVMVolumeGroup{},
&LVMVolumeGroupList{},
&LVMLogicalVolume{},
&LVMLogicalVolumeList{},
)
Expand Down
18 changes: 9 additions & 9 deletions api/v1alpha1/zz_generated.deepcopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,56 +76,56 @@ func (in *BlockDeviceList) DeepCopyObject() runtime.Object {
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *LvmVolumeGroup) DeepCopyInto(out *LvmVolumeGroup) {
func (in *LVMVolumeGroup) DeepCopyInto(out *LVMVolumeGroup) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EmptyBlockDevice.
func (in *LvmVolumeGroup) DeepCopy() *LvmVolumeGroup {
func (in *LVMVolumeGroup) DeepCopy() *LVMVolumeGroup {
if in == nil {
return nil
}
out := new(LvmVolumeGroup)
out := new(LVMVolumeGroup)
in.DeepCopyInto(out)
return out
}

// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *LvmVolumeGroup) DeepCopyObject() runtime.Object {
func (in *LVMVolumeGroup) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *LvmVolumeGroupList) DeepCopyInto(out *LvmVolumeGroupList) {
func (in *LVMVolumeGroupList) DeepCopyInto(out *LVMVolumeGroupList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]LvmVolumeGroup, len(*in))
*out = make([]LVMVolumeGroup, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GuestbookList.
func (in *LvmVolumeGroupList) DeepCopy() *LvmVolumeGroupList {
func (in *LVMVolumeGroupList) DeepCopy() *LVMVolumeGroupList {
if in == nil {
return nil
}
out := new(LvmVolumeGroupList)
out := new(LVMVolumeGroupList)
in.DeepCopyInto(out)
return out
}

// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *LvmVolumeGroupList) DeepCopyObject() runtime.Object {
func (in *LVMVolumeGroupList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
Expand Down
11 changes: 9 additions & 2 deletions crds/doc-ru-lvmvolumegroup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,16 @@ spec:
description: |
Тип Volume Group. Может быть:
- Local, то есть локальным, если используемые девайсы не являются распределенными (не Shared LUN).
blockDeviceNames:
local:
description: |
Список имен ресурсов BlockDevice для создания Volume Group.
Желаемая конфигурация для локальной Volume Group.
properties:
nodeName:
description: |
Имя ноды, на которой планируется размещение Volume Group.
blockDeviceSelector:
description: |
Желаемый селектор для выбора BlockDevice ресурсов.
> Обратите внимание, что выбранные блок-девайсы должны принадлежать одному узлу для Volume Group с типом 'Local'.
actualVGNameOnTheNode:
Expand Down
7 changes: 7 additions & 0 deletions crds/doc-ru-lvmvolumegroupbackup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
spec:
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: |
Ресурс, сохраняющий состояние lvmvolumegroups ресурсов для совершения миграции kind с LvmVolumeGroup до LVMVolumeGroup.
69 changes: 59 additions & 10 deletions crds/lvmvolumegroup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spec:
group: storage.deckhouse.io
scope: Cluster
names:
kind: LvmVolumeGroup
kind: LVMVolumeGroup
plural: lvmvolumegroups
singular: lvmvolumegroup
shortNames:
Expand All @@ -33,32 +33,81 @@ spec:
properties:
spec:
type: object
x-kubernetes-validations:
- rule: |
(self.type == "Local" && has(self.local)) || self.type != "Local"
message: "The 'local' field is required when the 'type' field is 'Local'."
required:
- type
- blockDeviceNames
- blockDeviceSelector
- actualVGNameOnTheNode
properties:
type:
type: string
description: |
The type of a Volume Group. Might be:
The type of a VolumeGroup. Might be:
- Local, that is, local if the devices used are not distributed (not Shared LUN).
enum:
- Local
blockDeviceNames:
type: array
x-kubernetes-validations:
- rule: self == oldSelf
message: "The type field is immutable."
local:
type: object
description: |
An array of block device resource names to create a Volume Group.
> Note that the selected block devices must belong to the same node for a Local Volume Group.
items:
type: string
The desired configuration for a local Volume Group.
required:
- nodeName
properties:
nodeName:
type: string
description: |
The desired node for the LVM Volume Group.
> This field is immutable.
x-kubernetes-validations:
- rule: self == oldSelf
message: "The nodeName field is immutable."
blockDeviceSelector:
type: object
description: |
The desired block device selector.
properties:
matchLabels:
type: object
description: |
The desired block device selector labels.
additionalProperties:
type: string
matchExpressions:
type: array
description: |
The desired block device selector expressions.
items:
type: object
properties:
key:
type: string
operator:
type: string
enum:
- In
- NotIn
- Exists
- DoesNotExist
values:
type: array
items:
type: string
actualVGNameOnTheNode:
type: string
description: |
The desired name of a Volume Group. Must be unique for the node it is on.
> This field is immutable.
x-kubernetes-validations:
- rule: self == oldSelf
message: "The actualVGNameOnTheNode field is immutable."
thinPools:
type: array
description: |
Expand Down
Loading

0 comments on commit 249de28

Please sign in to comment.