Skip to content

refactor(retracer): split callback into smaller functions#25

Draft
Copilot wants to merge 5 commits into
mainfrom
copilot/split-callback-function
Draft

refactor(retracer): split callback into smaller functions#25
Copilot wants to merge 5 commits into
mainfrom
copilot/split-callback-function

Conversation

Copilot AI commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

The callback method in src/retracer.py had grown to ~720 lines, mixing core decompression, gdb validation, retraceability checks, and the apport-retrace invocation in a single function.

Extracts five self-contained helpers from callback, each in its own commit, with no behavior change (control flow, metrics, logging, and error handling preserved):

  • build_report — builds an apport Report from the Cassandra columns.
  • decompress_core — decompresses the core dump to disk; returns success.
  • gdb_core_check — validates the core dump via gdb; returns whether it's a usable core.
  • check_retraceable — determines release/architecture retraceability and validity.
  • run_apport_retrace — sets up the sandbox/cache and runs apport-retrace, returning (proc, out, err, day_key, retracing_start_time).

callback now reads as a sequence of guarded steps, e.g.:

if not self.decompress_core(report_path, core_file):
    self.remove(oops_id)
    self.update_time_to_retrace(msg)
    metrics.meter("retrace.failure.decompression")
    ...
    return

callback shrinks from ~727 to ~619 lines.

Notes for reviewers

  • run_apport_retrace keeps the original sandbox/cache finally cleanup and re-raises setup failures, so the caller's propagation is unchanged.
  • The unit/functional suite requires Cassandra, RabbitMQ, and Swift and was not run in this environment; existing tests don't exercise callback.

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