projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix a few staticcheck warnings.
[arvados.git]
/
lib
/
costanalyzer
/
costanalyzer.go
diff --git
a/lib/costanalyzer/costanalyzer.go
b/lib/costanalyzer/costanalyzer.go
index d81ade607c6ebc1b1426220077b60c9fa3cad77d..e8dd186050fb200ca575a480ff6d15db1d88adf0 100644
(file)
--- a/
lib/costanalyzer/costanalyzer.go
+++ b/
lib/costanalyzer/costanalyzer.go
@@
-120,7
+120,7
@@
Options:
if len(uuids) < 1 {
flags.Usage()
if len(uuids) < 1 {
flags.Usage()
- err = fmt.Errorf("
E
rror: no uuid(s) provided")
+ err = fmt.Errorf("
e
rror: no uuid(s) provided")
exitCode = 2
return
}
exitCode = 2
return
}
@@
-285,7
+285,7
@@
func loadObject(logger *logrus.Logger, ac *arvados.Client, path string, uuid str
func getNode(arv *arvadosclient.ArvadosClient, ac *arvados.Client, kc *keepclient.KeepClient, cr arvados.ContainerRequest) (node nodeInfo, err error) {
if cr.LogUUID == "" {
func getNode(arv *arvadosclient.ArvadosClient, ac *arvados.Client, kc *keepclient.KeepClient, cr arvados.ContainerRequest) (node nodeInfo, err error) {
if cr.LogUUID == "" {
- err = errors.New("
N
o log collection")
+ err = errors.New("
n
o log collection")
return
}
return
}
@@
-399,7
+399,7
@@
func generateCrCsv(logger *logrus.Logger, uuid string, arv *arvadosclient.Arvado
return nil, fmt.Errorf("error loading cr object %s: %s", uuid, err)
}
var container arvados.Container
return nil, fmt.Errorf("error loading cr object %s: %s", uuid, err)
}
var container arvados.Container
- err = loadObject(logger, ac,
uuid
, cr.ContainerUUID, cache, &container)
+ err = loadObject(logger, ac,
crUUID
, cr.ContainerUUID, cache, &container)
if err != nil {
return nil, fmt.Errorf("error loading container object %s: %s", cr.ContainerUUID, err)
}
if err != nil {
return nil, fmt.Errorf("error loading container object %s: %s", cr.ContainerUUID, err)
}
@@
-428,7
+428,7
@@
func generateCrCsv(logger *logrus.Logger, uuid string, arv *arvadosclient.Arvado
if err != nil {
return nil, fmt.Errorf("error querying container_requests: %s", err.Error())
}
if err != nil {
return nil, fmt.Errorf("error querying container_requests: %s", err.Error())
}
- logger.Infof("Collecting child containers for container request %s",
uuid
)
+ logger.Infof("Collecting child containers for container request %s",
crUUID
)
for _, cr2 := range childCrs.Items {
logger.Info(".")
node, err := getNode(arv, ac, kc, cr2)
for _, cr2 := range childCrs.Items {
logger.Info(".")
node, err := getNode(arv, ac, kc, cr2)
@@
-437,7
+437,7
@@
func generateCrCsv(logger *logrus.Logger, uuid string, arv *arvadosclient.Arvado
}
logger.Debug("\nChild container: " + cr2.ContainerUUID + "\n")
var c2 arvados.Container
}
logger.Debug("\nChild container: " + cr2.ContainerUUID + "\n")
var c2 arvados.Container
- err = loadObject(logger, ac,
uuid
, cr2.ContainerUUID, cache, &c2)
+ err = loadObject(logger, ac,
cr.UUID
, cr2.ContainerUUID, cache, &c2)
if err != nil {
return nil, fmt.Errorf("error loading object %s: %s", cr2.ContainerUUID, err)
}
if err != nil {
return nil, fmt.Errorf("error loading object %s: %s", cr2.ContainerUUID, err)
}
@@
-452,7
+452,7
@@
func generateCrCsv(logger *logrus.Logger, uuid string, arv *arvadosclient.Arvado
if resultsDir != "" {
// Write the resulting CSV file
if resultsDir != "" {
// Write the resulting CSV file
- fName := resultsDir + "/" +
uuid
+ ".csv"
+ fName := resultsDir + "/" +
crUUID
+ ".csv"
err = ioutil.WriteFile(fName, []byte(csv), 0644)
if err != nil {
return nil, fmt.Errorf("error writing file with path %s: %s", fName, err.Error())
err = ioutil.WriteFile(fName, []byte(csv), 0644)
if err != nil {
return nil, fmt.Errorf("error writing file with path %s: %s", fName, err.Error())
@@
-509,7
+509,7
@@
func costanalyzer(prog string, args []string, loader *config.Loader, logger *log
var crCsv map[string]float64
crCsv, err = generateCrCsv(logger, uuid, arv, ac, kc, resultsDir, cache)
if err != nil {
var crCsv map[string]float64
crCsv, err = generateCrCsv(logger, uuid, arv, ac, kc, resultsDir, cache)
if err != nil {
- err = fmt.Errorf("
E
rror generating CSV for uuid %s: %s", uuid, err.Error())
+ err = fmt.Errorf("
e
rror generating CSV for uuid %s: %s", uuid, err.Error())
exitcode = 2
return
}
exitcode = 2
return
}
@@
-521,9
+521,9
@@
func costanalyzer(prog string, args []string, loader *config.Loader, logger *log
// It is identified by the user uuid. As such, cost analysis for the
// "Home" project is not supported by this program. Skip this uuid, but
// keep going.
// It is identified by the user uuid. As such, cost analysis for the
// "Home" project is not supported by this program. Skip this uuid, but
// keep going.
- logger.Errorf("
C
ost analysis is not supported for the 'Home' project: %s", uuid)
+ logger.Errorf("
c
ost analysis is not supported for the 'Home' project: %s", uuid)
} else {
} else {
- logger.Errorf("
T
his argument does not look like a uuid: %s\n", uuid)
+ logger.Errorf("
t
his argument does not look like a uuid: %s\n", uuid)
exitcode = 3
return
}
exitcode = 3
return
}
@@
-554,7
+554,7
@@
func costanalyzer(prog string, args []string, loader *config.Loader, logger *log
aFile := resultsDir + "/" + time.Now().Format("2006-01-02-15-04-05") + "-aggregate-costaccounting.csv"
err = ioutil.WriteFile(aFile, []byte(csv), 0644)
if err != nil {
aFile := resultsDir + "/" + time.Now().Format("2006-01-02-15-04-05") + "-aggregate-costaccounting.csv"
err = ioutil.WriteFile(aFile, []byte(csv), 0644)
if err != nil {
- err = fmt.Errorf("
E
rror writing file with path %s: %s", aFile, err.Error())
+ err = fmt.Errorf("
e
rror writing file with path %s: %s", aFile, err.Error())
exitcode = 1
return
}
exitcode = 1
return
}