Skip to content

Guard build_agent.yaml updates on Agent branch existence#23987

Open
Kyle-Neale wants to merge 5 commits into
masterfrom
kn-build-agent-yaml-guard
Open

Guard build_agent.yaml updates on Agent branch existence#23987
Kyle-Neale wants to merge 5 commits into
masterfrom
kn-build-agent-yaml-guard

Conversation

@Kyle-Neale

@Kyle-Neale Kyle-Neale commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

  • Gate both writers of .gitlab/build_agent.yaml (ddev release branch create and the update-build-agent-yaml.yml workflow) on the matching DataDog/datadog-agent branch existing. The workflow now hard-fails; the CLI warns and leaves branch: main so ddev release branch tag can recover later.
  • Consolidate the YAML parsing/update helpers into a new ddev/src/ddev/cli/release/branch/build_agent.py shared by create.py and tag.py.
  • In bump_milestone(), force-restore .gitlab/build_agent.yaml from origin/master after checking out the bump branch, so a prior release-branch edit cannot leak into the milestone-bump commit.

Motivation

When 7.81.x was cut, .gitlab/build_agent.yaml ended up pointing at a DataDog/datadog-agent branch that did not yet exist, and the change leaked into the milestone-bump PR #23977 (later reverted). The existence check was missing from both writers and the working-tree state from the release-branch edit was reused for the bump commit.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add qa/required if this PR needs QA validation, or qa/skip-qa if it does not. Exactly one of the two is required.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

Extract YAML helpers into a shared build_agent.py module so the inline
update in `ddev release branch create` and the recovery path through
the workflow share parsing logic. Gate both writers on the matching
DataDog/datadog-agent branch existing:

- `ensure_build_agent_yaml_updated` skips the rewrite (with a warning)
  when the upstream branch is missing, leaving `main` in place for the
  tag-time recovery path to handle later.
- The `update-build-agent-yaml.yml` workflow now hard-fails instead of
  warning when the upstream branch is missing, so a fire-and-forget
  dispatch from `ddev release branch tag` is visible in Actions.
- `bump_milestone` defensively restores build_agent.yaml from
  origin/master after checking out the milestone-bump branch so the
  release-branch edit cannot leak into the bump commit
  (see PR #23977 commit f71a89c).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Kyle-Neale Kyle-Neale added the qa/skip-qa Automatically skip this PR for the next QA label Jun 9, 2026
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Pipelines  Tests  Code Coverage

Fix all issues with BitsAI

⚠️ Warnings

🚦 5 Pipeline jobs failed

PR All | test / j89811be / Appgate SDP   View in Datadog   GitHub Actions

PR All | test / j89ec795 / Confluent Platform   View in Datadog   GitHub Actions

PR All | test / jc346754 / Dell Powerflex   View in Datadog   GitHub Actions

View all 5 failed jobs.

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 87.84%
Overall Coverage: 87.86% (+0.17%)

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: ff3dc15 | Docs | Datadog PR Page | Give us feedback!

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens the release-branch .gitlab/build_agent.yaml update flow so neither the ddev CLI nor the GitHub workflow can point release branches at a non-existent upstream DataDog/datadog-agent branch, while also preventing the YAML edit from leaking into milestone-bump commits.

Changes:

  • Extracts build-agent YAML parsing/updating helpers into a new shared build_agent.py module and updates imports accordingly.
  • Adds an upstream branch existence precondition to the ddev-side writer (warn + no-op when missing) and restores the workflow-side writer to hard-fail when missing.
  • Adds a defensive git checkout origin/master -- .gitlab/build_agent.yaml during milestone bump branch creation to prevent leakage into the bump commit.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
ddev/src/ddev/cli/release/branch/build_agent.py New shared module for parsing/updating build-agent YAML and checking upstream agent branch existence.
ddev/src/ddev/cli/release/branch/create.py Switches to shared helpers; adds defensive restore of build_agent.yaml during milestone bump.
ddev/src/ddev/cli/release/branch/tag.py Stops importing build-agent YAML helpers from create.py; imports from build_agent.py instead.
ddev/tests/cli/release/branch/test_create.py Extends tests to cover missing-upstream-branch behavior and the milestone-bump defensive restore.
.github/workflows/update-build-agent-yaml.yml Restores upstream branch existence check as a hard failure (error + exit 1).
ddev/changelog.d/23987.fixed Changelog entry documenting the fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ddev/src/ddev/cli/release/branch/build_agent.py
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@Kyle-Neale Kyle-Neale marked this pull request as ready for review June 10, 2026 19:11
@Kyle-Neale Kyle-Neale requested a review from a team as a code owner June 10, 2026 19:11
Kyle-Neale and others added 2 commits June 10, 2026 15:31
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
No external caller imports the two YAML-helper names from create.py;
they live in build_agent.py and tag.py imports them from there
directly. With those imports gone, __all__ has no purpose either.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dd-octo-sts

dd-octo-sts Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Validation Report

All 21 validations passed.

Show details
Validation Description Status
agent-reqs Verify check versions match the Agent requirements file
ci Validate CI configuration and code coverage settings
codeowners Validate every integration has a CODEOWNERS entry
config Validate default configuration files against spec.yaml
dep Verify dependency pins are consistent and Agent-compatible
http Validate integrations use the HTTP wrapper correctly
imports Validate check imports do not use deprecated modules
integration-style Validate check code style conventions
jmx-metrics Validate JMX metrics definition files and config
labeler Validate PR labeler config matches integration directories
legacy-signature Validate no integration uses the legacy Agent check signature
license-headers Validate Python files have proper license headers
licenses Validate third-party license attribution list
metadata Validate metadata.csv metric definitions
models Validate configuration data models match spec.yaml
openmetrics Validate OpenMetrics integrations disable the metric limit
package Validate Python package metadata and naming
qa-label Validate the pull request declares whether it needs QA for the next Agent release
readmes Validate README files have required sections
saved-views Validate saved view JSON file structure and fields
version Validate version consistency between package and changelog

View full run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants