Skip to content

Commit

Permalink
Move LLVS to EE
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksandr Stefurishin <[email protected]>
  • Loading branch information
astef committed Dec 19, 2024
1 parent a89ae24 commit eaa249f
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 35 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
.settings
.idea/
venv/
.vscode

# macOS Finder files
*.DS_Store
Expand Down
10 changes: 10 additions & 0 deletions api/v1alpha1/lvm_logical_volume_snapshot.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build ee

/*
Copyright 2024 Flant JSC
Expand All @@ -21,6 +23,14 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func init() {
knownTypes = append(
knownTypes,
&LVMLogicalVolumeSnapshot{},
&LVMLogicalVolumeSnapshotList{},
)
}

// +k8s:deepcopy-gen=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type LVMLogicalVolumeSnapshotList struct {
Expand Down
24 changes: 12 additions & 12 deletions api/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@ var (
AddToScheme = SchemeBuilder.AddToScheme
)

var knownTypes = []runtime.Object{
&BlockDevice{},
&BlockDeviceList{},
&LVMVolumeGroup{},
&LVMVolumeGroupList{},
&LVMLogicalVolume{},
&LVMLogicalVolumeList{},
&LVMVolumeGroupSet{},
&LVMVolumeGroupSetList{},
}

// Adds the list of known types to Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&BlockDevice{},
&BlockDeviceList{},
&LVMVolumeGroup{},
&LVMVolumeGroupList{},
&LVMLogicalVolume{},
&LVMLogicalVolumeList{},
&LVMLogicalVolumeSnapshot{},
&LVMLogicalVolumeSnapshotList{},
&LVMVolumeGroupSet{},
&LVMVolumeGroupSetList{},
)
scheme.AddKnownTypes(SchemeGroupVersion, knownTypes...)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions images/agent/src/cmd/llvs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//go:build !ee

package main

import (
"agent/internal/cache"
"agent/internal/config"
"agent/internal/logger"
"agent/internal/monitoring"

"sigs.k8s.io/controller-runtime/pkg/manager"
)

func addLLVSReconciler(
_ manager.Manager,
_ logger.Logger,
_ monitoring.Metrics,
_ *cache.Cache,
_ *config.Config,
) {
// noop
}
44 changes: 44 additions & 0 deletions images/agent/src/cmd/llvs_ee.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//go:build ee

package main

import (
"agent/internal/cache"
"agent/internal/config"
"agent/internal/controller"
"agent/internal/controller/llvs"
"agent/internal/logger"
"agent/internal/monitoring"
"os"

"sigs.k8s.io/controller-runtime/pkg/manager"
)

func addLLVSReconciler(
mgr manager.Manager,
log logger.Logger,
metrics monitoring.Metrics,
sdsCache *cache.Cache,
cfgParams *config.Config,
) {
err := controller.AddReconciler(
mgr,
log,
llvs.NewReconciler(
mgr.GetClient(),
log,
metrics,
sdsCache,
llvs.ReconcilerConfig{
NodeName: cfgParams.NodeName,
LLVRequeueInterval: cfgParams.LLVRequeueInterval,
VolumeGroupScanInterval: cfgParams.VolumeGroupScanInterval,
LLVSRequeueInterval: cfgParams.LLVSRequeueInterval,
},
),
)
if err != nil {
log.Error(err, "[main] unable to start llvs.NewReconciler")
os.Exit(1)
}
}
22 changes: 1 addition & 21 deletions images/agent/src/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
"agent/internal/controller/bd"
"agent/internal/controller/llv"
"agent/internal/controller/llv_extender"
"agent/internal/controller/llvs"
"agent/internal/controller/lvg"
"agent/internal/kubutils"
"agent/internal/logger"
Expand Down Expand Up @@ -234,26 +233,7 @@ func main() {
os.Exit(1)
}

err = controller.AddReconciler(
mgr,
log,
llvs.NewReconciler(
mgr.GetClient(),
log,
metrics,
sdsCache,
llvs.ReconcilerConfig{
NodeName: cfgParams.NodeName,
LLVRequeueInterval: cfgParams.LLVRequeueInterval,
VolumeGroupScanInterval: cfgParams.VolumeGroupScanInterval,
LLVSRequeueInterval: cfgParams.LLVSRequeueInterval,
},
),
)
if err != nil {
log.Error(err, "[main] unable to start llvs.NewReconciler")
os.Exit(1)
}
addLLVSReconciler(mgr, log, metrics, sdsCache, cfgParams)

if err = mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
log.Error(err, "[main] unable to mgr.AddHealthzCheck")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build ee

package llvs

import (
Expand Down

0 comments on commit eaa249f

Please sign in to comment.