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] Code refactor by linter suggestions #80

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading