Skip to content

Promtimer fails if logs have no persistent blocks #34

@jameseh96

Description

@jameseh96

A node which has not been up for long may not have any persistent blocks.

That is, stats_snapshot may just have head chunks and the WAL:

$ tree ./stats_snapshot/
./stats_snapshot/
├── chunks_head
│   └── 000001
├── queries.active
└── wal
    └── 00000000

In this case, Promtimer fails with:

  File ".../promtimer/promtimer.py", line 308, in <module>
    main()
  File ".../promtimer/promtimer.py", line 259, in main
    times = cbstats.CBCollect.compute_min_and_max_times(stats_sources)
  File ".../promtimer/promtimer/cbstats.py", line 345, in compute_min_and_max_times
    times = [s.get_min_and_max_times() for s in sources]
  File ".../promtimer/promtimer/cbstats.py", line 345, in <listcomp>
    times = [s.get_min_and_max_times() for s in sources]
  File ".../promtimer/promtimer/cbstats.py", line 175, in get_min_and_max_times
    return get_prometheus_times(self._cbcollect_dir)
  File ".../promtimer/promtimer/cbstats.py", line 570, in get_prometheus_times
    return min(min_times), max(max_times)
ValueError: min() arg is an empty sequence

Corresponding to:

def get_prometheus_times(cbcollect_dir):
    min_times = []
    max_times = []
    meta_files = glob.glob(path.join(cbcollect_dir, 'stats_snapshot', '*', 'meta.json'))
    for meta_file in meta_files:
        with open(meta_file, 'r') as file:
            meta = json.loads(file.read())
            min_times.append(meta['minTime'] / 1000.0)
            max_times.append(meta['maxTime'] / 1000.0)
    return min(min_times), max(max_times)

No persistent block dirs like 01F5WQSJ4705B6SRTQE4CCB0DZ (containing meta.json) are present, so the glob does not match anything.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions