fixed some errors from linter
This commit is contained in:
parent
20a59dceae
commit
54ce83f458
|
|
@ -34,12 +34,11 @@ func loggerInit() *zap.SugaredLogger {
|
|||
|
||||
// This func runs even before main()
|
||||
func init() {
|
||||
|
||||
config_file := flag.String("config", "/etc/ceph/ceph.conf", "placement of ceph config file")
|
||||
configFile := flag.String("config", "/etc/ceph/ceph.conf", "placement of ceph config file")
|
||||
_keyring := flag.String("keyring", "/etc/ceph/ceph.client.admin.keyring", "placement of ceph keyring file")
|
||||
flag.Parse()
|
||||
|
||||
params.Config = *config_file
|
||||
params.Config = *configFile
|
||||
params.Keyring = *_keyring
|
||||
|
||||
mainlogger = loggerInit()
|
||||
|
|
@ -63,7 +62,7 @@ func main() {
|
|||
|
||||
http.Handle("/metrics", promhttp.Handler())
|
||||
|
||||
// HTTP runs in separate thread cuz it blocks futher execution of main
|
||||
// HTTP runs in separate thread cuz it blocks further execution of main
|
||||
go func() {
|
||||
mainlogger.Info("Starting http server")
|
||||
// Here I check for errors if HTTP fails
|
||||
|
|
@ -77,5 +76,4 @@ func main() {
|
|||
go metrics.GetMetrics(cephConn)
|
||||
|
||||
select {}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
package metrics
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"rbd_exporter/RBDFactory"
|
||||
"rbd_exporter/rbdfactory"
|
||||
"rbd_exporter/mytypes"
|
||||
"rbd_exporter/logger"
|
||||
"time"
|
||||
|
|
@ -11,7 +10,6 @@ import (
|
|||
|
||||
|
||||
func GetMetrics(cephConn mytypes.CephConnector) {
|
||||
|
||||
metrics := InitMetrics()
|
||||
prometheus.MustRegister(
|
||||
metrics.Total_rbd_requested_size_per_pool,
|
||||
|
|
@ -30,7 +28,7 @@ func GetMetrics(cephConn mytypes.CephConnector) {
|
|||
}
|
||||
|
||||
for _, v := range poolList {
|
||||
x, _ := RBDFactory.PoolFactory(cephConn, v)
|
||||
x, _ := rbdfactory.PoolFactory(cephConn, v)
|
||||
result = append(result, x)
|
||||
}
|
||||
|
||||
|
|
@ -39,9 +37,8 @@ func GetMetrics(cephConn mytypes.CephConnector) {
|
|||
if !v.HasRBD {continue}
|
||||
FillMetrics(v,metrics)
|
||||
}
|
||||
fmt.Println("====================")
|
||||
logger.Logger.Debug("====================")
|
||||
// fmt.Println(result)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -79,5 +76,4 @@ func FillMetrics(pool mytypes.Pool,metrics *mytypes.Metrics) {
|
|||
metrics.Total_rbd_requested_size_per_pool.WithLabelValues(pool.Name,
|
||||
).Set(
|
||||
float64(totalSizePerPool))
|
||||
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package RBDFactory
|
||||
package rbdfactory
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
|
@ -18,12 +18,12 @@ func PoolFactory(cephConn mytypes.CephConnector, poolName string) (mytypes.Pool,
|
|||
|
||||
imageList, err := ioctx.GetImageNames()
|
||||
if err != nil {
|
||||
return mytypes.Pool{}, fmt.Errorf("Couldn't get list of rbds %w", err)
|
||||
return mytypes.Pool{}, fmt.Errorf("couldn't get list of rbds %w", err)
|
||||
}
|
||||
for _, rbdname := range imageList {
|
||||
stat, err := RBDFacroty(ioctx, rbdname)
|
||||
if err != nil {
|
||||
fmt.Errorf("Coundn't get stat from disk %s %w", rbdname, err)
|
||||
fmt.Errorf("coundn't get stat from disk %s %w", rbdname, err)
|
||||
panic(err)
|
||||
}
|
||||
rbdlist = append(rbdlist, stat)
|
||||
|
|
@ -38,7 +38,7 @@ func PoolFactory(cephConn mytypes.CephConnector, poolName string) (mytypes.Pool,
|
|||
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)")
|
||||
logger.Logger.Errorf("no such RBD exists (probably just deleted)")
|
||||
}
|
||||
}()
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ 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{
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package tests
|
||||
|
||||
import (
|
||||
"rbd_exporter/RBDFactory"
|
||||
"rbd_exporter/rbdfactory"
|
||||
mock "rbd_exporter/mytypes/mock"
|
||||
"testing"
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ func TestRBDFactory(t *testing.T) {
|
|||
MockRBDImager.EXPECT().Stat().Return(expectedImageInfo,nil)
|
||||
|
||||
|
||||
result,err := RBDFactory.RBDFacroty(MockIOContexter,rbdName)
|
||||
result,err := rbdfactory.RBDFacroty(MockIOContexter,rbdName)
|
||||
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, rbdName, result.Name)
|
||||
|
|
@ -62,7 +62,7 @@ func TestPoolFactory(t *testing.T) {
|
|||
mockImage.EXPECT().Stat().Return(expectedImageInfo, nil)
|
||||
}
|
||||
|
||||
result, err := RBDFactory.PoolFactory(mockCephConn, poolName)
|
||||
result, err := rbdfactory.PoolFactory(mockCephConn, poolName)
|
||||
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, poolName, result.Name)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user