Skip to content

Commit 58e2d5f

Browse files
committed
[fleet installer] Remove the global instrumentation commands (#7182)
## Summary of changes - Removes the global instrumentation command - Moves the global instrumentation logic into IIS command (currently unused) - Removes non-applicable smoke tests ## Reason for change We are changing the approach to shipping the command, and don't want to expose an additional command, as discussed with @bmermet ## Implementation details - Move the logic previously in the "global" commands into the IIS commands - Refactor, so it's easy to switch to the alternative - Remove the smoke tests that test with the "global" commands ## Test coverage As long as the existing smoke tests pass, this is fine. ## Other details We jumped the gun a bit merging those commands, so are backing them out. See #7183 for an alternative approach we're looking at.
1 parent 0cc7e7f commit 58e2d5f

File tree

7 files changed

+60
-247
lines changed

7 files changed

+60
-247
lines changed

.azure-pipelines/ultimate-pipeline.yml

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -6006,81 +6006,6 @@ stages:
60066006
- script: tracer\build.cmd CheckSmokeTestsForErrors
60076007
displayName: CheckSmokeTestsForErrors
60086008

6009-
- stage: fleet_installer_smoke_tests
6010-
dependsOn: [package_windows, generate_variables, merge_commit_id]
6011-
variables:
6012-
targetShaId: $[ stageDependencies.merge_commit_id.fetch.outputs['set_sha.sha']]
6013-
targetBranch: $[ stageDependencies.merge_commit_id.fetch.outputs['set_sha.branch']]
6014-
dockerComposePath: 'C:/docker-compose/docker-compose.exe'
6015-
jobs:
6016-
- template: steps/update-github-status-jobs.yml
6017-
parameters:
6018-
jobs: [windows]
6019-
6020-
- job: windows
6021-
timeoutInMinutes: 45 # should take ~15 mins as large Windows docker files
6022-
strategy:
6023-
matrix: $[ stageDependencies.generate_variables.generate_variables_job.outputs['generate_variables_step.fleet_installer_windows_smoke_tests_matrix'] ]
6024-
variables:
6025-
smokeTestAppDir: "$(System.DefaultWorkingDirectory)/tracer/test/test-applications/regression/AspNetCoreSmokeTest"
6026-
pool:
6027-
vmImage: windows-2022
6028-
6029-
steps:
6030-
- template: steps/install-docker-compose-v1.yml
6031-
parameters:
6032-
dockerComposePath: $(dockerComposePath)
6033-
6034-
- template: steps/clone-repo.yml
6035-
parameters:
6036-
targetShaId: $(targetShaId)
6037-
targetBranch: $(targetBranch)
6038-
6039-
- template: steps/download-artifact.yml
6040-
parameters:
6041-
artifact: windows-tracer-home.zip
6042-
path: $(smokeTestAppDir)/artifacts
6043-
6044-
- template: steps/download-artifact.yml
6045-
parameters:
6046-
artifact: fleet-installer
6047-
path: $(smokeTestAppDir)/artifacts/installer
6048-
6049-
- powershell: |
6050-
ls $(smokeTestAppDir)/artifacts
6051-
ls $(smokeTestAppDir)/artifacts/installer
6052-
mkdir -p artifacts/build_data/snapshots
6053-
mkdir -p artifacts/build_data/logs
6054-
displayName: Create test data directories
6055-
6056-
- bash: |
6057-
$(dockerComposePath) -f docker-compose.windows.yml -p $(DockerComposeProjectName) build \
6058-
--build-arg DOTNETSDK_VERSION=$(dotnetCoreSdkLatestVersionShort) \
6059-
--build-arg RUNTIME_IMAGE=$(runtimeImage) \
6060-
--build-arg PUBLISH_FRAMEWORK=$(publishFramework) \
6061-
--build-arg CHANNEL_32_BIT="$(channel32Bit)" \
6062-
fleet-installer-smoke-tests.windows
6063-
env:
6064-
dockerTag: $(dockerTag)
6065-
displayName: docker-compose build smoke-tests
6066-
retryCountOnTaskFailure: 3
6067-
6068-
- template: steps/run-snapshot-test.yml
6069-
parameters:
6070-
target: 'fleet-installer-smoke-tests.windows'
6071-
snapshotPrefix: "smoke_test"
6072-
isLinux: false
6073-
dockerComposePath: $(dockerComposePath)
6074-
6075-
- publish: artifacts/build_data
6076-
artifact: _$(System.StageName)_$(Agent.JobName)_logs_$(System.JobAttempt)
6077-
condition: always()
6078-
continueOnError: true
6079-
6080-
- template: steps/install-latest-dotnet-sdk.yml
6081-
- script: tracer\build.cmd CheckSmokeTestsForErrors
6082-
displayName: CheckSmokeTestsForErrors
6083-
60846009
- stage: dotnet_tool_nuget_smoke_tests_macos
60856010
condition: and(succeeded(), or(eq(variables.isMainOrReleaseBranch, 'true'), eq(variables.run_all_installer_tests, 'true')))
60866011
dependsOn: [dotnet_tool, generate_variables, merge_commit_id]

tracer/build/_build/Build.VariableGenerations.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1495,7 +1495,7 @@ void GenerateWindowsFleetInstallerIisSmokeTestsMatrix()
14951495
var matrix = (
14961496
from platform in platforms
14971497
from image in runtimeImages
1498-
from globalInstall in new[] { false, true }
1498+
from globalInstall in new[] { false } // global install isn't currently supported
14991499
let installCommand = globalInstall ? "enable-global-instrumentation" : "enable-iis-instrumentation"
15001500
let dockerTag = $"{image.PublishFramework}_{platform}_{image.RuntimeTag}_{(globalInstall ? "global" : "iis")}".Replace('.', '_')
15011501
select new

tracer/src/Datadog.FleetInstaller/Commands/EnableGlobalInstrumentationCommand.cs

Lines changed: 0 additions & 95 deletions
This file was deleted.

tracer/src/Datadog.FleetInstaller/Commands/EnableIisInstrumentationCommand.cs

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,44 @@ public Task ExecuteAsync(InvocationContext context)
4545
return Task.CompletedTask;
4646
}
4747

48+
internal static ReturnCode Execute(ILogger log, TracerValues tracerInstallValues)
49+
=> ExecuteIIs(log, tracerInstallValues);
50+
51+
internal static ReturnCode ExecuteGlobal(ILogger log, TracerValues tracerInstallValues)
52+
{
53+
log.WriteInfo("Enabling instrumentation for .NET tracer");
54+
55+
if (!GlobalEnvVariableHelper.SetMachineEnvironmentVariables(log, tracerInstallValues, out var previousVariables))
56+
{
57+
log.WriteError("Failed to set global environment variables");
58+
return ReturnCode.ErrorSettingGlobalEnvironmentVariables;
59+
}
60+
61+
// We can't enable iis instrumentation if IIS is not available or it's too low of a version
62+
if (!HasValidIIsVersion(out var errorMessage))
63+
{
64+
// nothing more to do in this case
65+
log.WriteInfo("Skipping IIS instrumentation. " + errorMessage);
66+
log.WriteInfo("Instrumentation complete");
67+
return ReturnCode.Success;
68+
}
69+
70+
var iisResult = ExecuteIIs(log, tracerInstallValues);
71+
if (iisResult is ReturnCode.Success)
72+
{
73+
log.WriteInfo("Instrumentation complete");
74+
return ReturnCode.Success;
75+
}
76+
77+
log.WriteInfo("Reverting global environment variables after failed install");
78+
GlobalEnvVariableHelper.RevertMachineEnvironmentVariables(log, previousVariables);
79+
80+
log.WriteError("Instrumentation failed");
81+
return iisResult;
82+
}
83+
4884
// Internal for testing
49-
internal static ReturnCode Execute(ILogger log, TracerValues tracerValues)
85+
internal static ReturnCode ExecuteIIs(ILogger log, TracerValues tracerValues)
5086
{
5187
log.WriteInfo("Enabling IIS instrumentation for .NET tracer");
5288

tracer/src/Datadog.FleetInstaller/Commands/RemoveGlobalInstrumentationCommand.cs

Lines changed: 0 additions & 67 deletions
This file was deleted.

tracer/src/Datadog.FleetInstaller/Commands/RemoveIisInstrumentationCommand.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,28 @@ public Task ExecuteAsync(InvocationContext context)
3737

3838
// Internal for testing
3939
internal static ReturnCode Execute(ILogger log)
40+
=> ExecuteIis(log);
41+
42+
internal static ReturnCode ExecuteGlobal(ILogger log)
43+
{
44+
log.WriteInfo("Removing global instrumentation for .NET tracer");
45+
46+
if (!GlobalEnvVariableHelper.RemoveMachineEnvironmentVariables(log))
47+
{
48+
log.WriteError("Failed to remove global environment variables. Apps may continue to be instrumented");
49+
return ReturnCode.ErrorRemovingGlobalEnvironmentVariables;
50+
}
51+
52+
var iisResult = ExecuteIis(log);
53+
if (iisResult != ReturnCode.Success)
54+
{
55+
log.WriteError("Failed to remove IIS instrumentation. Apps may continue to be instrumented");
56+
}
57+
58+
return iisResult;
59+
}
60+
61+
internal static ReturnCode ExecuteIis(ILogger log)
4062
{
4163
log.WriteInfo("Removing IIS instrumentation for .NET tracer");
4264

tracer/src/Datadog.FleetInstaller/Program.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@
3737
rootCommand.AddExample("""
3838
remove-iis-instrumentation"
3939
""");
40-
rootCommand.AddExample("""
41-
enable-global-instrumentation --home-path "C:\datadog\versions\3.9.0"
42-
""");
43-
rootCommand.AddExample("""
44-
remove-global-instrumentation"
45-
""");
4640
rootCommand.AddExample("""
4741
available-commands"
4842
""");
@@ -51,8 +45,6 @@
5145
rootCommand.AddCommand(new UninstallVersionCommand());
5246
rootCommand.AddCommand(new EnableIisInstrumentationCommand());
5347
rootCommand.AddCommand(new RemoveIisInstrumentationCommand());
54-
rootCommand.AddCommand(new EnableGlobalInstrumentationCommand());
55-
rootCommand.AddCommand(new RemoveGlobalInstrumentationCommand());
5648
rootCommand.AddCommand(new AvailableCommandsCommand(rootCommand));
5749

5850
return builder.Build().Invoke(args);

0 commit comments

Comments
 (0)