Skip to content

Commit e019961

Browse files
[dotnet] Pin the Windows SSI agent to agent.lock (#8641)
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 4ff434e commit e019961

3 files changed

Lines changed: 42 additions & 25 deletions

File tree

‎docs/understand/scenarios/onboarding.md‎

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,31 +1208,12 @@ An agent failure can block CI pipelines, preventing new builds or merges from co
12081208
**Quick Solution:**
12091209

12101210
In this case the quick solution resides on the system-tests repository and it will impact in all the tracers and injector pipelines.
1211-
We will use these environment variables DD_AGENT_MAJOR_VERSION and DD_AGENT_MINOR_VERSION to point to the exact the agent version.
1212-
First, you should check the latest versions of the agent: https://github.com/DataDog/datadog-agent/releases.
1213-
We’ll pin a specific Agent version from three different points within system-tests:
1214-
- https://github.com/DataDog/system-tests/blob/a9ebdef3c3593d231616097d13a02a2ecd4037c2/utils/build/virtual_machine/provisions/auto-inject/auto-inject_installer_manual.yml#L10
1215-
```yaml
1216-
remote-command: |
1217-
#Pin to 7.69.4 agent release
1218-
export DD_AGENT_MAJOR_VERSION=7
1219-
export DD_AGENT_MINOR_VERSION=69.4
1220-
if [ "${DD_env}" == "dev" ]; then
1221-
```
1222-
- https://github.com/DataDog/system-tests/blob/045237acae933f6e96d974c55aef1d319cd5a1e6/utils/build/virtual_machine/provisions/auto-inject/docker/docker-compose-agent-prod.yml#L4
1223-
```yaml
1224-
services:
1225-
datadog:
1226-
container_name: dd-agent
1227-
image: gcr.io/datadoghq/agent:7.69.4
1228-
```
1229-
- https://github.com/DataDog/system-tests/blob/045237acae933f6e96d974c55aef1d319cd5a1e6/utils/build/virtual_machine/provisions/host-auto-inject-install-script/auto-inject_host_script.yml#L8
1230-
```yaml
1231-
remote-command: |
1232-
export DD_AGENT_MAJOR_VERSION=7
1233-
export DD_AGENT_MINOR_VERSION=69.4
1234-
# Env variables set on the scenario definition. Write to file and load
1235-
```
1211+
1212+
AWS SSI scenarios install the Agent version pinned in `utils/build/virtual_machine/agent.lock`, on Linux and on Windows, in prod and in dev, whichever repository runs the pipeline. The provisions read `DD_AGENT_VERSION` from the lock file and set `DD_AGENT_MAJOR_VERSION` and `DD_AGENT_MINOR_VERSION` for the install scripts. Containerized agents use the same version for the `gcr.io/datadoghq/agent` image.
1213+
1214+
The nightly `update_agent_version` job keeps the lock file current: when a newer stable Agent is released, it opens a pull request that bumps the lock and merges automatically once the required checks pass.
1215+
1216+
To pin a different Agent version, check the [Agent releases](https://github.com/DataDog/datadog-agent/releases) and set `DD_AGENT_VERSION` in `utils/build/virtual_machine/agent.lock` to a stable `<major>.<minor>.<patch>` release. On Windows the minor version must be 72 or newer.
12361217

12371218
---
12381219

‎tests/test_the_test/test_update_agent_version.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import urllib.error
77
from pathlib import Path
88

9+
import yaml
10+
911
from utils import pytest
1012

1113
from utils import scenarios
@@ -98,6 +100,19 @@ def test_agent_version_consumers_load_lock() -> None:
98100
assert '. "./${AGENT_LOCK}"' in content
99101

100102

103+
@scenarios.test_the_test
104+
def test_installer_manual_pins_agent_on_every_os() -> None:
105+
root = Path(__file__).resolve().parents[2]
106+
provision = root / "utils/build/virtual_machine/provisions/auto-inject/auto-inject_installer_manual.yml"
107+
os_installations = yaml.safe_load(provision.read_text())
108+
109+
assert {installation["os_type"] for installation in os_installations} == {"linux", "windows"}
110+
for installation in os_installations:
111+
copied_files = [copy_file["local_path"] for copy_file in installation["copy_files"]]
112+
assert str(AGENT_VERSION_LOCK) in copied_files, installation["os_type"]
113+
assert "DD_AGENT_VERSION" in installation["remote-command"], installation["os_type"]
114+
115+
101116
@scenarios.test_the_test
102117
def test_pull_agent_image_resolves_version_from_lock(tmp_path: Path) -> None:
103118
root = Path(__file__).resolve().parents[2]

‎utils/build/virtual_machine/provisions/auto-inject/auto-inject_installer_manual.yml‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,26 @@
202202
copy_files:
203203
- name: copy-auto-inject-lock
204204
local_path: utils/build/auto_inject.lock
205+
- name: copy-agent-version-lock
206+
local_path: utils/build/virtual_machine/agent.lock
205207
- name: copy-binaries
206208
local_path: binaries/
207209

208210
remote-command: |
211+
$AGENT_LOCK_PATH = "agent.lock"
212+
$DD_AGENT_VERSION = Get-Content -Path $AGENT_LOCK_PATH -ErrorAction Stop |
213+
Where-Object { $_ -match '^DD_AGENT_VERSION=' } |
214+
ForEach-Object { $_.Substring('DD_AGENT_VERSION='.Length).Trim() } |
215+
Select-Object -First 1
216+
if ([string]::IsNullOrWhiteSpace($DD_AGENT_VERSION)) {
217+
throw "No DD_AGENT_VERSION found in '$AGENT_LOCK_PATH'; refusing to install an unpinned agent"
218+
}
219+
# Windows environment variables are case-insensitive: these replace the scenario's DD_agent_major_version,
220+
# otherwise the installer requests the moving "7" tag, which the dev registry doesn't publish.
221+
$env:DD_AGENT_MAJOR_VERSION = $DD_AGENT_VERSION.Split('.', 2)[0]
222+
$env:DD_AGENT_MINOR_VERSION = $DD_AGENT_VERSION.Split('.', 2)[1]
223+
Write-Host "Using pinned agent version from agent.lock: $DD_AGENT_VERSION"
224+
209225
if ($env:DD_env -eq "dev") {
210226
$env:DD_INSTALLER_REGISTRY_URL = "install.datad0g.com";
211227
}
@@ -297,7 +313,12 @@
297313
[System.IO.File]::WriteAllText($datadogYaml, $backendConfig)
298314
}
299315
316+
# The install script reports its failures through `exit`, which doesn't stop this script
317+
$global:LASTEXITCODE = 0
300318
C:\Windows\SystemTemp\Install-Datadog.ps1
319+
if ($LASTEXITCODE -ne 0) {
320+
throw "Install-Datadog.ps1 failed with exit code $LASTEXITCODE"
321+
}
301322
302323
if ($env:DD_AGENT_BACKEND_URL) {
303324
if (-not (Select-String -Path $datadogYaml -SimpleMatch -Quiet -Pattern $env:DD_AGENT_BACKEND_URL)) {

0 commit comments

Comments
 (0)