From f163b31b6e2c74630e68c82dd4ee9f64f718de8e Mon Sep 17 00:00:00 2001 From: Anuj Singh Date: Thu, 7 Aug 2025 23:33:19 +0000 Subject: [PATCH 1/2] docker runtime healthcheck: initialize LastUpdated to the current time --- agent/doctor/docker_runtime_healthcheck.go | 5 ++++- .../doctor/docker_runtime_healthcheck_test.go | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/agent/doctor/docker_runtime_healthcheck.go b/agent/doctor/docker_runtime_healthcheck.go index 45027d1181a..1bb2f9d2b35 100644 --- a/agent/doctor/docker_runtime_healthcheck.go +++ b/agent/doctor/docker_runtime_healthcheck.go @@ -25,6 +25,8 @@ import ( const systemPingTimeout = time.Second * 2 +var timeNow = time.Now + type dockerRuntimeHealthcheck struct { // HealthcheckType is the reported healthcheck type HealthcheckType string `json:"HealthcheckType,omitempty"` @@ -45,12 +47,13 @@ type dockerRuntimeHealthcheck struct { } func NewDockerRuntimeHealthcheck(client dockerapi.DockerClient) *dockerRuntimeHealthcheck { - nowTime := time.Now() + nowTime := timeNow() return &dockerRuntimeHealthcheck{ HealthcheckType: doctor.HealthcheckTypeContainerRuntime, Status: doctor.HealthcheckStatusInitializing, TimeStamp: nowTime, StatusChangeTime: nowTime, + LastTimeStamp: nowTime, client: client, } } diff --git a/agent/doctor/docker_runtime_healthcheck_test.go b/agent/doctor/docker_runtime_healthcheck_test.go index b4ad49e5b9c..21eec1ae62e 100644 --- a/agent/doctor/docker_runtime_healthcheck_test.go +++ b/agent/doctor/docker_runtime_healthcheck_test.go @@ -19,8 +19,23 @@ func TestNewDockerRuntimeHealthCheck(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() mockDockerClient := mock_dockerapi.NewMockDockerClient(ctrl) - dockerRuntimeHealthCheck := NewDockerRuntimeHealthcheck(mockDockerClient) - assert.Equal(t, doctor.HealthcheckStatusInitializing, dockerRuntimeHealthCheck.Status) + + // Mock the time to have predictable values + mockTime := time.Now() + originalTimeNow := timeNow + timeNow = func() time.Time { return mockTime } + defer func() { timeNow = originalTimeNow }() + + expectedDockerRuntimeHealthcheck := &dockerRuntimeHealthcheck{ + HealthcheckType: doctor.HealthcheckTypeContainerRuntime, + Status: doctor.HealthcheckStatusInitializing, + TimeStamp: mockTime, + StatusChangeTime: mockTime, + LastTimeStamp: mockTime, + client: mockDockerClient, + } + actualDockerRuntimeHealthcheck := NewDockerRuntimeHealthcheck(mockDockerClient) + assert.Equal(t, expectedDockerRuntimeHealthcheck, actualDockerRuntimeHealthcheck) } func TestRunCheck(t *testing.T) { From 6c827db527f1671595476147081fd244ae3cff34 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Aug 2025 01:11:28 +0000 Subject: [PATCH 2/2] Bump actions/checkout from 4 to 5 in /.github/workflows Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/gitsecrets.yml | 2 +- .github/workflows/gomod.yml | 2 +- .github/workflows/linux.yml | 2 +- .github/workflows/static.yml | 12 ++++++------ .github/workflows/windows.yml | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/gitsecrets.yml b/.github/workflows/gitsecrets.yml index a3128341914..968ff3a17be 100644 --- a/.github/workflows/gitsecrets.yml +++ b/.github/workflows/gitsecrets.yml @@ -8,7 +8,7 @@ jobs: name: Git Secrets Scan runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: path: src/github.com/aws/amazon-ecs-agent - name: Git Secrets Scan Script diff --git a/.github/workflows/gomod.yml b/.github/workflows/gomod.yml index cd53cda324a..58855af8c67 100644 --- a/.github/workflows/gomod.yml +++ b/.github/workflows/gomod.yml @@ -8,7 +8,7 @@ jobs: check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: submodules: true path: src/github.com/aws/amazon-ecs-agent diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 7d91115a920..fa1a46f38a9 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -8,7 +8,7 @@ jobs: name: Linux unit tests runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: submodules: true path: src/github.com/aws/amazon-ecs-agent diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 5b06e97a9e3..4be0285f3ca 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -8,7 +8,7 @@ jobs: name: Static Analysis runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: path: src/github.com/aws/amazon-ecs-agent - name: get GO_VERSION @@ -27,7 +27,7 @@ jobs: - uses: actions/setup-go@v5 with: go-version: ${{ steps.get-go-version.outputs.GO_VERSION }} - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: path: src/github.com/aws/amazon-ecs-agent - name: run static checks @@ -43,7 +43,7 @@ jobs: name: Static Analysis Init runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: path: src/github.com/aws/amazon-ecs-agent - name: get GO_VERSION @@ -62,7 +62,7 @@ jobs: - uses: actions/setup-go@v5 with: go-version: ${{ steps.get-go-version.outputs.GO_VERSION }} - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: path: src/github.com/aws/amazon-ecs-agent - name: run static checks @@ -78,7 +78,7 @@ jobs: name: Cross platform build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: path: src/github.com/aws/amazon-ecs-agent - name: get GO_VERSION @@ -97,7 +97,7 @@ jobs: - uses: actions/setup-go@v5 with: go-version: ${{ steps.get-go-version.outputs.GO_VERSION }} - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: submodules: true path: src/github.com/aws/amazon-ecs-agent diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index e4abeccd5d5..fd91c8b88f0 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -8,7 +8,7 @@ jobs: name: Windows unit tests runs-on: windows-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: path: src/github.com/aws/amazon-ecs-agent - name: get GO_VERSION @@ -27,7 +27,7 @@ jobs: - uses: actions/setup-go@v5 with: go-version: ${{ steps.get-go-version.outputs.GO_VERSION_WINDOWS }} - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: submodules: true path: src/github.com/aws/amazon-ecs-agent