From a506b08eef3815583b283c90962397973efaa689 Mon Sep 17 00:00:00 2001 From: Jeel Mehta Date: Tue, 7 Jan 2025 14:14:04 -0800 Subject: [PATCH 1/2] EC2 default test with new sample apps deployment --- .github/workflows/dotnet-ec2-canary.yml | 1 + .../workflows/dotnet-ec2-default-retry.yml | 5 +++++ .github/workflows/dotnet-ec2-default-test.yml | 9 ++++++++- terraform/dotnet/ec2/default/main.tf | 20 +++++++++++++------ terraform/dotnet/ec2/default/variables.tf | 4 ++++ 5 files changed, 32 insertions(+), 7 deletions(-) diff --git a/.github/workflows/dotnet-ec2-canary.yml b/.github/workflows/dotnet-ec2-canary.yml index 292fcc5d9..5349c06ab 100644 --- a/.github/workflows/dotnet-ec2-canary.yml +++ b/.github/workflows/dotnet-ec2-canary.yml @@ -29,6 +29,7 @@ jobs: with: aws-region: ${{ matrix.aws-region }} caller-workflow-name: 'appsignals-dotnet-e2e-ec2-canary-test' + dotnet-version: '8.0' nuget: strategy: diff --git a/.github/workflows/dotnet-ec2-default-retry.yml b/.github/workflows/dotnet-ec2-default-retry.yml index 88336f2f9..604e3e142 100644 --- a/.github/workflows/dotnet-ec2-default-retry.yml +++ b/.github/workflows/dotnet-ec2-default-retry.yml @@ -14,6 +14,9 @@ on: caller-workflow-name: required: true type: string + dotnet-version: + required: true + type: string permissions: id-token: write @@ -26,6 +29,7 @@ jobs: with: aws-region: ${{ inputs.aws-region }} caller-workflow-name: ${{ inputs.caller-workflow-name }} + dotnet-version: ${{ inputs.dotnet-version }} dotnet-ec2-default-attempt-2: needs: [ dotnet-ec2-default-attempt-1 ] @@ -35,6 +39,7 @@ jobs: with: aws-region: ${{ inputs.aws-region }} caller-workflow-name: ${{ inputs.caller-workflow-name }} + dotnet-version: ${{ inputs.dotnet-version }} publish-metric-attempt-1: needs: [ dotnet-ec2-default-attempt-1, dotnet-ec2-default-attempt-2 ] diff --git a/.github/workflows/dotnet-ec2-default-test.yml b/.github/workflows/dotnet-ec2-default-test.yml index 9d09da3cd..ef1f5ceb4 100644 --- a/.github/workflows/dotnet-ec2-default-test.yml +++ b/.github/workflows/dotnet-ec2-default-test.yml @@ -18,6 +18,11 @@ on: caller-workflow-name: required: true type: string + dotnet-version: + description: "Currently support version 6.0, 8.0" + required: false + type: string + default: '8.0' outputs: job-started: value: ${{ jobs.dotnet-ec2-default.outputs.job-started }} @@ -32,7 +37,8 @@ env: E2E_TEST_AWS_REGION: ${{ inputs.aws-region }} E2E_TEST_ACCOUNT_ID: ${{ secrets.APPLICATION_SIGNALS_E2E_TEST_ACCOUNT_ID }} E2E_TEST_ROLE_NAME: ${{ secrets.APPLICATION_SIGNALS_E2E_TEST_ROLE_NAME }} - SAMPLE_APP_ZIP: s3://aws-appsignals-sample-app-prod-${{ inputs.aws-region }}/dotnet-sample-app.zip + DOTNET_VERSION: ${{ inputs.dotnet-version }} + SAMPLE_APP_ZIP: s3://aws-appsignals-sample-app-prod-${{ inputs.aws-region }}/dotnet-sample-app-${{ inputs.dotnet-version }}.zip METRIC_NAMESPACE: ApplicationSignals LOG_GROUP_NAME: /aws/application-signals/data ADOT_DISTRO_NAME: ${{ inputs.staging_distro_name }} @@ -141,6 +147,7 @@ jobs: -var="sample_app_zip=${{ env.SAMPLE_APP_ZIP }}" \ -var="get_cw_agent_rpm_command=${{ env.GET_CW_AGENT_RPM_COMMAND }}" \ -var="get_adot_distro_command=${{ env.GET_ADOT_DISTRO_COMMAND }}" \ + -var="language_version=${{ env.DOTNET_VERSION }}" \ || deployment_failed=$? if [ $deployment_failed -eq 1 ]; then diff --git a/terraform/dotnet/ec2/default/main.tf b/terraform/dotnet/ec2/default/main.tf index 38927235e..9279b37f3 100644 --- a/terraform/dotnet/ec2/default/main.tf +++ b/terraform/dotnet/ec2/default/main.tf @@ -116,7 +116,11 @@ resource "null_resource" "main_service_setup" { sudo yum install -y wget sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc sudo wget -O /etc/yum.repos.d/microsoft-prod.repo https://packages.microsoft.com/config/fedora/37/prod.repo - sudo dnf install -y dotnet-sdk-8.0 + if [[ "${var.language_version}" == "8.0" ]]; then + sudo dnf install -y dotnet-sdk-8.0 + else + sudo dnf install -y dotnet-sdk-6.0 + fi sudo yum install unzip -y # Copy in CW Agent configuration @@ -141,6 +145,7 @@ resource "null_resource" "main_service_setup" { # Export environment variables for instrumentation cd ./asp_frontend_service + dotnet build export CORECLR_ENABLE_PROFILING=1 export CORECLR_PROFILER={918728DD-259F-4A6A-AC2B-B85E1B658318} export CORECLR_PROFILER_PATH=$current_dir/dotnet-distro/linux-x64/OpenTelemetry.AutoInstrumentation.Native.so @@ -158,8 +163,7 @@ resource "null_resource" "main_service_setup" { export OTEL_AWS_APPLICATION_SIGNALS_RUNTIME_ENABLED=false export OTEL_TRACES_SAMPLER=always_on export ASPNETCORE_URLS=http://0.0.0.0:8080 - dotnet build - nohup dotnet bin/Debug/netcoreapp8.0/asp_frontend_service.dll & + nohup dotnet bin/Debug/netcoreapp${var.language_version}/asp_frontend_service.dll & # The application needs time to come up and reach a steady state, this should not take longer than 30 seconds sleep 30 @@ -224,7 +228,11 @@ resource "null_resource" "remote_service_setup" { sudo yum install -y wget sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc sudo wget -O /etc/yum.repos.d/microsoft-prod.repo https://packages.microsoft.com/config/fedora/37/prod.repo - sudo dnf install -y dotnet-sdk-8.0 + if [[ "${var.language_version}" == "8.0" ]]; then + sudo dnf install -y dotnet-sdk-8.0 + else + sudo dnf install -y dotnet-sdk-6.0 + fi sudo yum install unzip -y # Copy in CW Agent configuration @@ -249,6 +257,7 @@ resource "null_resource" "remote_service_setup" { # Export environment variables for instrumentation cd ./asp_remote_service + dotnet build export CORECLR_ENABLE_PROFILING=1 export CORECLR_PROFILER={918728DD-259F-4A6A-AC2B-B85E1B658318} export CORECLR_PROFILER_PATH=$current_dir/dotnet-distro/linux-x64/OpenTelemetry.AutoInstrumentation.Native.so @@ -266,8 +275,7 @@ resource "null_resource" "remote_service_setup" { export OTEL_AWS_APPLICATION_SIGNALS_RUNTIME_ENABLED=false export OTEL_TRACES_SAMPLER=always_on export ASPNETCORE_URLS=http://0.0.0.0:8081 - dotnet build - nohup dotnet bin/Debug/netcoreapp8.0/asp_remote_service.dll & + nohup dotnet bin/Debug/netcoreapp${var.language_version}/asp_remote_service.dll & # The application needs time to come up and reach a steady state, this should not take longer than 30 seconds sleep 30 diff --git a/terraform/dotnet/ec2/default/variables.tf b/terraform/dotnet/ec2/default/variables.tf index 98d75e176..15f86d058 100644 --- a/terraform/dotnet/ec2/default/variables.tf +++ b/terraform/dotnet/ec2/default/variables.tf @@ -39,4 +39,8 @@ variable "get_cw_agent_rpm_command" { variable "canary_type" { default = "dotnet-ec2-default" +} + +variable "language_version" { + default = "8.0" } \ No newline at end of file From 5f46e812cb516666d9489b753fb7aed36f2e115b Mon Sep 17 00:00:00 2001 From: Mahad Janjua <134644284+majanjua-amzn@users.noreply.github.com> Date: Wed, 8 Jan 2025 14:33:22 -0800 Subject: [PATCH 2/2] Apply suggestions from code review --- terraform/dotnet/ec2/default/main.tf | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/terraform/dotnet/ec2/default/main.tf b/terraform/dotnet/ec2/default/main.tf index 9279b37f3..17bb0e478 100644 --- a/terraform/dotnet/ec2/default/main.tf +++ b/terraform/dotnet/ec2/default/main.tf @@ -116,11 +116,7 @@ resource "null_resource" "main_service_setup" { sudo yum install -y wget sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc sudo wget -O /etc/yum.repos.d/microsoft-prod.repo https://packages.microsoft.com/config/fedora/37/prod.repo - if [[ "${var.language_version}" == "8.0" ]]; then - sudo dnf install -y dotnet-sdk-8.0 - else - sudo dnf install -y dotnet-sdk-6.0 - fi + sudo dnf install -y dotnet-sdk-${var.language_version} sudo yum install unzip -y # Copy in CW Agent configuration @@ -228,11 +224,7 @@ resource "null_resource" "remote_service_setup" { sudo yum install -y wget sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc sudo wget -O /etc/yum.repos.d/microsoft-prod.repo https://packages.microsoft.com/config/fedora/37/prod.repo - if [[ "${var.language_version}" == "8.0" ]]; then - sudo dnf install -y dotnet-sdk-8.0 - else - sudo dnf install -y dotnet-sdk-6.0 - fi + sudo dnf install -y dotnet-sdk-${var.language_version} sudo yum install unzip -y # Copy in CW Agent configuration