Skip to content

Commit

Permalink
[controller] Code refactor by linter suggestions (#80)
Browse files Browse the repository at this point in the history
Signed-off-by: Viktor Kramarenko <[email protected]>
  • Loading branch information
ViktorKram committed Sep 17, 2024
1 parent 1836e0c commit 09ec6ef
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 21 deletions.
8 changes: 2 additions & 6 deletions api/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@ import (
)

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

// SchemeGroupVersion is group version used to register these objects
Expand Down
3 changes: 0 additions & 3 deletions api/v1alpha1/zz_generated.deepcopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ func (in *BlockDevice) DeepCopyInto(out *BlockDevice) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)

}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EmptyBlockDevice.
Expand Down Expand Up @@ -81,7 +80,6 @@ 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.
Expand Down Expand Up @@ -139,7 +137,6 @@ 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.
Expand Down
14 changes: 2 additions & 12 deletions images/agent/src/pkg/controller/block_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func RemoveDeprecatedAPIDevices(

for name, device := range apiBlockDevices {
if shouldDeleteBlockDevice(device, actualCandidates, nodeName) {
err := DeleteAPIBlockDevice(ctx, cl, metrics, name)
err := DeleteAPIBlockDevice(ctx, cl, metrics, &device)
if err != nil {
log.Error(err, fmt.Sprintf("[RunBlockDeviceController] unable to delete APIBlockDevice, name: %s", name))
continue
Expand Down Expand Up @@ -564,17 +564,7 @@ func CreateAPIBlockDevice(ctx context.Context, kc kclient.Client, metrics monito
return device, nil
}

func DeleteAPIBlockDevice(ctx context.Context, kc kclient.Client, metrics monitoring.Metrics, deviceName string) error {
device := &v1alpha1.BlockDevice{
ObjectMeta: metav1.ObjectMeta{
Name: deviceName,
},
TypeMeta: metav1.TypeMeta{
Kind: v1alpha1.BlockDeviceKind,
APIVersion: v1alpha1.TypeMediaAPIVersion,
},
}

func DeleteAPIBlockDevice(ctx context.Context, kc kclient.Client, metrics monitoring.Metrics, device *v1alpha1.BlockDevice) error {
start := time.Now()
err := kc.Delete(ctx, device)
metrics.ApiMethodsDuration(BlockDeviceCtrlName, "delete").Observe(metrics.GetEstimatedTimeInSeconds(start))
Expand Down

0 comments on commit 09ec6ef

Please sign in to comment.