Further tweak to how -o loop polling works
The prior 2 changes made the handling of the first set of polled loops inconsistent with subsequent sets with respect to maintaining data across dish reboot. This change makes them both work the same (and correctly).
This commit is contained in:
parent
afab7553e3
commit
9f726e71af
2 changed files with 19 additions and 18 deletions
|
@ -130,8 +130,7 @@ def run_arg_parser(parser, need_id=False, no_stdout_errors=False):
|
||||||
opts.bulk_mode = "bulk_history" in opts.mode
|
opts.bulk_mode = "bulk_history" in opts.mode
|
||||||
|
|
||||||
if opts.samples is None:
|
if opts.samples is None:
|
||||||
opts.samples = int(opts.loop_interval *
|
opts.samples = int(opts.loop_interval) if opts.loop_interval >= 1.0 else SAMPLES_DEFAULT
|
||||||
opts.poll_loops) if opts.loop_interval >= 1.0 else SAMPLES_DEFAULT
|
|
||||||
opts.bulk_samples = -1
|
opts.bulk_samples = -1
|
||||||
else:
|
else:
|
||||||
opts.bulk_samples = opts.samples
|
opts.bulk_samples = opts.samples
|
||||||
|
@ -272,23 +271,25 @@ def get_history_stats(opts, gstate, add_item, add_sequence):
|
||||||
conn_error(opts, "Failure getting history: %s", str(starlink_grpc.GrpcError(e)))
|
conn_error(opts, "Failure getting history: %s", str(starlink_grpc.GrpcError(e)))
|
||||||
history = None
|
history = None
|
||||||
|
|
||||||
|
parse_samples = opts.samples if gstate.counter_stats is None else -1
|
||||||
|
start = gstate.counter_stats if gstate.counter_stats else None
|
||||||
|
|
||||||
# Accumulate polled history data into gstate.accum_history, even if there
|
# Accumulate polled history data into gstate.accum_history, even if there
|
||||||
# was a dish reboot.
|
# was a dish reboot.
|
||||||
if gstate.accum_history:
|
if gstate.accum_history:
|
||||||
if history is not None:
|
if history is not None:
|
||||||
# This gets too complicated to handle across reboots once the data
|
|
||||||
# has been accumulated, so just have concatenate do it on the
|
|
||||||
# first pass and use a value of 0 to remember it was done (as
|
|
||||||
# opposed to None, which is used for a different purpose).
|
|
||||||
if gstate.counter_stats:
|
|
||||||
start = gstate.counter_stats
|
|
||||||
gstate.counter_stats = 0
|
|
||||||
else:
|
|
||||||
start = None
|
|
||||||
gstate.accum_history = starlink_grpc.concatenate_history(gstate.accum_history,
|
gstate.accum_history = starlink_grpc.concatenate_history(gstate.accum_history,
|
||||||
history,
|
history,
|
||||||
start=start,
|
samples1=parse_samples,
|
||||||
|
start1=start,
|
||||||
verbose=opts.verbose)
|
verbose=opts.verbose)
|
||||||
|
# Counter tracking gets too complicated to handle across reboots
|
||||||
|
# once the data has been accumulated, so just have concatenate
|
||||||
|
# handle it on the first polled loop and use a value of 0 to
|
||||||
|
# remember it was done (as opposed to None, which is used for a
|
||||||
|
# different purpose).
|
||||||
|
if not opts.no_counter:
|
||||||
|
gstate.counter_stats = 0
|
||||||
else:
|
else:
|
||||||
gstate.accum_history = history
|
gstate.accum_history = history
|
||||||
|
|
||||||
|
@ -303,8 +304,6 @@ def get_history_stats(opts, gstate, add_item, add_sequence):
|
||||||
|
|
||||||
gstate.poll_count = 0
|
gstate.poll_count = 0
|
||||||
|
|
||||||
start = gstate.counter_stats if gstate.counter_stats else None
|
|
||||||
parse_samples = opts.samples if gstate.counter_stats is None else -1
|
|
||||||
groups = starlink_grpc.history_stats(parse_samples,
|
groups = starlink_grpc.history_stats(parse_samples,
|
||||||
start=start,
|
start=start,
|
||||||
verbose=opts.verbose,
|
verbose=opts.verbose,
|
||||||
|
|
|
@ -846,7 +846,7 @@ def _compute_sample_range(history, parse_samples, start=None, verbose=False):
|
||||||
return sample_range, current - start, current
|
return sample_range, current - start, current
|
||||||
|
|
||||||
|
|
||||||
def concatenate_history(history1, history2, start=None, verbose=False):
|
def concatenate_history(history1, history2, samples1=-1, start1=None, verbose=False):
|
||||||
"""Append the sample-dependent fields of one history object to another.
|
"""Append the sample-dependent fields of one history object to another.
|
||||||
|
|
||||||
Note:
|
Note:
|
||||||
|
@ -860,7 +860,9 @@ def concatenate_history(history1, history2, start=None, verbose=False):
|
||||||
to append.
|
to append.
|
||||||
history2: The grpc history object, such as one returned by a prior
|
history2: The grpc history object, such as one returned by a prior
|
||||||
call to `get_history`, from which to append.
|
call to `get_history`, from which to append.
|
||||||
start (int): Optional starting counter value to be applied to the
|
samples1 (int): Optional number of samples to process, or -1 to parse
|
||||||
|
all available samples (bounded by start1, if it is set).
|
||||||
|
start1 (int): Optional starting counter value to be applied to the
|
||||||
history1 data. See `history_bulk_data` documentation for more
|
history1 data. See `history_bulk_data` documentation for more
|
||||||
details on how this parameter is used.
|
details on how this parameter is used.
|
||||||
verbose (bool): Optionally produce verbose output.
|
verbose (bool): Optionally produce verbose output.
|
||||||
|
@ -889,7 +891,7 @@ def concatenate_history(history1, history2, start=None, verbose=False):
|
||||||
unwrapped.unwrapped = True
|
unwrapped.unwrapped = True
|
||||||
|
|
||||||
sample_range, ignore1, ignore2 = _compute_sample_range( # pylint: disable=unused-variable
|
sample_range, ignore1, ignore2 = _compute_sample_range( # pylint: disable=unused-variable
|
||||||
history1, len(history1.pop_ping_drop_rate), start=start)
|
history1, samples1, start=start1)
|
||||||
for i in sample_range:
|
for i in sample_range:
|
||||||
for field in HISTORY_FIELDS:
|
for field in HISTORY_FIELDS:
|
||||||
getattr(unwrapped, field).append(getattr(history1, field)[i])
|
getattr(unwrapped, field).append(getattr(history1, field)[i])
|
||||||
|
|
Loading…
Reference in a new issue