Skip to content

Commit

Permalink
[csi] Add select node logic
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandr Ohrimenko <alexandr.ohrimenko@flant.com>
  • Loading branch information
dxavx authored and AleksZimin committed Feb 27, 2024
1 parent dcda873 commit d42518b
Show file tree
Hide file tree
Showing 10 changed files with 459 additions and 174 deletions.
54 changes: 54 additions & 0 deletions images/sds-lvm-csi/api/v1alpha1/lvm_logical_volume.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
Copyright 2023 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.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

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

Items []LvmLogicalVolume `json:"items"`
}

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

Spec LvmLogicalVolumeSpec `json:"spec"`
Status *LvmLogicalVolumeStatus `json:"status,omitempty"`
}

type LvmLogicalVolumeSpec struct {
Type string `json:"type"`
Size resource.Quantity `json:"size"`
LvmVolumeGroup string `json:"lvmVolumeGroup"`
Thin *ThinLogicalVolumeSpec `json:"thin,omitempty"`
}

type ThinLogicalVolumeSpec struct {
PoolName string `json:"poolName"`
}

type LvmLogicalVolumeStatus struct {
Phase string `json:"phase"`
Reason string `json:"reason"`
ActualSize resource.Quantity `json:"actualSize"`
}
11 changes: 7 additions & 4 deletions images/sds-lvm-csi/api/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ import (
)

const (
LVMVolumeGroupKind = "LvmVolumeGroup"
APIGroup = "storage.deckhouse.io"
APIVersion = "v1alpha1"
TypeMediaAPIVersion = APIGroup + "/" + APIVersion
LVMVolumeGroupKind = "LvmVolumeGroup"
LVMLogicalVolumeKind = "LvmLogicalVolume"
APIGroup = "storage.deckhouse.io"
APIVersion = "v1alpha1"
TypeMediaAPIVersion = APIGroup + "/" + APIVersion
)

// SchemeGroupVersion is group version used to register these objects
Expand All @@ -44,6 +45,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&LvmVolumeGroup{},
&LvmVolumeGroupList{},
&LvmLogicalVolume{},
&LvmLogicalVolumeList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
Expand Down
60 changes: 60 additions & 0 deletions images/sds-lvm-csi/api/v1alpha1/zz_generated.deepcopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,63 @@ func (in *LvmVolumeGroupList) DeepCopyObject() runtime.Object {
}
return nil
}

// -------------- LvmLogicalVolume ----------

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *LvmLogicalVolume) DeepCopyInto(out *LvmLogicalVolume) {
*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 *LvmLogicalVolume) DeepCopy() *LvmLogicalVolume {
if in == nil {
return nil
}
out := new(LvmLogicalVolume)
in.DeepCopyInto(out)
return out
}

// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *LvmLogicalVolume) 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 *LvmLogicalVolumeList) DeepCopyInto(out *LvmLogicalVolumeList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]LvmLogicalVolume, 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 *LvmLogicalVolumeList) DeepCopy() *LvmLogicalVolumeList {
if in == nil {
return nil
}
out := new(LvmLogicalVolumeList)
in.DeepCopyInto(out)
return out
}

// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *LvmLogicalVolumeList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
31 changes: 31 additions & 0 deletions images/sds-lvm-csi/driver/const.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
Copyright 2023 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.
See the License for the specific language governing permissions and
limitations under the License.
*/

package driver

const (
lvmType = "lvm.csi.storage.deckhouse.io/lvm-type"
lvmBindingMode = "lvm.csi.storage.deckhouse.io/volume-binding-mode"
lvmVolumeGroup = "lvm.csi.storage.deckhouse.io/lvm-volume-groups"
topologyKey = "topology.sds-lvm-csi/node"
subPath = "subPath"
VGNameKey = "vgname"
LLVTypeThin = "Thin"
LLVTypeThick = "Thick"
LLVStatusCreated = "Created"
BindingModeWFFC = "WaitForFirstConsumer"
BindingModeI = "Immediate"
)
Loading

0 comments on commit d42518b

Please sign in to comment.