From 259252cdf683369c41241e3cdf23794353893c94 Mon Sep 17 00:00:00 2001 From: Andres Montalban Date: Tue, 23 Jul 2024 17:24:43 -0300 Subject: [PATCH 01/15] sec: Upgrade Ubuntu to latest LTS version --- CHANGELOG.md | 4 ++++ cmd/grafana-agent-operator/Dockerfile | 2 +- cmd/grafana-agent/Dockerfile | 2 +- cmd/grafana-agentctl/Dockerfile | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c47cbbf4b1f1..6ca2cbecf20d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ internal API changes are not present. Main (unreleased) ----------------- +### Other changes + +- Change the Docker base image for Linux containers to `ubuntu:noble`. (@amontalban) + v0.42.0 (2024-07-24) ------------------------- diff --git a/cmd/grafana-agent-operator/Dockerfile b/cmd/grafana-agent-operator/Dockerfile index c18b4a27420b..1cea76934f65 100644 --- a/cmd/grafana-agent-operator/Dockerfile +++ b/cmd/grafana-agent-operator/Dockerfile @@ -22,7 +22,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ RELEASE_BUILD=${RELEASE_BUILD} VERSION=${VERSION} \ make operator -FROM public.ecr.aws/ubuntu/ubuntu:mantic +FROM public.ecr.aws/ubuntu/ubuntu:noble LABEL org.opencontainers.image.source="https://github.com/grafana/agent" diff --git a/cmd/grafana-agent/Dockerfile b/cmd/grafana-agent/Dockerfile index c729901b0576..6b1e4412b150 100644 --- a/cmd/grafana-agent/Dockerfile +++ b/cmd/grafana-agent/Dockerfile @@ -30,7 +30,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ GOEXPERIMENT=${GOEXPERIMENT} \ make agent -FROM public.ecr.aws/ubuntu/ubuntu:mantic +FROM public.ecr.aws/ubuntu/ubuntu:noble #Username and uid for grafana-agent user ARG UID=473 diff --git a/cmd/grafana-agentctl/Dockerfile b/cmd/grafana-agentctl/Dockerfile index 06a48141f8c4..05c68547d7fe 100644 --- a/cmd/grafana-agentctl/Dockerfile +++ b/cmd/grafana-agentctl/Dockerfile @@ -23,7 +23,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ GO_TAGS="netgo promtail_journal_enabled" \ make agentctl -FROM public.ecr.aws/ubuntu/ubuntu:mantic +FROM public.ecr.aws/ubuntu/ubuntu:noble LABEL org.opencontainers.image.source="https://github.com/grafana/agent" From ea6172e9e1dd76049c36f117a10612601fdb7c0b Mon Sep 17 00:00:00 2001 From: Andres Montalban Date: Thu, 15 Aug 2024 12:28:50 -0300 Subject: [PATCH 02/15] Test integration-tests.yml --- .github/workflows/integration-tests.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 823ce60c2194..7c95b7dda65b 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -4,9 +4,6 @@ on: # in PRs. This speeds up the time it takes to test PRs dramatically. # (More information on https://docs.github.com/en/enterprise-server@3.6/actions/using-workflows/caching-dependencies-to-speed-up-workflows) push: - branches: - - main - pull_request: jobs: run_tests: runs-on: ubuntu-latest From 9b24cce3876d2b076fa0c9cfbd4731d0c33cca46 Mon Sep 17 00:00:00 2001 From: Andres Montalban Date: Thu, 15 Aug 2024 12:29:28 -0300 Subject: [PATCH 03/15] Update integration-tests.yml --- .github/workflows/integration-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 7c95b7dda65b..df3c7e5e6c8d 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -4,6 +4,7 @@ on: # in PRs. This speeds up the time it takes to test PRs dramatically. # (More information on https://docs.github.com/en/enterprise-server@3.6/actions/using-workflows/caching-dependencies-to-speed-up-workflows) push: + workflow_dispatch: jobs: run_tests: runs-on: ubuntu-latest From b1b3363c8c8d9271a93ea4f059decf4e92840489 Mon Sep 17 00:00:00 2001 From: Paulin Todev Date: Fri, 16 Aug 2024 10:40:58 +0100 Subject: [PATCH 04/15] Revert github workflow change --- .github/workflows/integration-tests.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index df3c7e5e6c8d..823ce60c2194 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -4,7 +4,9 @@ on: # in PRs. This speeds up the time it takes to test PRs dramatically. # (More information on https://docs.github.com/en/enterprise-server@3.6/actions/using-workflows/caching-dependencies-to-speed-up-workflows) push: - workflow_dispatch: + branches: + - main + pull_request: jobs: run_tests: runs-on: ubuntu-latest From 0858abdbf29bf3defda95240b4d5f1a05cc2a3ce Mon Sep 17 00:00:00 2001 From: Paulin Todev Date: Fri, 16 Aug 2024 11:12:47 +0100 Subject: [PATCH 05/15] Upgrade some GitHub workflows to "latest" Ubuntu --- .github/workflows/check-linux-build-image.yml | 2 +- .github/workflows/trivy.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-linux-build-image.yml b/.github/workflows/check-linux-build-image.yml index b5ea49014dbf..1ddcc1327afb 100644 --- a/.github/workflows/check-linux-build-image.yml +++ b/.github/workflows/check-linux-build-image.yml @@ -7,7 +7,7 @@ on: jobs: check-linux-build-image: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/trivy.yml b/.github/workflows/trivy.yml index 6c9922918875..4a6164ec5e0c 100644 --- a/.github/workflows/trivy.yml +++ b/.github/workflows/trivy.yml @@ -21,7 +21,7 @@ jobs: security-events: write # for github/codeql-action/upload-sarif to upload SARIF results actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status name: Build - runs-on: "ubuntu-20.04" + runs-on: "ubuntu-latest" steps: - name: Checkout code uses: actions/checkout@v4 From 6636aec7029bef339d911f8353b29e07580ff38c Mon Sep 17 00:00:00 2001 From: Paulin Todev Date: Fri, 16 Aug 2024 11:14:02 +0100 Subject: [PATCH 06/15] Print stdout in case of a command error --- internal/cmd/integration-tests/utils.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/cmd/integration-tests/utils.go b/internal/cmd/integration-tests/utils.go index 57abd33f5c41..262aef69f971 100644 --- a/internal/cmd/integration-tests/utils.go +++ b/internal/cmd/integration-tests/utils.go @@ -29,8 +29,10 @@ func executeCommand(command string, args []string, taskDescription string) { cmd := exec.Command(command, args...) var stderr bytes.Buffer cmd.Stderr = &stderr + var stdout bytes.Buffer + cmd.Stdout = &stdout if err := cmd.Run(); err != nil { - log.Fatalf("Error: %s\n", stderr.String()) + log.Fatalf("stderr: %s\n\nstdout:%s\n", stderr.String(), stdout.String()) } } From 0cd2be5ce83c48d68566c562d0f58a8f438e6f93 Mon Sep 17 00:00:00 2001 From: Paulin Todev Date: Fri, 16 Aug 2024 12:11:57 +0100 Subject: [PATCH 07/15] Test docker-compose up --exit-code-from --- internal/cmd/integration-tests/utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cmd/integration-tests/utils.go b/internal/cmd/integration-tests/utils.go index 262aef69f971..7b184153efea 100644 --- a/internal/cmd/integration-tests/utils.go +++ b/internal/cmd/integration-tests/utils.go @@ -41,7 +41,7 @@ func buildAgent() { } func setupEnvironment() { - executeCommand("docker-compose", []string{"up", "-d"}, "Setting up environment with Docker Compose") + executeCommand("docker-compose", []string{"up", "--exit-code-from"}, "Setting up environment with Docker Compose") fmt.Println("Sleep for 30 seconds to ensure that the env has time to initialize...") time.Sleep(30 * time.Second) } From d250ce60f4180a8d0ad261c292d72119ff3c44d4 Mon Sep 17 00:00:00 2001 From: Paulin Todev Date: Fri, 16 Aug 2024 14:05:38 +0100 Subject: [PATCH 08/15] Try "abort-on-container-exit" and "docker ps" --- internal/cmd/integration-tests/utils.go | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/internal/cmd/integration-tests/utils.go b/internal/cmd/integration-tests/utils.go index 7b184153efea..678d0ab10f79 100644 --- a/internal/cmd/integration-tests/utils.go +++ b/internal/cmd/integration-tests/utils.go @@ -24,16 +24,29 @@ type TestLog struct { var logChan chan TestLog -func executeCommand(command string, args []string, taskDescription string) { +func executeCommand(command string, args []string, taskDescription string) bool { fmt.Printf("%s...\n", taskDescription) cmd := exec.Command(command, args...) var stderr bytes.Buffer cmd.Stderr = &stderr var stdout bytes.Buffer cmd.Stdout = &stdout + + success := true if err := cmd.Run(); err != nil { - log.Fatalf("stderr: %s\n\nstdout:%s\n", stderr.String(), stdout.String()) + stderrStr := stderr.String() + if len(stderrStr) > 0 { + log.Fatalf("stderr: %s\n", stderrStr) + } else { + log.Fatalf("Task '%s' failed, but no stderr was printed\n", taskDescription) + } + success = false } + stdoutStr := stderr.String() + if len(stdoutStr) > 0 { + log.Printf("stdout:%s\n", stdoutStr) + } + return success } func buildAgent() { @@ -41,7 +54,10 @@ func buildAgent() { } func setupEnvironment() { - executeCommand("docker-compose", []string{"up", "--exit-code-from"}, "Setting up environment with Docker Compose") + success := executeCommand("docker-compose", []string{"up", "--abort-on-container-exit"}, "Setting up environment with Docker Compose") + if !success { + executeCommand("docker-compose", []string{"ps", "-las"}, "Docker ps") + } fmt.Println("Sleep for 30 seconds to ensure that the env has time to initialize...") time.Sleep(30 * time.Second) } From c6b3e5122f8b4f9fe4f015ebd2f59cfa36329d67 Mon Sep 17 00:00:00 2001 From: Paulin Todev Date: Fri, 16 Aug 2024 14:17:39 +0100 Subject: [PATCH 09/15] Fix docker ps command --- internal/cmd/integration-tests/utils.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/cmd/integration-tests/utils.go b/internal/cmd/integration-tests/utils.go index 678d0ab10f79..30d35f7546de 100644 --- a/internal/cmd/integration-tests/utils.go +++ b/internal/cmd/integration-tests/utils.go @@ -45,6 +45,8 @@ func executeCommand(command string, args []string, taskDescription string) bool stdoutStr := stderr.String() if len(stdoutStr) > 0 { log.Printf("stdout:%s\n", stdoutStr) + } else { + log.Fatalf("No stdout was printed from task '%s'\n", taskDescription) } return success } @@ -56,7 +58,7 @@ func buildAgent() { func setupEnvironment() { success := executeCommand("docker-compose", []string{"up", "--abort-on-container-exit"}, "Setting up environment with Docker Compose") if !success { - executeCommand("docker-compose", []string{"ps", "-las"}, "Docker ps") + executeCommand("docker", []string{"ps", "-las"}, "Docker ps") } fmt.Println("Sleep for 30 seconds to ensure that the env has time to initialize...") time.Sleep(30 * time.Second) From fd498f3294afc096f3c107c86e65f60365311202 Mon Sep 17 00:00:00 2001 From: Paulin Todev Date: Fri, 16 Aug 2024 14:21:22 +0100 Subject: [PATCH 10/15] Replace "docker compose" with "docker compose" --- internal/cmd/integration-tests/utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cmd/integration-tests/utils.go b/internal/cmd/integration-tests/utils.go index 30d35f7546de..ab0b70e6e34d 100644 --- a/internal/cmd/integration-tests/utils.go +++ b/internal/cmd/integration-tests/utils.go @@ -56,7 +56,7 @@ func buildAgent() { } func setupEnvironment() { - success := executeCommand("docker-compose", []string{"up", "--abort-on-container-exit"}, "Setting up environment with Docker Compose") + success := executeCommand("docker", []string{"compose", "up", "--abort-on-container-exit"}, "Setting up environment with Docker Compose") if !success { executeCommand("docker", []string{"ps", "-las"}, "Docker ps") } From e81cff160e68f6862407b3b6fa1f49ec436ad4a5 Mon Sep 17 00:00:00 2001 From: Paulin Todev Date: Sat, 17 Aug 2024 10:04:39 +0100 Subject: [PATCH 11/15] Use '-d' cmd arg in docker compose command --- internal/cmd/integration-tests/utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cmd/integration-tests/utils.go b/internal/cmd/integration-tests/utils.go index ab0b70e6e34d..091f825715a1 100644 --- a/internal/cmd/integration-tests/utils.go +++ b/internal/cmd/integration-tests/utils.go @@ -56,7 +56,7 @@ func buildAgent() { } func setupEnvironment() { - success := executeCommand("docker", []string{"compose", "up", "--abort-on-container-exit"}, "Setting up environment with Docker Compose") + success := executeCommand("docker", []string{"compose", "up", "-d"}, "Setting up environment with Docker Compose") if !success { executeCommand("docker", []string{"ps", "-las"}, "Docker ps") } From e522d3ba590c77de910e6b135e67b90c2a532a79 Mon Sep 17 00:00:00 2001 From: Andres Montalban Date: Sun, 18 Aug 2024 09:54:23 -0300 Subject: [PATCH 12/15] fix: Change docker-compose to docker compose for cleanup --- internal/cmd/integration-tests/utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cmd/integration-tests/utils.go b/internal/cmd/integration-tests/utils.go index 091f825715a1..44f4f29ab8d8 100644 --- a/internal/cmd/integration-tests/utils.go +++ b/internal/cmd/integration-tests/utils.go @@ -134,7 +134,7 @@ func runAllTests() { func cleanUpEnvironment() { fmt.Println("Cleaning up Docker environment...") - err := exec.Command("docker-compose", "down", "--volumes", "--rmi", "all").Run() + err := exec.Command("docker", "compose", "down", "--volumes", "--rmi", "all").Run() if err != nil { panic(err) } From df7b829ce5668db852b5ad91b53c0a52f9403ab3 Mon Sep 17 00:00:00 2001 From: Paulin Todev Date: Mon, 19 Aug 2024 10:54:01 +0100 Subject: [PATCH 13/15] go fmt --- internal/cmd/integration-tests/utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cmd/integration-tests/utils.go b/internal/cmd/integration-tests/utils.go index 44f4f29ab8d8..f683389f3b69 100644 --- a/internal/cmd/integration-tests/utils.go +++ b/internal/cmd/integration-tests/utils.go @@ -134,7 +134,7 @@ func runAllTests() { func cleanUpEnvironment() { fmt.Println("Cleaning up Docker environment...") - err := exec.Command("docker", "compose", "down", "--volumes", "--rmi", "all").Run() + err := exec.Command("docker", "compose", "down", "--volumes", "--rmi", "all").Run() if err != nil { panic(err) } From e9e005dd17f305a41a34eff02f9dddb89eeb4c79 Mon Sep 17 00:00:00 2001 From: Paulin Todev Date: Tue, 20 Aug 2024 14:47:46 +0100 Subject: [PATCH 14/15] Fix incorrect log line. --- internal/cmd/integration-tests/utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cmd/integration-tests/utils.go b/internal/cmd/integration-tests/utils.go index f683389f3b69..4aba265a4308 100644 --- a/internal/cmd/integration-tests/utils.go +++ b/internal/cmd/integration-tests/utils.go @@ -46,7 +46,7 @@ func executeCommand(command string, args []string, taskDescription string) bool if len(stdoutStr) > 0 { log.Printf("stdout:%s\n", stdoutStr) } else { - log.Fatalf("No stdout was printed from task '%s'\n", taskDescription) + log.Printf("No stdout was printed from task '%s'\n", taskDescription) } return success } From d9d6ee8f5dde28a0ff7c42c8e3a8c5c036727c9e Mon Sep 17 00:00:00 2001 From: Paulin Todev Date: Thu, 22 Aug 2024 10:37:01 +0100 Subject: [PATCH 15/15] Rollback change to executeCommand --- internal/cmd/integration-tests/utils.go | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/internal/cmd/integration-tests/utils.go b/internal/cmd/integration-tests/utils.go index 4aba265a4308..8b81502ddcea 100644 --- a/internal/cmd/integration-tests/utils.go +++ b/internal/cmd/integration-tests/utils.go @@ -24,31 +24,15 @@ type TestLog struct { var logChan chan TestLog -func executeCommand(command string, args []string, taskDescription string) bool { +func executeCommand(command string, args []string, taskDescription string) { fmt.Printf("%s...\n", taskDescription) cmd := exec.Command(command, args...) var stderr bytes.Buffer cmd.Stderr = &stderr - var stdout bytes.Buffer - cmd.Stdout = &stdout - success := true if err := cmd.Run(); err != nil { - stderrStr := stderr.String() - if len(stderrStr) > 0 { - log.Fatalf("stderr: %s\n", stderrStr) - } else { - log.Fatalf("Task '%s' failed, but no stderr was printed\n", taskDescription) - } - success = false - } - stdoutStr := stderr.String() - if len(stdoutStr) > 0 { - log.Printf("stdout:%s\n", stdoutStr) - } else { - log.Printf("No stdout was printed from task '%s'\n", taskDescription) + log.Fatalf("Error: %s\n", stderr.String()) } - return success } func buildAgent() { @@ -56,10 +40,7 @@ func buildAgent() { } func setupEnvironment() { - success := executeCommand("docker", []string{"compose", "up", "-d"}, "Setting up environment with Docker Compose") - if !success { - executeCommand("docker", []string{"ps", "-las"}, "Docker ps") - } + executeCommand("docker", []string{"compose", "up", "-d"}, "Setting up environment with Docker Compose") fmt.Println("Sleep for 30 seconds to ensure that the env has time to initialize...") time.Sleep(30 * time.Second) }