Files
buzz/deploy/charts/buzz-push-gateway/tests/migration-annotations.sh
Tom Brow fd885b5530 feat(push): support migration pod annotations (#8105)
Allow operators to configure migration Pod annotations independently of
runtime Pod annotations. This lets clusters with automatic sidecar
injection opt the migration Job out without changing the gateway
Deployment or Helm hook metadata.

The new string-map setting defaults to empty. Chart version 0.3.3 is
prepared here; publication requires a separate approved chart release
PR.

### Validation

The full chart render suite and focused migration annotation tests pass.
Tests verify unchanged default resources and hooks, independent runtime
annotations, and rejection of non-string annotation values. Independent
agent review found no blockers. Repository-wide `just ci` exited 1 in
unchanged `buzz-acp` tests: idle/stdout keepalive timing and steering
assertions (one failure in the first group, four in the second).
Subsequent recipes were not reached. No rerun or unrelated code fix was
attempted. Human testing remains pending.

Signed-off-by: Tom Brow <tomb@block.xyz>
2026-10-05 11:39:20 -07:00

28 lines
1.4 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
chart=deploy/charts/buzz-push-gateway
out=$(mktemp -d)
trap 'rm -rf "$out"' EXIT
helm template push "$chart" >"$out/default.yaml"
helm template push "$chart" \
--set-string 'migration.podAnnotations.sidecar\.istio\.io/inject=false' \
--set-string 'podAnnotations.example\.com/runtime=enabled' >"$out/annotated.yaml"
env -u GEM_HOME -u GEM_PATH -u RUBYLIB -u RUBYOPT ruby -ryaml - "$out" <<'RUBY'
base, changed = %w[default annotated].map { |name| YAML.load_stream(File.read("#{ARGV[0]}/#{name}.yaml")).compact }
job = changed.find { |r| r['kind'] == 'Job' }
raise 'migration annotation missing or not a string' unless job.dig('spec', 'template', 'metadata').delete('annotations') == {'sidecar.istio.io/inject' => 'false'}
runtime = changed.find { |r| r['kind'] == 'Deployment' }
raise 'runtime annotations changed' unless runtime.dig('spec', 'template', 'metadata').delete('annotations') == {'example.com/runtime' => 'enabled'}
raise 'annotations changed other resources or hook metadata' unless base == changed
RUBY
for value in true 7; do
if helm template push "$chart" --set "migration.podAnnotations.invalid=$value" >"$out/invalid.log" 2>&1; then
echo 'expected non-string migration annotation to fail schema validation' >&2
exit 1
fi
if ! grep -Eq 'Expected: string|want string' "$out/invalid.log"; then
cat "$out/invalid.log" >&2
exit 1
fi
done