mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-12-26 05:19:05 +01:00
improve transaction init error handling
This commit is contained in:
parent
d4f487d554
commit
8ea1454c06
@ -43,6 +43,9 @@ func RegisterFootprintWorker() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
// NOTE: Additional Subcluster Loop Could Allow For Limited List Of (Energy)Footprint-Metrics Only.
|
||||||
|
// - Chunk-Size Would Then Be 'SubCluster' (Running Jobs, Transactions) as Lists Can Change Within SCs
|
||||||
|
// - Would Require Review of 'updateFootprint' And 'updateEnergy' Usage
|
||||||
allMetrics := make([]string, 0)
|
allMetrics := make([]string, 0)
|
||||||
metricConfigs := archive.GetCluster(cluster.Name).MetricConfig
|
metricConfigs := archive.GetCluster(cluster.Name).MetricConfig
|
||||||
for _, mc := range metricConfigs {
|
for _, mc := range metricConfigs {
|
||||||
@ -78,7 +81,7 @@ func RegisterFootprintWorker() {
|
|||||||
|
|
||||||
for _, metric := range allMetrics {
|
for _, metric := range allMetrics {
|
||||||
avg, min, max := 0.0, 0.0, 0.0
|
avg, min, max := 0.0, 0.0, 0.0
|
||||||
data, ok := jobStats[metric] // Metric:[Hostname:Stats]
|
data, ok := jobStats[metric] // JobStats[Metric1:[Hostname1:[Stats], Hostname2:[Stats], ...], Metric2[...] ...]
|
||||||
if ok {
|
if ok {
|
||||||
for _, res := range job.Resources {
|
for _, res := range job.Resources {
|
||||||
hostStats, ok := data[res.Hostname]
|
hostStats, ok := data[res.Hostname]
|
||||||
@ -87,14 +90,9 @@ func RegisterFootprintWorker() {
|
|||||||
min = math.Min(min, hostStats.Min)
|
min = math.Min(min, hostStats.Min)
|
||||||
max = math.Max(max, hostStats.Max)
|
max = math.Max(max, hostStats.Max)
|
||||||
}
|
}
|
||||||
// else {
|
|
||||||
// log.Debugf("no stats data return for host %s in job %d, metric %s", res.Hostname, job.JobID, metric)
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// else {
|
|
||||||
// log.Debugf("no stats data return for job %d, metric %s", job.JobID, metric)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Add values rounded to 2 digits
|
// Add values rounded to 2 digits
|
||||||
jobMeta.Statistics[metric] = schema.JobStatistics{
|
jobMeta.Statistics[metric] = schema.JobStatistics{
|
||||||
@ -131,23 +129,22 @@ func RegisterFootprintWorker() {
|
|||||||
t, err := jobRepo.TransactionInit()
|
t, err := jobRepo.TransactionInit()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("failed TransactionInit %v", err)
|
log.Errorf("failed TransactionInit %v", err)
|
||||||
}
|
log.Errorf("skipped %d transactions for cluster %s", len(pendingStatements), cluster.Name)
|
||||||
|
ce += len(pendingStatements)
|
||||||
for idx, ps := range pendingStatements {
|
} else {
|
||||||
|
for _, ps := range pendingStatements {
|
||||||
query, args, err := ps.ToSql()
|
query, args, err := ps.ToSql()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("failed in ToSQL conversion: %v", err)
|
log.Errorf("failed in ToSQL conversion: %v", err)
|
||||||
ce++
|
ce++
|
||||||
} else {
|
} else {
|
||||||
// Args: JSON, JSON, ENERGY, JOBID
|
// args...: Footprint-JSON, Energyfootprint-JSON, TotalEnergy, JobID
|
||||||
log.Debugf("add transaction on index %d", idx)
|
jobRepo.TransactionAdd(t, query, args...)
|
||||||
jobRepo.TransactionAdd(t, query, args...)
|
c++
|
||||||
c++
|
}
|
||||||
}
|
}
|
||||||
|
jobRepo.TransactionEnd(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
jobRepo.TransactionEnd(t)
|
|
||||||
log.Debugf("Finish Cluster %s, took %s", cluster.Name, time.Since(s_cluster))
|
log.Debugf("Finish Cluster %s, took %s", cluster.Name, time.Since(s_cluster))
|
||||||
}
|
}
|
||||||
log.Printf("Updating %d (of %d; Skipped %d) Footprints is done and took %s", c, cl, ce, time.Since(s))
|
log.Printf("Updating %d (of %d; Skipped %d) Footprints is done and took %s", c, cl, ce, time.Since(s))
|
||||||
|
Loading…
Reference in New Issue
Block a user