linter defeated!

This commit is contained in:
a.pivkin
2025-12-23 19:20:42 +03:00
parent 5ca21e635d
commit 2294202009
6 changed files with 56 additions and 50 deletions
+11 -18
View File
@@ -7,7 +7,7 @@ import (
)
func PoolFactory(cephConn mytypes.CephConnector, poolName string) (mytypes.Pool, error) {
var rbdlist []mytypes.IRBD = []mytypes.IRBD{}
var rbdlist = []mytypes.IRBD{}
ioctx, err := cephConn.OpenIOContext(poolName)
if err != nil {
@@ -16,36 +16,29 @@ func PoolFactory(cephConn mytypes.CephConnector, poolName string) (mytypes.Pool,
defer ioctx.Destroy()
imageList, err := ioctx.GetImageNames()
imageNames, err := ioctx.GetImageNames()
if err != nil {
return mytypes.Pool{}, fmt.Errorf("couldn't get list of rbds %w", err)
}
for _, rbdname := range imageList {
stat, err := RBDFacroty(ioctx, rbdname)
for _, rbdName := range imageNames {
stat, err := RBDFacroty(ioctx, rbdName)
if err != nil {
fmt.Errorf("coundn't get stat from disk %s %w", rbdname, err)
panic(err)
logger.Logger.Errorf("coundn't get stat from disk %s %w", rbdName, err)
}
rbdlist = append(rbdlist, stat)
}
return mytypes.Pool{
Name: poolName,
HasRBD: len(imageList) != 0,
HasRBD: len(imageNames) != 0,
RBDlist: rbdlist,
}, nil
}
func RBDFacroty(ioctx mytypes.IOContexter, rbdname string) (mytypes.RBD, error) {
defer func() {
if v := recover(); v != nil {
logger.Logger.Errorf("no such RBD exists (probably just deleted)")
}
}()
image := ioctx.GetImage(rbdname)
func RBDFacroty(ioctx mytypes.IOContexter, rbdName string) (mytypes.RBD, error) {
image := ioctx.GetImage(rbdName)
err := image.Open()
if err != nil {
panic(err)
logger.Logger.Errorf("Couldn't open RBD %s",rbdName)
// logger.Logger.Errorf("Shit happened in RBDFactory")
}
@@ -54,11 +47,11 @@ func RBDFacroty(ioctx mytypes.IOContexter, rbdname string) (mytypes.RBD, error)
info,err := image.Stat()
if err != nil {
return mytypes.RBD{},fmt.Errorf("couldn't get stats for image %s %w",rbdname,err)
return mytypes.RBD{},fmt.Errorf("couldn't get stats for image %s %w",rbdName,err)
}
return mytypes.RBD{
Name: rbdname,
Name: rbdName,
ImageInfo: *info,
},nil
}