mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-12-26 05:19:05 +01:00
Always return on metricstore error.
This commit is contained in:
parent
ec581e3509
commit
5a4671b7b1
@ -38,7 +38,6 @@ var metricDataRepos map[string]MetricDataRepository = map[string]MetricDataRepos
|
|||||||
var useArchive bool
|
var useArchive bool
|
||||||
|
|
||||||
func Init(disableArchive bool) error {
|
func Init(disableArchive bool) error {
|
||||||
|
|
||||||
useArchive = !disableArchive
|
useArchive = !disableArchive
|
||||||
for _, cluster := range config.Keys.Clusters {
|
for _, cluster := range config.Keys.Clusters {
|
||||||
if cluster.MetricDataRepository != nil {
|
if cluster.MetricDataRepository != nil {
|
||||||
@ -80,7 +79,8 @@ var cache *lrucache.Cache = lrucache.New(128 * 1024 * 1024)
|
|||||||
func LoadData(job *schema.Job,
|
func LoadData(job *schema.Job,
|
||||||
metrics []string,
|
metrics []string,
|
||||||
scopes []schema.MetricScope,
|
scopes []schema.MetricScope,
|
||||||
ctx context.Context) (schema.JobData, error) {
|
ctx context.Context,
|
||||||
|
) (schema.JobData, error) {
|
||||||
data := cache.Get(cacheKey(job, metrics, scopes), func() (_ interface{}, ttl time.Duration, size int) {
|
data := cache.Get(cacheKey(job, metrics, scopes), func() (_ interface{}, ttl time.Duration, size int) {
|
||||||
var jd schema.JobData
|
var jd schema.JobData
|
||||||
var err error
|
var err error
|
||||||
@ -109,7 +109,8 @@ func LoadData(job *schema.Job,
|
|||||||
jd, err = repo.LoadData(job, metrics, scopes, ctx)
|
jd, err = repo.LoadData(job, metrics, scopes, ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if len(jd) != 0 {
|
if len(jd) != 0 {
|
||||||
log.Warnf("partial error: %s", err.Error())
|
log.Errorf("partial error: %s", err.Error())
|
||||||
|
return err, 0, 0
|
||||||
} else {
|
} else {
|
||||||
log.Error("Error while loading job data from metric repository")
|
log.Error("Error while loading job data from metric repository")
|
||||||
return err, 0, 0
|
return err, 0, 0
|
||||||
@ -179,8 +180,8 @@ func LoadAverages(
|
|||||||
job *schema.Job,
|
job *schema.Job,
|
||||||
metrics []string,
|
metrics []string,
|
||||||
data [][]schema.Float,
|
data [][]schema.Float,
|
||||||
ctx context.Context) error {
|
ctx context.Context,
|
||||||
|
) error {
|
||||||
if job.State != schema.JobStateRunning && useArchive {
|
if job.State != schema.JobStateRunning && useArchive {
|
||||||
return archive.LoadAveragesFromArchive(job, metrics, data) // #166 change also here?
|
return archive.LoadAveragesFromArchive(job, metrics, data) // #166 change also here?
|
||||||
}
|
}
|
||||||
@ -219,8 +220,8 @@ func LoadNodeData(
|
|||||||
metrics, nodes []string,
|
metrics, nodes []string,
|
||||||
scopes []schema.MetricScope,
|
scopes []schema.MetricScope,
|
||||||
from, to time.Time,
|
from, to time.Time,
|
||||||
ctx context.Context) (map[string]map[string][]*schema.JobMetric, error) {
|
ctx context.Context,
|
||||||
|
) (map[string]map[string][]*schema.JobMetric, error) {
|
||||||
repo, ok := metricDataRepos[cluster]
|
repo, ok := metricDataRepos[cluster]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("METRICDATA/METRICDATA > no metric data repository configured for '%s'", cluster)
|
return nil, fmt.Errorf("METRICDATA/METRICDATA > no metric data repository configured for '%s'", cluster)
|
||||||
@ -252,8 +253,8 @@ func LoadNodeData(
|
|||||||
func cacheKey(
|
func cacheKey(
|
||||||
job *schema.Job,
|
job *schema.Job,
|
||||||
metrics []string,
|
metrics []string,
|
||||||
scopes []schema.MetricScope) string {
|
scopes []schema.MetricScope,
|
||||||
|
) string {
|
||||||
// Duration and StartTime do not need to be in the cache key as StartTime is less unique than
|
// Duration and StartTime do not need to be in the cache key as StartTime is less unique than
|
||||||
// job.ID and the TTL of the cache entry makes sure it does not stay there forever.
|
// job.ID and the TTL of the cache entry makes sure it does not stay there forever.
|
||||||
return fmt.Sprintf("%d(%s):[%v],[%v]",
|
return fmt.Sprintf("%d(%s):[%v],[%v]",
|
||||||
@ -267,8 +268,8 @@ func cacheKey(
|
|||||||
func prepareJobData(
|
func prepareJobData(
|
||||||
job *schema.Job,
|
job *schema.Job,
|
||||||
jobData schema.JobData,
|
jobData schema.JobData,
|
||||||
scopes []schema.MetricScope) {
|
scopes []schema.MetricScope,
|
||||||
|
) {
|
||||||
const maxSeriesSize int = 15
|
const maxSeriesSize int = 15
|
||||||
for _, scopes := range jobData {
|
for _, scopes := range jobData {
|
||||||
for _, jm := range scopes {
|
for _, jm := range scopes {
|
||||||
@ -295,7 +296,6 @@ func prepareJobData(
|
|||||||
|
|
||||||
// Writes a running job to the job-archive
|
// Writes a running job to the job-archive
|
||||||
func ArchiveJob(job *schema.Job, ctx context.Context) (*schema.JobMeta, error) {
|
func ArchiveJob(job *schema.Job, ctx context.Context) (*schema.JobMeta, error) {
|
||||||
|
|
||||||
allMetrics := make([]string, 0)
|
allMetrics := make([]string, 0)
|
||||||
metricConfigs := archive.GetCluster(job.Cluster).MetricConfig
|
metricConfigs := archive.GetCluster(job.Cluster).MetricConfig
|
||||||
for _, mc := range metricConfigs {
|
for _, mc := range metricConfigs {
|
||||||
|
Loading…
Reference in New Issue
Block a user