Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[controller] Add BlockDevice resource selector for LVMVolumeGroups #90

Merged
merged 78 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
d516dee
refactored api module
ViktorKram Aug 27, 2024
81dd56e
refactored agent
ViktorKram Aug 27, 2024
b128edf
refactored agent
ViktorKram Aug 28, 2024
75ccced
python hook
ViktorKram Aug 29, 2024
b86c03e
rebased
ViktorKram Aug 29, 2024
f3f3b1e
finish hook
ViktorKram Aug 29, 2024
384c948
finish hook
ViktorKram Aug 30, 2024
4ae97bf
hook fixes
ViktorKram Aug 30, 2024
420b52f
hook fixes
ViktorKram Aug 30, 2024
3e62569
added chmod
ViktorKram Aug 30, 2024
1f0dc0b
add chmod
ViktorKram Aug 30, 2024
7935a72
new hook
ViktorKram Aug 30, 2024
174304d
new hook
ViktorKram Aug 30, 2024
d467da6
hook fix
ViktorKram Aug 30, 2024
0f12900
Fix
duckhawk Aug 30, 2024
eaea803
hook fix
ViktorKram Aug 30, 2024
a665c45
hook fix
ViktorKram Aug 30, 2024
18e86dc
hook fix
ViktorKram Sep 2, 2024
f17aa79
added backups
ViktorKram Sep 2, 2024
669b3a9
test hook
ViktorKram Sep 4, 2024
aa2f069
hook improves
ViktorKram Sep 4, 2024
af8cd29
hook improves
ViktorKram Sep 5, 2024
7d6d02e
hook improves
ViktorKram Sep 5, 2024
892d80b
hook improves
ViktorKram Sep 5, 2024
6a6e611
hook improves
ViktorKram Sep 5, 2024
d38ca9a
hook improves
ViktorKram Sep 5, 2024
2bdb292
hook improves
ViktorKram Sep 5, 2024
4188201
hook improves
ViktorKram Sep 6, 2024
a851a68
hook improves
ViktorKram Sep 6, 2024
fbbf6c6
hook improves
ViktorKram Sep 6, 2024
52d0ebf
hook improves
ViktorKram Sep 6, 2024
639ace7
hook improves
ViktorKram Sep 6, 2024
60412a7
hook improves
ViktorKram Sep 6, 2024
968736a
hook improves
ViktorKram Sep 7, 2024
1b1b81d
hook improves
ViktorKram Sep 7, 2024
9131acf
hook improves
ViktorKram Sep 7, 2024
0addebb
hook improves
ViktorKram Sep 7, 2024
f005372
hook improves
ViktorKram Sep 7, 2024
f1f2fd1
hook improves
ViktorKram Sep 7, 2024
9f2bfcb
hook improves
ViktorKram Sep 7, 2024
ad3a023
hook improves
ViktorKram Sep 9, 2024
747239a
hook improves
ViktorKram Sep 9, 2024
85f400c
hook improves
ViktorKram Sep 9, 2024
dd85e25
hook improves
ViktorKram Sep 9, 2024
a06ac1f
hook improves
ViktorKram Sep 9, 2024
41f3b74
hook improves
ViktorKram Sep 9, 2024
000ef59
hook improves
ViktorKram Sep 9, 2024
3f21e1b
hook improves
ViktorKram Sep 9, 2024
3ea4f27
hook improves
ViktorKram Sep 9, 2024
5f2a7eb
hook improves
ViktorKram Sep 9, 2024
a3bc1c3
new hook version
ViktorKram Sep 9, 2024
7e727df
new hook version
ViktorKram Sep 9, 2024
6ab4a77
new life
ViktorKram Sep 9, 2024
27ca23a
new life
ViktorKram Sep 10, 2024
43289c7
new life
ViktorKram Sep 10, 2024
49b0a5a
new life
ViktorKram Sep 11, 2024
fa3b472
new life
ViktorKram Sep 11, 2024
c981987
new life
ViktorKram Sep 11, 2024
1948cee
new life
ViktorKram Sep 11, 2024
3080603
final refactoring
ViktorKram Sep 12, 2024
63a7f7e
final refactoring
ViktorKram Sep 16, 2024
ebae4c3
refactoring by comments
ViktorKram Sep 17, 2024
0504cfa
refactored agent
ViktorKram Aug 27, 2024
c25cf33
refactored agent
ViktorKram Aug 28, 2024
c3b6f40
python hook
ViktorKram Aug 29, 2024
5f157fc
finish hook
ViktorKram Aug 29, 2024
76a9324
hook fixes
ViktorKram Aug 30, 2024
8f14856
hook fixes
ViktorKram Aug 30, 2024
e6226b0
added chmod
ViktorKram Aug 30, 2024
8b74ac1
add chmod
ViktorKram Aug 30, 2024
0a10c53
new hook
ViktorKram Aug 30, 2024
550376b
Fix condition in Go modules checks
duckhawk Sep 16, 2024
b350727
fixed gci
ViktorKram Sep 17, 2024
70c85bf
fixed DCO
ViktorKram Sep 17, 2024
3821515
final fixes
ViktorKram Sep 17, 2024
ebc2f49
final fixes
ViktorKram Sep 18, 2024
0cb42b4
final fixes
ViktorKram Sep 18, 2024
a035b4a
final fixes
ViktorKram Sep 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading