Skip to content

chore: revive patch-overlay sync for OTel + Telegraf submodules - #371

Merged
zzylol merged 2 commits into
mainfrom
chore/revive-patch-overlay-scripts
May 10, 2026
Merged

zzylol merged 2 commits into
mainfrom
chore/revive-patch-overlay-scripts

Conversation

@zzylol

@zzylol zzylol commented May 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Revives the 8 restore_*.sh patch-overlay scripts retired in cleanup: drop dead processors, cmd dirs, backup scripts, v0 aliases #363 — fresh-clone builds of asap-otel were silently broken because patched sketch processors import go.opentelemetry.io/collector/processor/selfmonitor (not in upstream v0.141.0) and the existing replace directives point at the submodule, not at the patch tree.
  • Revives the 8 backup_*.sh reverse-sync scripts so submodule-side debug edits can be folded back into the canonical patch tree.
  • Patch trees stay the source-of-truth in main; submodules stay clean (no upstream pushes). restore_* copies *-patch/ → submodule working tree at build time; backup_* does the reverse.
  • Wires Step 1 (Apply patches to submodules) back into build_asap_otel.sh and build_asap_telegraf.sh; --skip-patches is real again instead of a no-op.

Restore scripts

Script Files staged Source → Dest
restore_otel_collector_patches.sh 85 opentelemetry-collector-patch/opentelemetry-collector/
restore_otel_collector_contrib_patches.sh 201 opentelemetry-collector-contrib-patch/opentelemetry-collector-contrib/
restore_otel_proto_patches.sh 15 opentelemetry-proto-patch/opentelemetry-proto/
restore_opentelemetry_go_patches.sh 80 opentelemetry-go-patch/opentelemetry-go/
restore_otel_client_patches.sh (alias) restore_opentelemetry_go_patches.sh
restore_telegraf_patches.sh 7 telegraf-patch/telegraf/ (skips go.mod/go.sum)
restore_otel_patches.sh wrapper collector + contrib + proto + opentelemetry-go
restore_all.sh wrapper otel + telegraf

Backup scripts (reverse direction)

Each uses git status --porcelain inside the submodule to discover modified/added/renamed paths and copies them into the patch tree. Deletions skipped (patch trees should never delete files relative to upstream).

Script Direction
backup_otel_collector_patches.sh opentelemetry-collector/…-patch/
backup_otel_collector_contrib_patches.sh opentelemetry-collector-contrib/…-patch/
backup_otel_proto_patches.sh opentelemetry-proto/…-patch/
backup_opentelemetry_go_patches.sh opentelemetry-go/…-patch/
backup_otel_client_patches.sh (alias) → backup_opentelemetry_go_patches.sh
backup_telegraf_patches.sh telegraf/telegraf-patch/ (does NOT skip go.mod/go.sum)
backup_otel_patches.sh wrapper
backup_all.sh wrapper

Out of scope

  • OTAP (build_asap_otap.sh) inlines its own overlay (stages a new crate + edits Cargo.toml / main.rs in place). No behavior change there.

Test plan

  • bash -n parses all 16 new scripts + the 2 modified build scripts
  • Each restore script runs idempotently and reports the expected file counts on the current working tree
  • ./build_asap_otel.sh from a fresh clone (i.e. submodule working trees clean) builds asap-otel successfully
  • ./build_asap_telegraf.sh from a fresh clone builds asap-telegraf
  • ./build_asap_otel.sh --skip-patches (after a previous successful build) skips the overlay step

🤖 Generated with Claude Code

zzylol and others added 2 commits May 9, 2026 23:17
PR #363 retired the patch-overlay restore scripts on the assumption
that the patch trees alone were sufficient. They aren't: the patched
sketch processors and selfmonitor live under the upstream submodule
import paths (e.g. `go.opentelemetry.io/collector/processor/selfmonitor`),
and the patched processors' `replace` directives point at
`opentelemetry-collector/processor/...` not at the patch tree. A
fresh clone or a worktree without overlay-staged submodules fails to
build asap-otel because `processor/selfmonitor/` is missing from the
v0.141.0 submodule.

This revives the overlay step. The patch trees (committed in
ASAPCollector main) stay the source of truth; submodules stay clean
(we don't push changes upstream). The restore scripts copy
`*-patch/` → submodule working tree at build time.

Restored:

- restore_otel_collector_patches.sh         (85 files)
- restore_otel_collector_contrib_patches.sh (201 files)
- restore_otel_proto_patches.sh             (15 files)
- restore_opentelemetry_go_patches.sh       (80 files)
- restore_otel_client_patches.sh            (legacy alias → -go)
- restore_telegraf_patches.sh               (7 files; skips go.mod/go.sum)
- restore_otel_patches.sh                   (wrapper: collector+contrib+proto+go)
- restore_all.sh                            (wrapper: otel + telegraf)

Wired into:

- build_asap_otel.sh: Step 1 calls restore_otel_patches.sh; --skip-patches
  is real again.
- build_asap_telegraf.sh: Step 1 calls restore_telegraf_patches.sh;
  --skip-patches is real again.

OTAP (build_asap_otap.sh) inlines its own overlay (stages a new crate
+ edits Cargo.toml/main.rs in place); not factored out, no behavior
change there.

Verification:

- `bash -n` parses all 8 new scripts + the 2 modified build scripts.
- Each restore script runs idempotently and reports the expected file
  counts on the current working tree.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Companion to the restore_*.sh revival. Use these when you've edited
files directly in a submodule (e.g. while debugging at the build
site) and want to fold the changes back into the canonical patch
tree before they're blown away by the next restore.

Restored:

- backup_otel_collector_patches.sh         (submodule → -patch)
- backup_otel_collector_contrib_patches.sh (submodule → -patch)
- backup_otel_proto_patches.sh             (submodule → -patch)
- backup_opentelemetry_go_patches.sh       (submodule → -patch)
- backup_otel_client_patches.sh            (legacy alias → -go)
- backup_telegraf_patches.sh               (submodule → -patch)
- backup_otel_patches.sh                   (wrapper)
- backup_all.sh                            (wrapper)

Each script uses `git status --porcelain` inside the submodule to
discover modified/added/renamed paths and copies only those (plus
their parent dirs) back into the patch tree. Deletions are skipped
on purpose — patch trees should never delete files relative to the
upstream tag.

`backup_telegraf_patches.sh` does NOT exclude go.mod/go.sum (unlike
its restore counterpart) — if you've genuinely modified those in the
submodule, you probably want them captured. The script header notes
the footgun: the patch tree's standalone `processors/allsketches/`
go.mod is separate from telegraf's mono-module go.mod, so don't run
this if you've only added an import inside the submodule's main
go.mod.

Verification:

- `bash -n` parses all 8 scripts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zzylol
zzylol merged commit 33b3ad8 into main May 10, 2026
@zzylol
zzylol deleted the chore/revive-patch-overlay-scripts branch May 10, 2026 03:22
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.

1 participant