Skip to content

Conversation

ryanmelt
Copy link
Member

No description provided.

@ryanmelt ryanmelt requested a review from jmthomas September 28, 2023 17:20
@codecov
Copy link

codecov bot commented Sep 28, 2023

Codecov Report

Attention: 22 lines in your changes are missing coverage. Please review.

Comparison is base (2289402) 72.27% compared to head (0b98385) 72.28%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #849      +/-   ##
==========================================
+ Coverage   72.27%   72.28%   +0.01%     
==========================================
  Files         471      471              
  Lines       31069    31137      +68     
  Branches      877      877              
==========================================
+ Hits        22454    22507      +53     
- Misses       8522     8535      +13     
- Partials       93       95       +2     
Flag Coverage Δ
frontend 60.65% <ø> (+0.04%) ⬆️
ruby-api 48.66% <ø> (ø)
ruby-backend 80.32% <78.64%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
openc3/lib/openc3/api/metrics_api.rb 66.66% <100.00%> (+3.95%) ⬆️
openc3/lib/openc3/logs/log_writer.rb 90.34% <100.00%> (ø)
openc3/lib/openc3/logs/packet_log_writer.rb 93.88% <100.00%> (+0.10%) ⬆️
openc3/lib/openc3/models/target_model.rb 72.75% <ø> (ø)
openc3/lib/openc3/utilities/bucket_file_cache.rb 22.50% <0.00%> (-1.19%) ⬇️
...3/lib/openc3/microservices/reducer_microservice.rb 85.49% <82.66%> (-0.82%) ⬇️

... and 6 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -291,7 +291,7 @@ def prepare_write(time_nsec_since_epoch, data_length, redis_topic = nil, redis_o
elsif @cycle_size and ((@file_size + data_length) > @cycle_size)
Logger.debug("Log writer start new file due to cycle size #{@cycle_size}")
start_new_file() if allow_new_file
elsif @enforce_time_order and @previous_time_nsec_since_epoch and (@previous_time_nsec_since_epoch > time_nsec_since_epoch)
elsif process_out_of_order and @enforce_time_order and @previous_time_nsec_since_epoch and (@previous_time_nsec_since_epoch > time_nsec_since_epoch)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

process_out_of_order and @enforce_time_order ... which is it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Different purposes. @enforce_time_order is do we care about time order at all, process_out_of_order is do we care about time order for this entry (we don't care for the non-packet entry types).

if entry_type == :RAW_PACKET or entry_type == :JSON_PACKET
process_out_of_order = true
else
process_out_of_order = false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

entry_type can be :TARGET_DECLARATION, :PACKET_DECLARATION, :RAW_PACKET, :JSON_PACKET, :OFFSET_MARKER, :KEY_MAP. Can you add a comment about why we process :RAW_PACKET, :JSON_PACKET out of order but not with the rest.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do

@@ -106,14 +107,28 @@ def initialize(name)
end
end

@buffer_depth = 10 unless @buffer_depth
@buffer_depth = 60 unless @buffer_depth
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This matches the default in log_microservice, good change.

end
processed # return to yield
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the only way this stays false is if nothing is returned from all_files?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. It only updates the metric if work was done. Not if it just realized there was nothing to do. Removes the more common super small time metrics.

end
end

def process_file(filename, type, entry_nanoseconds, file_nanoseconds)
throttle = OpenC3::Throttle.new(@max_cpu_utilization)
file = BucketFile.new(filename)
file.retrieve
unless file.local_path
@logger.warn("Reducer Warning: #{filename}: Could not be retrieved")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously we just warned and then carried on? That makes no sense.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah - Not correct before

raise "Local file does not exist after get_object: #{client_result.inspect}"
end
rescue => err
# Try to retrieve the file three times
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think this will address real world issues? We're asking for a file with get_object and for some reason it fails so retry and it works?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could happen. That wasn't what was causing the reducer issues, but I thought it was worth adding some retries which should improve resiliency.

I think the root cause of the EOFErrors was Rufus scheduler running two instances of process_file at the same time. The new mutex added to ReducerMicroservice prevents that.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@ryanmelt ryanmelt merged commit 566b618 into main Sep 28, 2023
@ryanmelt ryanmelt deleted the reducer_improvements branch September 28, 2023 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants