Skip to content

Raise exception when inject_tlm fails#3156

Merged
jmthomas merged 3 commits intomainfrom
fix-inject-tlm-error-handling
Apr 10, 2026
Merged

Raise exception when inject_tlm fails#3156
jmthomas merged 3 commits intomainfrom
fix-inject-tlm-error-handling

Conversation

@jmthomas
Copy link
Copy Markdown
Member

@jmthomas jmthomas commented Apr 2, 2026

closes #2960

@jmthomas jmthomas requested review from clayandgen and ryanmelt April 2, 2026 14:35
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 2, 2026

Codecov Report

❌ Patch coverage is 85.36585% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.38%. Comparing base (399b00b) to head (ab94ab2).
⚠️ Report is 40 commits behind head on main.

Files with missing lines Patch % Lines
...lib/openc3/microservices/interface_microservice.rb 33.33% 2 Missing ⚠️
openc3/lib/openc3/topics/decom_interface_topic.rb 85.71% 2 Missing ⚠️
openc3/lib/openc3/topics/interface_topic.rb 85.71% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3156      +/-   ##
==========================================
+ Coverage   78.36%   78.38%   +0.01%     
==========================================
  Files         674      674              
  Lines       55376    55458      +82     
  Branches      728      728              
==========================================
+ Hits        43398    43470      +72     
- Misses      11900    11910      +10     
  Partials       78       78              
Flag Coverage Δ
python 79.61% <ø> (+<0.01%) ⬆️
ruby-api 83.40% <ø> (+0.18%) ⬆️
ruby-backend 81.53% <85.36%> (+0.01%) ⬆️

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

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jmthomas
Copy link
Copy Markdown
Member Author

jmthomas commented Apr 2, 2026

As part of this investigation I noticed that some things we wait for acks and some we do not:

InterfaceTopic methods WITH ack-wait:

  • write_raw (line 51)
  • inject_tlm (line 114)
  • interface_details (line 160)

InterfaceTopic methods WITHOUT ack-wait (fire-and-forget):

  • connect_interface (line 74)
  • disconnect_interface (line 82)
  • start_raw_logging / stop_raw_logging (lines 86, 90)
  • interface_cmd (line 98)
  • protocol_cmd (line 105)
  • shutdown (line 94)
  • interface_target_enable / interface_target_disable (lines 142, 151)

DecomInterfaceTopic - ALL methods wait for acks:

  • build_cmd, inject_tlm, get_tlm_buffer

The methods that wait are where you need to know the outcome either to return data or propagate errors. The others are commands where we can infer the outcome through other telemetry (status models, etc).

We could extract a helper method into Topic like so:

  def self.write_and_wait_for_ack(cmd_topic, ack_topic, data, timeout:)
    Topic.update_topic_offsets([ack_topic])
    cmd_id = Topic.write_topic(cmd_topic, data, '*', 100)
    time = Time.now
    while (Time.now - time) < timeout
      Topic.read_topics([ack_topic]) do |_topic, _msg_id, msg_hash, _redis|
        if msg_hash["id"] == cmd_id
          yield msg_hash
          return msg_hash
        end
      end
    end
    raise "Timeout of #{timeout}s waiting for cmd ack"
  end

that could be used by InterfaceTopic and DecomInterfaceTopic but the bigger change would be to add acks to all the other methods above. Thoughts?

@ryanmelt
Copy link
Copy Markdown
Member

ryanmelt commented Apr 2, 2026

Everything should be "optionally" acked, (but on by default).
That ensures the methods work at the API level.

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
2 New issues

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@jmthomas jmthomas merged commit 1d19657 into main Apr 10, 2026
35 of 37 checks passed
@jmthomas jmthomas deleted the fix-inject-tlm-error-handling branch April 10, 2026 21:11
@ryanmelt
Copy link
Copy Markdown
Member

Please write another ticket to capture waits for other methods.

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.

inject_tlm() should raise an error if it fails

3 participants