From ff083c5337ea3bb2fc442a1229b1acd2eef9a480 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Mon, 9 Dec 2024 12:38:25 +0530 Subject: [PATCH 01/63] Added Fix health check update for consul-dataplane When we update the consul-dataplane health status, we should take into account the service health status as well --- subcommand/health-sync/checks.go | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/subcommand/health-sync/checks.go b/subcommand/health-sync/checks.go index 2a46ca26..e04bdc09 100644 --- a/subcommand/health-sync/checks.go +++ b/subcommand/health-sync/checks.go @@ -108,7 +108,6 @@ func (c *Command) syncChecks(consulClient *api.Client, } serviceName := c.constructServiceName(taskMeta.Family) - containersToSync, missingContainers := findContainersToSync(parsedContainerNames, taskMeta) // Mark the Consul health status as critical for missing containers @@ -131,6 +130,9 @@ func (c *Command) syncChecks(consulClient *api.Client, } } + overallDataplaneHealth := 0 + parsedContainers := make(map[string]string) + // iterate over parse for _, container := range containersToSync { c.log.Debug("updating Consul check from ECS container health", "name", container.Name, @@ -138,13 +140,11 @@ func (c *Command) syncChecks(consulClient *api.Client, "statusSince", container.Health.StatusSince, "exitCode", container.Health.ExitCode, ) - + parsedContainers[container.Name] = container.Health.Status previousStatus := currentStatuses[container.Name] if container.Health.Status != previousStatus { var err error - if container.Name == config.ConsulDataplaneContainerName { - err = c.handleHealthForDataplaneContainer(consulClient, taskMeta.TaskID(), serviceName, clusterARN, container.Name, container.Health.Status) - } else { + if container.Name != config.ConsulDataplaneContainerName { checkID := constructCheckID(makeServiceID(serviceName, taskMeta.TaskID()), container.Name) err = c.updateConsulHealthStatus(consulClient, checkID, clusterARN, container.Health.Status) } @@ -161,8 +161,30 @@ func (c *Command) syncChecks(consulClient *api.Client, currentStatuses[container.Name] = container.Health.Status } } + if container.Name == config.ConsulDataplaneContainerName { + if container.Health.Status == ecs.HealthStatusHealthy { + overallDataplaneHealth = 1 + } + } + } + + for containerName, healthStatus := range parsedContainers { + + if containerName != config.ConsulDataplaneContainerName { + currentContainerHealth := 0 + if healthStatus == ecs.HealthStatusHealthy { + currentContainerHealth = 1 + } + overallDataplaneHealth = overallDataplaneHealth & currentContainerHealth + } + } + overallDataplaneHealthStatus := ecs.HealthStatusUnhealthy + if overallDataplaneHealth == 1 { + overallDataplaneHealthStatus = ecs.HealthStatusHealthy } + err = c.handleHealthForDataplaneContainer(consulClient, taskMeta.TaskID(), serviceName, clusterARN, config.ConsulDataplaneContainerName, overallDataplaneHealthStatus) + return currentStatuses } From 4964983b7223c8a546ff8a26b6d40127bf5f901a Mon Sep 17 00:00:00 2001 From: Abhishek Date: Mon, 9 Dec 2024 12:59:02 +0530 Subject: [PATCH 02/63] Fix lint --- subcommand/health-sync/checks.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/subcommand/health-sync/checks.go b/subcommand/health-sync/checks.go index e04bdc09..9c520614 100644 --- a/subcommand/health-sync/checks.go +++ b/subcommand/health-sync/checks.go @@ -184,7 +184,14 @@ func (c *Command) syncChecks(consulClient *api.Client, } err = c.handleHealthForDataplaneContainer(consulClient, taskMeta.TaskID(), serviceName, clusterARN, config.ConsulDataplaneContainerName, overallDataplaneHealthStatus) - + if err != nil { + c.log.Warn("failed to update Consul health status", "err", err) + } else { + c.log.Info("container health check updated in Consul", + "name", config.ConsulDataplaneContainerName, + "status", overallDataplaneHealthStatus, + ) + } return currentStatuses } From 5f4633c0c05cab1b7f28746a8bfc8d1de6a1aab3 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Mon, 9 Dec 2024 18:22:26 +0530 Subject: [PATCH 03/63] Update command_test.go --- subcommand/health-sync/command_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index 561bb2eb..460a749e 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -391,7 +391,7 @@ func TestRun(t *testing.T) { } } } - expectedProxyCheck.Status = api.HealthPassing + expectedProxyCheck.Status = api.HealthCritical if c.missingDataplaneContainer { expectedProxyCheck.Status = api.HealthCritical } From a03cac7473698dc4d16c7b4a7a3389a1590d31b0 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Mon, 9 Dec 2024 18:27:36 +0530 Subject: [PATCH 04/63] Update command_test.go --- subcommand/health-sync/command_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index 460a749e..df097c88 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -387,7 +387,7 @@ func TestRun(t *testing.T) { if c.missingDataplaneContainer { expCheck.Status = api.HealthCritical } else { - expCheck.Status = api.HealthPassing + expCheck.Status = api.HealthCritical } } } From 648d2434fccdc17f4935a1f3b78355f5065bafce Mon Sep 17 00:00:00 2001 From: Abhishek Date: Mon, 9 Dec 2024 18:56:10 +0530 Subject: [PATCH 05/63] Fix tests --- subcommand/health-sync/command_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index df097c88..9520db86 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -387,7 +387,7 @@ func TestRun(t *testing.T) { if c.missingDataplaneContainer { expCheck.Status = api.HealthCritical } else { - expCheck.Status = api.HealthCritical + expCheck.Status = api.HealthPassing } } } @@ -445,7 +445,7 @@ func TestRun(t *testing.T) { expCheck.Status = api.HealthPassing } } - expectedProxyCheck.Status = api.HealthPassing + expectedProxyCheck.Status = api.HealthCritical assertHealthChecks(t, consulClient, expectedSvcChecks, expectedProxyCheck) } From 832a6e8f6120b82add05e7defe33830e5e286a21 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Mon, 9 Dec 2024 19:11:58 +0530 Subject: [PATCH 06/63] Fix tests --- subcommand/health-sync/command_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index 9520db86..9e94e794 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -442,7 +442,7 @@ func TestRun(t *testing.T) { } if !found { - expCheck.Status = api.HealthPassing + expCheck.Status = api.HealthCritical } } expectedProxyCheck.Status = api.HealthCritical From 7de0102ea440009aea48155e9a2c9d118e888af0 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Mon, 9 Dec 2024 19:39:17 +0530 Subject: [PATCH 07/63] Fix tests --- subcommand/health-sync/command_test.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index 9e94e794..fc816b17 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -377,6 +377,16 @@ func TestRun(t *testing.T) { expCheck.Status = api.HealthCritical } else { expCheck.Status = ecsHealthToConsulHealth(hsc.status) + // If there are multiple health sync containers and one of them is unhealthy + // then the service check should be critical. + if len(c.healthSyncContainers) > 1 { + for containerName := range c.healthSyncContainers { + if c.healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy { + expCheck.Status = api.HealthCritical + break + } + } + } } found = true break @@ -442,7 +452,7 @@ func TestRun(t *testing.T) { } if !found { - expCheck.Status = api.HealthCritical + expCheck.Status = api.HealthPassing } } expectedProxyCheck.Status = api.HealthCritical From 05354944decddf62f7c49bebfc8af098aced0284 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Mon, 9 Dec 2024 19:54:44 +0530 Subject: [PATCH 08/63] fix tests --- subcommand/health-sync/command_test.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index fc816b17..6f68f1b3 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -447,6 +447,14 @@ func TestRun(t *testing.T) { if expCheck.CheckID == checkID { expCheck.Status = ecsHealthToConsulHealth(hsc.status) found = true + if len(c.healthSyncContainers) > 1 { + for containerName := range c.healthSyncContainers { + if c.healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy { + expCheck.Status = api.HealthCritical + break + } + } + } break } } @@ -455,7 +463,7 @@ func TestRun(t *testing.T) { expCheck.Status = api.HealthPassing } } - expectedProxyCheck.Status = api.HealthCritical + expectedProxyCheck.Status = api.HealthPassing assertHealthChecks(t, consulClient, expectedSvcChecks, expectedProxyCheck) } From cc1d0051046d8b70028f7e83c07a0225f616bc28 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Mon, 9 Dec 2024 20:11:30 +0530 Subject: [PATCH 09/63] Fix tests for missing container reappearing --- subcommand/health-sync/command_test.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index 6f68f1b3..2f5c43ec 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -381,7 +381,8 @@ func TestRun(t *testing.T) { // then the service check should be critical. if len(c.healthSyncContainers) > 1 { for containerName := range c.healthSyncContainers { - if c.healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy { + if c.healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy && + c.healthSyncContainers[containerName].missing == false { expCheck.Status = api.HealthCritical break } @@ -446,15 +447,16 @@ func TestRun(t *testing.T) { checkID := constructCheckID(makeServiceID(serviceName, taskID), name) if expCheck.CheckID == checkID { expCheck.Status = ecsHealthToConsulHealth(hsc.status) - found = true if len(c.healthSyncContainers) > 1 { for containerName := range c.healthSyncContainers { - if c.healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy { + if c.healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy && + c.shouldMissingContainersReappear == false { expCheck.Status = api.HealthCritical break } } } + found = true break } } From 77a6e4144b48a030ec7e070254304199eab7c308 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Mon, 9 Dec 2024 20:17:12 +0530 Subject: [PATCH 10/63] Update command_test.go --- subcommand/health-sync/command_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index 2f5c43ec..a672f1cb 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -402,7 +402,7 @@ func TestRun(t *testing.T) { } } } - expectedProxyCheck.Status = api.HealthCritical + expectedProxyCheck.Status = api.HealthPassing if c.missingDataplaneContainer { expectedProxyCheck.Status = api.HealthCritical } From 8712ba56a3e7cb0758866d0e93821ea660bf6e1a Mon Sep 17 00:00:00 2001 From: Abhishek Date: Mon, 9 Dec 2024 20:32:47 +0530 Subject: [PATCH 11/63] Update command_test.go --- subcommand/health-sync/command_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index a672f1cb..62943b15 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -129,7 +129,8 @@ func TestRun(t *testing.T) { status: ecs.HealthStatusHealthy, }, "container-2": { - status: ecs.HealthStatusUnhealthy, + missing: false, + status: ecs.HealthStatusUnhealthy, }, }, }, From 3831a8af3a78295afff6b22028fda34ca1c3d5d6 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Mon, 9 Dec 2024 20:37:26 +0530 Subject: [PATCH 12/63] Update command_test.go --- subcommand/health-sync/command_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index 62943b15..f908df83 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -149,10 +149,12 @@ func TestRun(t *testing.T) { "two unhealthy health sync containers": { healthSyncContainers: map[string]healthSyncContainerMetaData{ "container-1": { - status: ecs.HealthStatusUnhealthy, + missing: false, + status: ecs.HealthStatusUnhealthy, }, "container-2": { - status: ecs.HealthStatusUnhealthy, + missing: false, + status: ecs.HealthStatusUnhealthy, }, }, }, From 5f4786fb52b2d85240eef631f6b9c0db54adf9d4 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Mon, 9 Dec 2024 20:40:16 +0530 Subject: [PATCH 13/63] Update command_test.go --- subcommand/health-sync/command_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index f908df83..63b71fdc 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -126,7 +126,8 @@ func TestRun(t *testing.T) { "one healthy and one unhealthy health sync containers": { healthSyncContainers: map[string]healthSyncContainerMetaData{ "container-1": { - status: ecs.HealthStatusHealthy, + missing: false, + status: ecs.HealthStatusHealthy, }, "container-2": { missing: false, From 0e1efb97c767acfdd5a1b26adcb024fb5f38333b Mon Sep 17 00:00:00 2001 From: Abhishek Date: Mon, 9 Dec 2024 21:00:22 +0530 Subject: [PATCH 14/63] Update command_test.go --- subcommand/health-sync/command_test.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index 63b71fdc..b461ec81 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -385,8 +385,7 @@ func TestRun(t *testing.T) { // then the service check should be critical. if len(c.healthSyncContainers) > 1 { for containerName := range c.healthSyncContainers { - if c.healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy && - c.healthSyncContainers[containerName].missing == false { + if c.healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy && hsc.missing == false { expCheck.Status = api.HealthCritical break } @@ -466,7 +465,7 @@ func TestRun(t *testing.T) { } if !found { - expCheck.Status = api.HealthPassing + expCheck.Status = api.HealthCritical } } expectedProxyCheck.Status = api.HealthPassing From ada2b3b2f652e3017a019e7f40cf1a569d50ad30 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Mon, 9 Dec 2024 21:14:47 +0530 Subject: [PATCH 15/63] Update command_test.go --- subcommand/health-sync/command_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index b461ec81..5218280c 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -401,7 +401,7 @@ func TestRun(t *testing.T) { if c.missingDataplaneContainer { expCheck.Status = api.HealthCritical } else { - expCheck.Status = api.HealthPassing + expCheck.Status = api.HealthCritical } } } From 6f4c09afcf40d0fcc0f5632fb3bf965895b8efc2 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Mon, 9 Dec 2024 21:20:11 +0530 Subject: [PATCH 16/63] Update command_test.go --- subcommand/health-sync/command_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index 5218280c..b461ec81 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -401,7 +401,7 @@ func TestRun(t *testing.T) { if c.missingDataplaneContainer { expCheck.Status = api.HealthCritical } else { - expCheck.Status = api.HealthCritical + expCheck.Status = api.HealthPassing } } } From 32fa3dc4563cc59efd840a4edd2a93b58e5fd92e Mon Sep 17 00:00:00 2001 From: Abhishek Date: Mon, 9 Dec 2024 21:31:51 +0530 Subject: [PATCH 17/63] Update command_test.go --- subcommand/health-sync/command_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index b461ec81..1399f44b 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -385,7 +385,7 @@ func TestRun(t *testing.T) { // then the service check should be critical. if len(c.healthSyncContainers) > 1 { for containerName := range c.healthSyncContainers { - if c.healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy && hsc.missing == false { + if c.healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy { expCheck.Status = api.HealthCritical break } From 578329a4a639951a1da5082ef5dd4b8a5f9bd29a Mon Sep 17 00:00:00 2001 From: Abhishek Date: Mon, 9 Dec 2024 21:41:26 +0530 Subject: [PATCH 18/63] Update command_test.go --- subcommand/health-sync/command_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index 1399f44b..03a64f27 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -465,7 +465,7 @@ func TestRun(t *testing.T) { } if !found { - expCheck.Status = api.HealthCritical + expCheck.Status = api.HealthPassing } } expectedProxyCheck.Status = api.HealthPassing From 7f4b3052ef72b76b75d9768b572e9951f2e1fb52 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Mon, 9 Dec 2024 21:53:13 +0530 Subject: [PATCH 19/63] Update command_test.go --- subcommand/health-sync/command_test.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index 03a64f27..dda8be67 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -450,15 +450,6 @@ func TestRun(t *testing.T) { checkID := constructCheckID(makeServiceID(serviceName, taskID), name) if expCheck.CheckID == checkID { expCheck.Status = ecsHealthToConsulHealth(hsc.status) - if len(c.healthSyncContainers) > 1 { - for containerName := range c.healthSyncContainers { - if c.healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy && - c.shouldMissingContainersReappear == false { - expCheck.Status = api.HealthCritical - break - } - } - } found = true break } From e8139f26027569b85e181a48414fbba8c30e6a6c Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 10 Dec 2024 12:06:05 +0530 Subject: [PATCH 20/63] Update command_test.go --- subcommand/health-sync/command_test.go | 91 ++++++++++++++------------ 1 file changed, 50 insertions(+), 41 deletions(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index dda8be67..76778f44 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -431,47 +431,56 @@ func TestRun(t *testing.T) { // This block makes a missing reappear in the task meta response and // tests if the healthy-sync process is able to sync back the status of the // container to Consul servers. - if c.shouldMissingContainersReappear { - // Mark all containers as non missing - c.missingDataplaneContainer = false - for _, hsc := range c.healthSyncContainers { - hsc.missing = false - } - - // Add the containers data into task meta response - taskMetaRespStr = injectContainersIntoTaskMetaResponse(t, taskMetadataResponse, c.missingDataplaneContainer, c.healthSyncContainers) - currentTaskMetaResp.Store(taskMetaRespStr) - - // Align the expectations for checks according to the - // state of health sync containers - for _, expCheck := range expectedSvcChecks { - found := false - for name, hsc := range c.healthSyncContainers { - checkID := constructCheckID(makeServiceID(serviceName, taskID), name) - if expCheck.CheckID == checkID { - expCheck.Status = ecsHealthToConsulHealth(hsc.status) - found = true - break - } - } - - if !found { - expCheck.Status = api.HealthPassing - } - } - expectedProxyCheck.Status = api.HealthPassing - assertHealthChecks(t, consulClient, expectedSvcChecks, expectedProxyCheck) - } - - // Send SIGTERM and verify the status of checks - signalSIGTERM(t) - - for _, expCheck := range expectedSvcChecks { - expCheck.Status = api.HealthCritical - } - expectedProxyCheck.Status = api.HealthCritical - - assertHealthChecks(t, consulClient, expectedSvcChecks, expectedProxyCheck) + //if c.shouldMissingContainersReappear { + // // Mark all containers as non missing + // c.missingDataplaneContainer = false + // for _, hsc := range c.healthSyncContainers { + // hsc.missing = false + // } + // + // // Add the containers data into task meta response + // taskMetaRespStr = injectContainersIntoTaskMetaResponse(t, taskMetadataResponse, c.missingDataplaneContainer, c.healthSyncContainers) + // currentTaskMetaResp.Store(taskMetaRespStr) + // + // // Align the expectations for checks according to the + // // state of health sync containers + // for _, expCheck := range expectedSvcChecks { + // found := false + // for name, hsc := range c.healthSyncContainers { + // checkID := constructCheckID(makeServiceID(serviceName, taskID), name) + // if expCheck.CheckID == checkID { + // expCheck.Status = ecsHealthToConsulHealth(hsc.status) + // //if len(c.healthSyncContainers) > 1 { + // // for containerName := range c.healthSyncContainers { + // // if c.healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy && + // // c.shouldMissingContainersReappear == false { + // // expCheck.Status = api.HealthCritical + // // break + // // } + // // } + // //} + // found = true + // break + // } + // } + // + // if !found { + // expCheck.Status = api.HealthPassing + // } + // } + // expectedProxyCheck.Status = api.HealthPassing + // assertHealthChecks(t, consulClient, expectedSvcChecks, expectedProxyCheck) + //} + // + //// Send SIGTERM and verify the status of checks + //signalSIGTERM(t) + // + //for _, expCheck := range expectedSvcChecks { + // expCheck.Status = api.HealthCritical + //} + //expectedProxyCheck.Status = api.HealthCritical + // + //assertHealthChecks(t, consulClient, expectedSvcChecks, expectedProxyCheck) // Stop dataplane container manually because // health-sync waits for it before deregistering From d8a55ee8245000e2053d8a4137cc54008bda6184 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 10 Dec 2024 12:15:14 +0530 Subject: [PATCH 21/63] Update command_test.go --- subcommand/health-sync/command_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index 76778f44..f816fd6c 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -489,7 +489,7 @@ func TestRun(t *testing.T) { require.NoError(t, err) currentTaskMetaResp.Store(taskMetaRespStr) - assertServiceAndProxyInstances(t, consulClient, serviceName, proxyServiceName, 0, apiQueryOptions) + //assertServiceAndProxyInstances(t, consulClient, serviceName, proxyServiceName, 0, apiQueryOptions) if c.consulLogin.Enabled { assertConsulLogout(t, cfg, consulEcsConfig.BootstrapDir) } From 2e718fc489282d4ce7f0965ec9c578dedacf2374 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 10 Dec 2024 12:20:42 +0530 Subject: [PATCH 22/63] Update command_test.go --- subcommand/health-sync/command_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index f816fd6c..92b329bc 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -472,8 +472,8 @@ func TestRun(t *testing.T) { // assertHealthChecks(t, consulClient, expectedSvcChecks, expectedProxyCheck) //} // - //// Send SIGTERM and verify the status of checks - //signalSIGTERM(t) + // Send SIGTERM and verify the status of checks + signalSIGTERM(t) // //for _, expCheck := range expectedSvcChecks { // expCheck.Status = api.HealthCritical From 412c16bd084e74dfb101534d004dc25dcf5ab378 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 10 Dec 2024 13:10:47 +0530 Subject: [PATCH 23/63] Update command_test.go --- subcommand/health-sync/command_test.go | 104 +++++++++++++------------ 1 file changed, 54 insertions(+), 50 deletions(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index 92b329bc..a13a0697 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -7,6 +7,7 @@ import ( "context" "encoding/json" "fmt" + "log" "os" "path/filepath" "sync/atomic" @@ -385,7 +386,8 @@ func TestRun(t *testing.T) { // then the service check should be critical. if len(c.healthSyncContainers) > 1 { for containerName := range c.healthSyncContainers { - if c.healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy { + if c.healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy && + containerName != config.ConsulDataplaneContainerName { expCheck.Status = api.HealthCritical break } @@ -431,56 +433,57 @@ func TestRun(t *testing.T) { // This block makes a missing reappear in the task meta response and // tests if the healthy-sync process is able to sync back the status of the // container to Consul servers. - //if c.shouldMissingContainersReappear { - // // Mark all containers as non missing - // c.missingDataplaneContainer = false - // for _, hsc := range c.healthSyncContainers { - // hsc.missing = false - // } - // - // // Add the containers data into task meta response - // taskMetaRespStr = injectContainersIntoTaskMetaResponse(t, taskMetadataResponse, c.missingDataplaneContainer, c.healthSyncContainers) - // currentTaskMetaResp.Store(taskMetaRespStr) - // - // // Align the expectations for checks according to the - // // state of health sync containers - // for _, expCheck := range expectedSvcChecks { - // found := false - // for name, hsc := range c.healthSyncContainers { - // checkID := constructCheckID(makeServiceID(serviceName, taskID), name) - // if expCheck.CheckID == checkID { - // expCheck.Status = ecsHealthToConsulHealth(hsc.status) - // //if len(c.healthSyncContainers) > 1 { - // // for containerName := range c.healthSyncContainers { - // // if c.healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy && - // // c.shouldMissingContainersReappear == false { - // // expCheck.Status = api.HealthCritical - // // break - // // } - // // } - // //} - // found = true - // break - // } - // } - // - // if !found { - // expCheck.Status = api.HealthPassing - // } - // } - // expectedProxyCheck.Status = api.HealthPassing - // assertHealthChecks(t, consulClient, expectedSvcChecks, expectedProxyCheck) - //} - // + if c.shouldMissingContainersReappear { + // Mark all containers as non missing + c.missingDataplaneContainer = false + for _, hsc := range c.healthSyncContainers { + hsc.missing = false + } + + // Add the containers data into task meta response + taskMetaRespStr = injectContainersIntoTaskMetaResponse(t, taskMetadataResponse, c.missingDataplaneContainer, c.healthSyncContainers) + currentTaskMetaResp.Store(taskMetaRespStr) + + // Align the expectations for checks according to the + // state of health sync containers + for _, expCheck := range expectedSvcChecks { + found := false + for name, hsc := range c.healthSyncContainers { + checkID := constructCheckID(makeServiceID(serviceName, taskID), name) + if expCheck.CheckID == checkID { + expCheck.Status = ecsHealthToConsulHealth(hsc.status) + if len(c.healthSyncContainers) > 1 { + for containerName := range c.healthSyncContainers { + if c.healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy && + containerName != config.ConsulDataplaneContainerName && + c.shouldMissingContainersReappear == false { + expCheck.Status = api.HealthCritical + break + } + } + } + found = true + break + } + } + + if !found { + expCheck.Status = api.HealthPassing + } + } + expectedProxyCheck.Status = api.HealthPassing + assertHealthChecks(t, consulClient, expectedSvcChecks, expectedProxyCheck) + } + // Send SIGTERM and verify the status of checks signalSIGTERM(t) - // - //for _, expCheck := range expectedSvcChecks { - // expCheck.Status = api.HealthCritical - //} - //expectedProxyCheck.Status = api.HealthCritical - // - //assertHealthChecks(t, consulClient, expectedSvcChecks, expectedProxyCheck) + + for _, expCheck := range expectedSvcChecks { + expCheck.Status = api.HealthCritical + } + expectedProxyCheck.Status = api.HealthCritical + + assertHealthChecks(t, consulClient, expectedSvcChecks, expectedProxyCheck) // Stop dataplane container manually because // health-sync waits for it before deregistering @@ -489,7 +492,7 @@ func TestRun(t *testing.T) { require.NoError(t, err) currentTaskMetaResp.Store(taskMetaRespStr) - //assertServiceAndProxyInstances(t, consulClient, serviceName, proxyServiceName, 0, apiQueryOptions) + assertServiceAndProxyInstances(t, consulClient, serviceName, proxyServiceName, 0, apiQueryOptions) if c.consulLogin.Enabled { assertConsulLogout(t, cfg, consulEcsConfig.BootstrapDir) } @@ -847,6 +850,7 @@ func assertHealthChecks(t *testing.T, consulClient *api.Client, expectedServiceC require.NoError(r, err) for _, check := range checks { + log.Printf("checkName:%s , expCheck:%s , Actual Status:%s \n", expCheck.Name, expCheck.Status, check.Status) require.Equal(r, expCheck.Status, check.Status) } } From 866725b4014d65689c52bf06cb174545a2a80f16 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 10 Dec 2024 13:23:26 +0530 Subject: [PATCH 24/63] Update command_test.go --- subcommand/health-sync/command_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index a13a0697..84c3c5ed 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -386,8 +386,7 @@ func TestRun(t *testing.T) { // then the service check should be critical. if len(c.healthSyncContainers) > 1 { for containerName := range c.healthSyncContainers { - if c.healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy && - containerName != config.ConsulDataplaneContainerName { + if c.healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy { expCheck.Status = api.HealthCritical break } From 5da90703bb3453d652358c7f6867ef574fabf285 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 10 Dec 2024 13:55:03 +0530 Subject: [PATCH 25/63] Update command_test.go --- subcommand/health-sync/command_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index 84c3c5ed..25efa4df 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -385,7 +385,9 @@ func TestRun(t *testing.T) { // If there are multiple health sync containers and one of them is unhealthy // then the service check should be critical. if len(c.healthSyncContainers) > 1 { + log.Printf("Checking for unhealthy containers: %s \n", name) for containerName := range c.healthSyncContainers { + log.Printf("Container Name: %s, ActualStatus:%s \n", containerName, c.healthSyncContainers[containerName].status) if c.healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy { expCheck.Status = api.HealthCritical break From 0a1535440e705d8a3f6c867748e26a4db438e158 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 10 Dec 2024 14:06:57 +0530 Subject: [PATCH 26/63] Update command_test.go --- subcommand/health-sync/command_test.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index 25efa4df..af100fd0 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -815,7 +815,18 @@ func constructTaskMetaResponseString(resp *awsutil.ECSTaskMeta) (string, error) func injectContainersIntoTaskMetaResponse(t *testing.T, taskMetadataResponse *awsutil.ECSTaskMeta, missingDataplaneContainer bool, healthSyncContainers map[string]healthSyncContainerMetaData) string { var taskMetaContainersResponse []awsutil.ECSTaskMetaContainer if !missingDataplaneContainer { - taskMetaContainersResponse = append(taskMetaContainersResponse, constructContainerResponse(config.ConsulDataplaneContainerName, ecs.HealthStatusHealthy)) + dataplaneContainerStatus := ecs.HealthStatusHealthy + if len(healthSyncContainers) > 1 { + log.Printf("Setting dataplane container status: %s \n", config.ConsulDataplaneContainerName) + for containerName := range healthSyncContainers { + log.Printf("Container Name: %s, ActualStatus:%s \n", containerName, healthSyncContainers[containerName].status) + if healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy { + dataplaneContainerStatus = ecs.HealthStatusUnhealthy + break + } + } + } + taskMetaContainersResponse = append(taskMetaContainersResponse, constructContainerResponse(config.ConsulDataplaneContainerName, dataplaneContainerStatus)) } for name, hsc := range healthSyncContainers { From 205c1526c8ac4d9e961ca905281a81f9541a590a Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 10 Dec 2024 14:14:13 +0530 Subject: [PATCH 27/63] Update command_test.go --- subcommand/health-sync/command_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index af100fd0..0da81a13 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -373,6 +373,7 @@ func TestRun(t *testing.T) { // Align the expectations for checks according to the // state of health sync containers + log.Printf("Expected Svc Checks: %v \n", expectedSvcChecks) for _, expCheck := range expectedSvcChecks { found := false for name, hsc := range c.healthSyncContainers { @@ -839,6 +840,7 @@ func injectContainersIntoTaskMetaResponse(t *testing.T, taskMetadataResponse *aw taskMetadataResponse.Containers = taskMetaContainersResponse taskMetaRespStr, err := constructTaskMetaResponseString(taskMetadataResponse) require.NoError(t, err) + log.Printf("TaskMetaResponseStr: %s, \n", taskMetaRespStr) return taskMetaRespStr } From d874e9327b5ef770a6b16ebb2f0d07b09f26303f Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 10 Dec 2024 14:21:07 +0530 Subject: [PATCH 28/63] Update command_test.go --- subcommand/health-sync/command_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index 0da81a13..63a6b1ab 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -373,7 +373,10 @@ func TestRun(t *testing.T) { // Align the expectations for checks according to the // state of health sync containers - log.Printf("Expected Svc Checks: %v \n", expectedSvcChecks) + log.Printf("Expected Svc Checks: %+v\n", expectedSvcChecks) + for _, check := range expectedSvcChecks { + log.Printf("Check Name: %s, Status: %s\n", check.Name, check.Status) + } for _, expCheck := range expectedSvcChecks { found := false for name, hsc := range c.healthSyncContainers { From 02c0e76ae96d1bc0975ffc9be36f561e66b666f6 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 10 Dec 2024 14:36:47 +0530 Subject: [PATCH 29/63] Update command_test.go --- subcommand/health-sync/command_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index 63a6b1ab..c7fecd70 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -375,12 +375,14 @@ func TestRun(t *testing.T) { // state of health sync containers log.Printf("Expected Svc Checks: %+v\n", expectedSvcChecks) for _, check := range expectedSvcChecks { - log.Printf("Check Name: %s, Status: %s\n", check.Name, check.Status) + log.Printf("Check Name: %s, Status: %s, ServiceName: %s, CheckId: %s\n", check.Name, check.Status, check.ServiceName, check.CheckID) } for _, expCheck := range expectedSvcChecks { found := false for name, hsc := range c.healthSyncContainers { + checkID := constructCheckID(makeServiceID(serviceName, taskID), name) + log.Printf("Checking for container: %s, hsc %s, CheckId: %s\n", name, hsc, checkID) if expCheck.CheckID == checkID { if hsc.missing { expCheck.Status = api.HealthCritical @@ -389,7 +391,6 @@ func TestRun(t *testing.T) { // If there are multiple health sync containers and one of them is unhealthy // then the service check should be critical. if len(c.healthSyncContainers) > 1 { - log.Printf("Checking for unhealthy containers: %s \n", name) for containerName := range c.healthSyncContainers { log.Printf("Container Name: %s, ActualStatus:%s \n", containerName, c.healthSyncContainers[containerName].status) if c.healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy { From edd914b836e4d150c9d383eb99c8a83103ee2bb3 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 10 Dec 2024 14:40:40 +0530 Subject: [PATCH 30/63] Update command_test.go --- subcommand/health-sync/command_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index c7fecd70..e13bcfb4 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -382,7 +382,7 @@ func TestRun(t *testing.T) { for name, hsc := range c.healthSyncContainers { checkID := constructCheckID(makeServiceID(serviceName, taskID), name) - log.Printf("Checking for container: %s, hsc %s, CheckId: %s\n", name, hsc, checkID) + log.Printf("Checking for container: %s, hsc %s, CheckId: %s\n", name, hsc.status, checkID) if expCheck.CheckID == checkID { if hsc.missing { expCheck.Status = api.HealthCritical From ca66c5ab1d6d349ad2a3bcd7ae8fc0de8fab265d Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 10 Dec 2024 14:52:04 +0530 Subject: [PATCH 31/63] Update command_test.go --- subcommand/health-sync/command_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index e13bcfb4..bf0899d4 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -377,10 +377,10 @@ func TestRun(t *testing.T) { for _, check := range expectedSvcChecks { log.Printf("Check Name: %s, Status: %s, ServiceName: %s, CheckId: %s\n", check.Name, check.Status, check.ServiceName, check.CheckID) } + markDataplaneContainerUnhealthy := false for _, expCheck := range expectedSvcChecks { found := false for name, hsc := range c.healthSyncContainers { - checkID := constructCheckID(makeServiceID(serviceName, taskID), name) log.Printf("Checking for container: %s, hsc %s, CheckId: %s\n", name, hsc.status, checkID) if expCheck.CheckID == checkID { @@ -395,6 +395,7 @@ func TestRun(t *testing.T) { log.Printf("Container Name: %s, ActualStatus:%s \n", containerName, c.healthSyncContainers[containerName].status) if c.healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy { expCheck.Status = api.HealthCritical + markDataplaneContainerUnhealthy = true break } } @@ -406,7 +407,7 @@ func TestRun(t *testing.T) { } if !found { - if c.missingDataplaneContainer { + if c.missingDataplaneContainer || markDataplaneContainerUnhealthy { expCheck.Status = api.HealthCritical } else { expCheck.Status = api.HealthPassing From dacfc8e5c80d77aba5deebac3a8f5d5f10b156fc Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 10 Dec 2024 15:17:06 +0530 Subject: [PATCH 32/63] Update command_test.go --- subcommand/health-sync/command_test.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index bf0899d4..74c3970e 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -390,16 +390,15 @@ func TestRun(t *testing.T) { expCheck.Status = ecsHealthToConsulHealth(hsc.status) // If there are multiple health sync containers and one of them is unhealthy // then the service check should be critical. - if len(c.healthSyncContainers) > 1 { - for containerName := range c.healthSyncContainers { - log.Printf("Container Name: %s, ActualStatus:%s \n", containerName, c.healthSyncContainers[containerName].status) - if c.healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy { - expCheck.Status = api.HealthCritical - markDataplaneContainerUnhealthy = true - break - } + for containerName := range c.healthSyncContainers { + log.Printf("Container Name: %s, ActualStatus:%s \n", containerName, c.healthSyncContainers[containerName].status) + if c.healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy { + expCheck.Status = api.HealthCritical + markDataplaneContainerUnhealthy = true + break } } + } found = true break From deddcdb56f71009a705dd059f2894d198c9e4f33 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 10 Dec 2024 15:27:19 +0530 Subject: [PATCH 33/63] Update command_test.go --- subcommand/health-sync/command_test.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index 74c3970e..b950ecaa 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -391,9 +391,9 @@ func TestRun(t *testing.T) { // If there are multiple health sync containers and one of them is unhealthy // then the service check should be critical. for containerName := range c.healthSyncContainers { - log.Printf("Container Name: %s, ActualStatus:%s \n", containerName, c.healthSyncContainers[containerName].status) if c.healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy { expCheck.Status = api.HealthCritical + log.Printf("Marking the datplane container unhealthy due to :%s \n", containerName) markDataplaneContainerUnhealthy = true break } @@ -407,13 +407,19 @@ func TestRun(t *testing.T) { if !found { if c.missingDataplaneContainer || markDataplaneContainerUnhealthy { + expCheck.Status = api.HealthCritical + } else { expCheck.Status = api.HealthPassing } + if markDataplaneContainerUnhealthy { + log.Printf("Marking expCheck for dataplane container :%s \n", expCheck.Status) + } } } expectedProxyCheck.Status = api.HealthPassing + log.Printf("ExpectedProxyCheck Name: %s and expCheck :%s \n", expectedProxyCheck.Name, expectedProxyCheck.Status) if c.missingDataplaneContainer { expectedProxyCheck.Status = api.HealthCritical } From abf7975d4860d7942b462cfb9372df51b0fae627 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 10 Dec 2024 15:34:20 +0530 Subject: [PATCH 34/63] Update command_test.go --- subcommand/health-sync/command_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index b950ecaa..ff5589a4 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -418,7 +418,11 @@ func TestRun(t *testing.T) { } } } - expectedProxyCheck.Status = api.HealthPassing + if markDataplaneContainerUnhealthy { + expectedProxyCheck.Status = api.HealthCritical + } else { + expectedProxyCheck.Status = api.HealthPassing + } log.Printf("ExpectedProxyCheck Name: %s and expCheck :%s \n", expectedProxyCheck.Name, expectedProxyCheck.Status) if c.missingDataplaneContainer { expectedProxyCheck.Status = api.HealthCritical @@ -884,6 +888,7 @@ func assertHealthChecks(t *testing.T, consulClient *api.Client, expectedServiceC checks, _, err := consulClient.Health().Checks(expectedProxyCheck.ServiceName, &api.QueryOptions{Filter: filter, Namespace: expectedProxyCheck.Namespace, Partition: expectedProxyCheck.Partition}) require.NoError(r, err) require.Equal(r, 1, len(checks)) + log.Printf("ProxyCheckName:%s , expProxyCheck:%s , Actual procy Status:%s \n", expectedProxyCheck.Name, expectedProxyCheck.Status, checks[0].Status) require.Equal(r, expectedProxyCheck.Status, checks[0].Status) }) } From 1cccdbf68316c792cd6166b4baa7c4a7b2cd650a Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 10 Dec 2024 15:44:53 +0530 Subject: [PATCH 35/63] Update command_test.go --- subcommand/health-sync/command_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index ff5589a4..7920557f 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -386,6 +386,7 @@ func TestRun(t *testing.T) { if expCheck.CheckID == checkID { if hsc.missing { expCheck.Status = api.HealthCritical + markDataplaneContainerUnhealthy = true } else { expCheck.Status = ecsHealthToConsulHealth(hsc.status) // If there are multiple health sync containers and one of them is unhealthy @@ -407,9 +408,7 @@ func TestRun(t *testing.T) { if !found { if c.missingDataplaneContainer || markDataplaneContainerUnhealthy { - expCheck.Status = api.HealthCritical - } else { expCheck.Status = api.HealthPassing } From 685287787fc8c70560b71bfd39a3e7225ad1faca Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 10 Dec 2024 15:51:02 +0530 Subject: [PATCH 36/63] Update command_test.go --- subcommand/health-sync/command_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index 7920557f..6a107126 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -151,12 +151,10 @@ func TestRun(t *testing.T) { "two unhealthy health sync containers": { healthSyncContainers: map[string]healthSyncContainerMetaData{ "container-1": { - missing: false, - status: ecs.HealthStatusUnhealthy, + status: ecs.HealthStatusUnhealthy, }, "container-2": { - missing: false, - status: ecs.HealthStatusUnhealthy, + status: ecs.HealthStatusUnhealthy, }, }, }, @@ -407,11 +405,13 @@ func TestRun(t *testing.T) { } if !found { + log.Printf("BEFORE: Updating dataplane container with Status markDataplaneContainerUnhealthy :%s and expCheck.Status %s\n", markDataplaneContainerUnhealthy, expCheck.Status) if c.missingDataplaneContainer || markDataplaneContainerUnhealthy { expCheck.Status = api.HealthCritical } else { expCheck.Status = api.HealthPassing } + log.Printf("AFTER: Updating dataplane container with Status markDataplaneContainerUnhealthy :%s and expCheck.Status %s\n", markDataplaneContainerUnhealthy, expCheck.Status) if markDataplaneContainerUnhealthy { log.Printf("Marking expCheck for dataplane container :%s \n", expCheck.Status) } From 12a1b23f6e87bc5459bbd4fde7311a6d0a945790 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 10 Dec 2024 15:53:36 +0530 Subject: [PATCH 37/63] Update command_test.go --- subcommand/health-sync/command_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index 6a107126..92f4106f 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -405,13 +405,13 @@ func TestRun(t *testing.T) { } if !found { - log.Printf("BEFORE: Updating dataplane container with Status markDataplaneContainerUnhealthy :%s and expCheck.Status %s\n", markDataplaneContainerUnhealthy, expCheck.Status) + log.Printf("BEFORE: Updating dataplane container with Status markDataplaneContainerUnhealthy :%t and expCheck.Status %s\n", markDataplaneContainerUnhealthy, expCheck.Status) if c.missingDataplaneContainer || markDataplaneContainerUnhealthy { expCheck.Status = api.HealthCritical } else { expCheck.Status = api.HealthPassing } - log.Printf("AFTER: Updating dataplane container with Status markDataplaneContainerUnhealthy :%s and expCheck.Status %s\n", markDataplaneContainerUnhealthy, expCheck.Status) + log.Printf("AFTER: Updating dataplane container with Status markDataplaneContainerUnhealthy :%t and expCheck.Status %s\n", markDataplaneContainerUnhealthy, expCheck.Status) if markDataplaneContainerUnhealthy { log.Printf("Marking expCheck for dataplane container :%s \n", expCheck.Status) } From aacd44c975c2f31e195162654ceb512921a6eca6 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 10 Dec 2024 17:10:27 +0530 Subject: [PATCH 38/63] Update command_test.go --- subcommand/health-sync/command_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index 92f4106f..00d23679 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -408,8 +408,6 @@ func TestRun(t *testing.T) { log.Printf("BEFORE: Updating dataplane container with Status markDataplaneContainerUnhealthy :%t and expCheck.Status %s\n", markDataplaneContainerUnhealthy, expCheck.Status) if c.missingDataplaneContainer || markDataplaneContainerUnhealthy { expCheck.Status = api.HealthCritical - } else { - expCheck.Status = api.HealthPassing } log.Printf("AFTER: Updating dataplane container with Status markDataplaneContainerUnhealthy :%t and expCheck.Status %s\n", markDataplaneContainerUnhealthy, expCheck.Status) if markDataplaneContainerUnhealthy { From e7a137d677155cddd8944de79bc06331dae937fc Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 10 Dec 2024 17:14:49 +0530 Subject: [PATCH 39/63] Update command_test.go --- subcommand/health-sync/command_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index 00d23679..4c899022 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -403,7 +403,7 @@ func TestRun(t *testing.T) { break } } - + log.Printf("dataplane container for expCheck: %s, markDataplaneContainerUnhealthy :%t , found: %t\n", expCheck.CheckID, markDataplaneContainerUnhealthy, found) if !found { log.Printf("BEFORE: Updating dataplane container with Status markDataplaneContainerUnhealthy :%t and expCheck.Status %s\n", markDataplaneContainerUnhealthy, expCheck.Status) if c.missingDataplaneContainer || markDataplaneContainerUnhealthy { From aad3768f5fccfce8d2db447c88a6846857ba9639 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 10 Dec 2024 23:12:43 +0530 Subject: [PATCH 40/63] Update command_test.go --- subcommand/health-sync/command_test.go | 53 ++++++++++---------------- 1 file changed, 21 insertions(+), 32 deletions(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index 4c899022..ba1a858d 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -114,16 +114,16 @@ func TestRun(t *testing.T) { }, consulLogin: consulLoginCfg, }, - "two healthy health sync containers": { - healthSyncContainers: map[string]healthSyncContainerMetaData{ - "container-1": { - status: ecs.HealthStatusHealthy, - }, - "container-2": { - status: ecs.HealthStatusHealthy, - }, - }, - }, + //"two healthy health sync containers": { + // healthSyncContainers: map[string]healthSyncContainerMetaData{ + // "container-1": { + // status: ecs.HealthStatusHealthy, + // }, + // "container-2": { + // status: ecs.HealthStatusHealthy, + // }, + // }, + //}, "one healthy and one unhealthy health sync containers": { healthSyncContainers: map[string]healthSyncContainerMetaData{ "container-1": { @@ -148,16 +148,16 @@ func TestRun(t *testing.T) { }, consulLogin: consulLoginCfg, }, - "two unhealthy health sync containers": { - healthSyncContainers: map[string]healthSyncContainerMetaData{ - "container-1": { - status: ecs.HealthStatusUnhealthy, - }, - "container-2": { - status: ecs.HealthStatusUnhealthy, - }, - }, - }, + //"two unhealthy health sync containers": { + // healthSyncContainers: map[string]healthSyncContainerMetaData{ + // "container-1": { + // status: ecs.HealthStatusUnhealthy, + // }, + // "container-2": { + // status: ecs.HealthStatusUnhealthy, + // }, + // }, + //}, "missing dataplane container": { missingDataplaneContainer: true, }, @@ -827,18 +827,7 @@ func constructTaskMetaResponseString(resp *awsutil.ECSTaskMeta) (string, error) func injectContainersIntoTaskMetaResponse(t *testing.T, taskMetadataResponse *awsutil.ECSTaskMeta, missingDataplaneContainer bool, healthSyncContainers map[string]healthSyncContainerMetaData) string { var taskMetaContainersResponse []awsutil.ECSTaskMetaContainer if !missingDataplaneContainer { - dataplaneContainerStatus := ecs.HealthStatusHealthy - if len(healthSyncContainers) > 1 { - log.Printf("Setting dataplane container status: %s \n", config.ConsulDataplaneContainerName) - for containerName := range healthSyncContainers { - log.Printf("Container Name: %s, ActualStatus:%s \n", containerName, healthSyncContainers[containerName].status) - if healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy { - dataplaneContainerStatus = ecs.HealthStatusUnhealthy - break - } - } - } - taskMetaContainersResponse = append(taskMetaContainersResponse, constructContainerResponse(config.ConsulDataplaneContainerName, dataplaneContainerStatus)) + taskMetaContainersResponse = append(taskMetaContainersResponse, constructContainerResponse(config.ConsulDataplaneContainerName, ecs.HealthStatusHealthy)) } for name, hsc := range healthSyncContainers { From 1f5eb36fb3954fa83a3e33bd29fe9a94b7274699 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 10 Dec 2024 23:17:18 +0530 Subject: [PATCH 41/63] Update command_test.go --- subcommand/health-sync/command_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index ba1a858d..f9cce9b6 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -106,14 +106,14 @@ func TestRun(t *testing.T) { shouldMissingContainersReappear bool }{ "no additional health sync containers": {}, - "one healthy health sync container": { - healthSyncContainers: map[string]healthSyncContainerMetaData{ - "container-1": { - status: ecs.HealthStatusHealthy, - }, - }, - consulLogin: consulLoginCfg, - }, + //"one healthy health sync container": { + // healthSyncContainers: map[string]healthSyncContainerMetaData{ + // "container-1": { + // status: ecs.HealthStatusHealthy, + // }, + // }, + // consulLogin: consulLoginCfg, + //}, //"two healthy health sync containers": { // healthSyncContainers: map[string]healthSyncContainerMetaData{ // "container-1": { From 88bd97d11d0c121cf48a031ae3ed9ed629991bde Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 10 Dec 2024 23:23:20 +0530 Subject: [PATCH 42/63] Update command_test.go --- subcommand/health-sync/command_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index f9cce9b6..bfa50e61 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -105,7 +105,7 @@ func TestRun(t *testing.T) { missingDataplaneContainer bool shouldMissingContainersReappear bool }{ - "no additional health sync containers": {}, + //"no additional health sync containers": {}, //"one healthy health sync container": { // healthSyncContainers: map[string]healthSyncContainerMetaData{ // "container-1": { From f3ceb6ccaf12424dfc3c9db46bae7c77c2d0295f Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 10 Dec 2024 23:48:56 +0530 Subject: [PATCH 43/63] Update command_test.go --- subcommand/health-sync/command_test.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index bfa50e61..847832a5 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -105,7 +105,7 @@ func TestRun(t *testing.T) { missingDataplaneContainer bool shouldMissingContainersReappear bool }{ - //"no additional health sync containers": {}, + "no additional health sync containers": {}, //"one healthy health sync container": { // healthSyncContainers: map[string]healthSyncContainerMetaData{ // "container-1": { @@ -384,6 +384,7 @@ func TestRun(t *testing.T) { if expCheck.CheckID == checkID { if hsc.missing { expCheck.Status = api.HealthCritical + log.Printf("Marking the datplane container unhealthy due to :%s \n", name) markDataplaneContainerUnhealthy = true } else { expCheck.Status = ecsHealthToConsulHealth(hsc.status) @@ -422,9 +423,11 @@ func TestRun(t *testing.T) { } log.Printf("ExpectedProxyCheck Name: %s and expCheck :%s \n", expectedProxyCheck.Name, expectedProxyCheck.Status) if c.missingDataplaneContainer { + log.Printf("Dataplane container is missing and marking proxy check Critical\n") expectedProxyCheck.Status = api.HealthCritical } + log.Printf("Asserting HEalth checks - 1") assertHealthChecks(t, consulClient, expectedSvcChecks, expectedProxyCheck) // Test server watch @@ -495,7 +498,7 @@ func TestRun(t *testing.T) { expCheck.Status = api.HealthCritical } expectedProxyCheck.Status = api.HealthCritical - + log.Printf("Asserting HEalth checks - 2") assertHealthChecks(t, consulClient, expectedSvcChecks, expectedProxyCheck) // Stop dataplane container manually because From 4b70a0e21a221ca57503d5327210a2222fdd7046 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Wed, 11 Dec 2024 00:17:23 +0530 Subject: [PATCH 44/63] Update command_test.go --- subcommand/health-sync/command_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index 847832a5..74f170cc 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -372,7 +372,7 @@ func TestRun(t *testing.T) { // Align the expectations for checks according to the // state of health sync containers log.Printf("Expected Svc Checks: %+v\n", expectedSvcChecks) - for _, check := range expectedSvcChecks { + for _, check := range append(expectedSvcChecks, expectedProxyCheck) { log.Printf("Check Name: %s, Status: %s, ServiceName: %s, CheckId: %s\n", check.Name, check.Status, check.ServiceName, check.CheckID) } markDataplaneContainerUnhealthy := false @@ -409,6 +409,8 @@ func TestRun(t *testing.T) { log.Printf("BEFORE: Updating dataplane container with Status markDataplaneContainerUnhealthy :%t and expCheck.Status %s\n", markDataplaneContainerUnhealthy, expCheck.Status) if c.missingDataplaneContainer || markDataplaneContainerUnhealthy { expCheck.Status = api.HealthCritical + } else if len(c.healthSyncContainers) == 0 { + expCheck.Status = api.HealthPassing } log.Printf("AFTER: Updating dataplane container with Status markDataplaneContainerUnhealthy :%t and expCheck.Status %s\n", markDataplaneContainerUnhealthy, expCheck.Status) if markDataplaneContainerUnhealthy { From 438db7b0be5b8e5278b9939108c1eea57d32b98d Mon Sep 17 00:00:00 2001 From: Abhishek Date: Wed, 11 Dec 2024 00:20:04 +0530 Subject: [PATCH 45/63] Update command_test.go --- subcommand/health-sync/command_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index 74f170cc..a64d32ba 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -106,14 +106,14 @@ func TestRun(t *testing.T) { shouldMissingContainersReappear bool }{ "no additional health sync containers": {}, - //"one healthy health sync container": { - // healthSyncContainers: map[string]healthSyncContainerMetaData{ - // "container-1": { - // status: ecs.HealthStatusHealthy, - // }, - // }, - // consulLogin: consulLoginCfg, - //}, + "one healthy health sync container": { + healthSyncContainers: map[string]healthSyncContainerMetaData{ + "container-1": { + status: ecs.HealthStatusHealthy, + }, + }, + consulLogin: consulLoginCfg, + }, //"two healthy health sync containers": { // healthSyncContainers: map[string]healthSyncContainerMetaData{ // "container-1": { From f57f3753f7305d5f357892e5788f87eb817b5af0 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Wed, 11 Dec 2024 00:27:27 +0530 Subject: [PATCH 46/63] Update command_test.go --- subcommand/health-sync/command_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index a64d32ba..0b9bc947 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -409,7 +409,7 @@ func TestRun(t *testing.T) { log.Printf("BEFORE: Updating dataplane container with Status markDataplaneContainerUnhealthy :%t and expCheck.Status %s\n", markDataplaneContainerUnhealthy, expCheck.Status) if c.missingDataplaneContainer || markDataplaneContainerUnhealthy { expCheck.Status = api.HealthCritical - } else if len(c.healthSyncContainers) == 0 { + } else if len(c.healthSyncContainers) == 0 || !markDataplaneContainerUnhealthy { expCheck.Status = api.HealthPassing } log.Printf("AFTER: Updating dataplane container with Status markDataplaneContainerUnhealthy :%t and expCheck.Status %s\n", markDataplaneContainerUnhealthy, expCheck.Status) From 8f547ff895e7aa5280961d66997418bd3c721ec7 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Wed, 11 Dec 2024 00:40:56 +0530 Subject: [PATCH 47/63] Update command_test.go --- subcommand/health-sync/command_test.go | 27 ++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index 0b9bc947..67aceb73 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -104,6 +104,7 @@ func TestRun(t *testing.T) { healthSyncContainers map[string]healthSyncContainerMetaData missingDataplaneContainer bool shouldMissingContainersReappear bool + expectedDataplaneHealthStatus string }{ "no additional health sync containers": {}, "one healthy health sync container": { @@ -146,7 +147,8 @@ func TestRun(t *testing.T) { status: ecs.HealthStatusUnhealthy, }, }, - consulLogin: consulLoginCfg, + expectedDataplaneHealthStatus: api.HealthPassing, + consulLogin: consulLoginCfg, }, //"two unhealthy health sync containers": { // healthSyncContainers: map[string]healthSyncContainerMetaData{ @@ -407,14 +409,19 @@ func TestRun(t *testing.T) { log.Printf("dataplane container for expCheck: %s, markDataplaneContainerUnhealthy :%t , found: %t\n", expCheck.CheckID, markDataplaneContainerUnhealthy, found) if !found { log.Printf("BEFORE: Updating dataplane container with Status markDataplaneContainerUnhealthy :%t and expCheck.Status %s\n", markDataplaneContainerUnhealthy, expCheck.Status) - if c.missingDataplaneContainer || markDataplaneContainerUnhealthy { - expCheck.Status = api.HealthCritical - } else if len(c.healthSyncContainers) == 0 || !markDataplaneContainerUnhealthy { - expCheck.Status = api.HealthPassing - } - log.Printf("AFTER: Updating dataplane container with Status markDataplaneContainerUnhealthy :%t and expCheck.Status %s\n", markDataplaneContainerUnhealthy, expCheck.Status) - if markDataplaneContainerUnhealthy { - log.Printf("Marking expCheck for dataplane container :%s \n", expCheck.Status) + + if c.expectedDataplaneHealthStatus != "" { + expCheck.Status = c.expectedDataplaneHealthStatus + } else { + if c.missingDataplaneContainer || markDataplaneContainerUnhealthy { + expCheck.Status = api.HealthCritical + } else if len(c.healthSyncContainers) == 0 || !markDataplaneContainerUnhealthy { + expCheck.Status = api.HealthPassing + } + log.Printf("AFTER: Updating dataplane container with Status markDataplaneContainerUnhealthy :%t and expCheck.Status %s\n", markDataplaneContainerUnhealthy, expCheck.Status) + if markDataplaneContainerUnhealthy { + log.Printf("Marking expCheck for dataplane container :%s \n", expCheck.Status) + } } } } @@ -869,7 +876,7 @@ func assertHealthChecks(t *testing.T, consulClient *api.Client, expectedServiceC require.NoError(r, err) for _, check := range checks { - log.Printf("checkName:%s , expCheck:%s , Actual Status:%s \n", expCheck.Name, expCheck.Status, check.Status) + log.Printf("checkId:%s , expCheck:%s , Actual Status:%s \n", expCheck.CheckID, expCheck.Status, check.Status) require.Equal(r, expCheck.Status, check.Status) } } From dca26c11cb53bf7c3a673782d86a28b17f863df1 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Wed, 11 Dec 2024 00:46:39 +0530 Subject: [PATCH 48/63] Update command_test.go --- subcommand/health-sync/command_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index 67aceb73..be612ece 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -393,7 +393,7 @@ func TestRun(t *testing.T) { // If there are multiple health sync containers and one of them is unhealthy // then the service check should be critical. for containerName := range c.healthSyncContainers { - if c.healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy { + if c.healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy && c.healthSyncContainers[containerName].missing == false { expCheck.Status = api.HealthCritical log.Printf("Marking the datplane container unhealthy due to :%s \n", containerName) markDataplaneContainerUnhealthy = true From ebd942ed3f0c57e72e497a1240b8025f6cf016cf Mon Sep 17 00:00:00 2001 From: Abhishek Date: Wed, 11 Dec 2024 00:55:59 +0530 Subject: [PATCH 49/63] Update command_test.go --- subcommand/health-sync/command_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index be612ece..01a6a03c 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -136,6 +136,7 @@ func TestRun(t *testing.T) { status: ecs.HealthStatusUnhealthy, }, }, + expectedDataplaneHealthStatus: api.HealthCritical, }, "one healthy and one missing health sync containers": { healthSyncContainers: map[string]healthSyncContainerMetaData{ From 95ce970b19a68e14fd40dd16581e9d4dec204028 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Wed, 11 Dec 2024 01:06:42 +0530 Subject: [PATCH 50/63] Update command_test.go --- subcommand/health-sync/command_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index 01a6a03c..5bea3952 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -206,6 +206,7 @@ func TestRun(t *testing.T) { status: ecs.HealthStatusUnhealthy, }, }, + expectedDataplaneHealthStatus: api.HealthPassing, shouldMissingContainersReappear: true, consulLogin: consulLoginCfg, }, From f7aa8140d18155f822f6f23796ae0a346af8079f Mon Sep 17 00:00:00 2001 From: Abhishek Date: Wed, 11 Dec 2024 01:11:14 +0530 Subject: [PATCH 51/63] Update command_test.go --- subcommand/health-sync/command_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index 5bea3952..89a8cafe 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -388,8 +388,8 @@ func TestRun(t *testing.T) { if expCheck.CheckID == checkID { if hsc.missing { expCheck.Status = api.HealthCritical - log.Printf("Marking the datplane container unhealthy due to :%s \n", name) - markDataplaneContainerUnhealthy = true + //log.Printf("Marking the datplane container unhealthy due to :%s \n", name) + //markDataplaneContainerUnhealthy = true } else { expCheck.Status = ecsHealthToConsulHealth(hsc.status) // If there are multiple health sync containers and one of them is unhealthy From 871e9c127ea7bf8061d41d739e9c628e310ab8f4 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Wed, 11 Dec 2024 01:14:06 +0530 Subject: [PATCH 52/63] Update command_test.go --- subcommand/health-sync/command_test.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index 89a8cafe..b8a22b95 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -115,16 +115,16 @@ func TestRun(t *testing.T) { }, consulLogin: consulLoginCfg, }, - //"two healthy health sync containers": { - // healthSyncContainers: map[string]healthSyncContainerMetaData{ - // "container-1": { - // status: ecs.HealthStatusHealthy, - // }, - // "container-2": { - // status: ecs.HealthStatusHealthy, - // }, - // }, - //}, + "two healthy health sync containers": { + healthSyncContainers: map[string]healthSyncContainerMetaData{ + "container-1": { + status: ecs.HealthStatusHealthy, + }, + "container-2": { + status: ecs.HealthStatusHealthy, + }, + }, + }, "one healthy and one unhealthy health sync containers": { healthSyncContainers: map[string]healthSyncContainerMetaData{ "container-1": { From e07091ee64005f8378578f08766fd1228fba1f03 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Wed, 11 Dec 2024 01:17:24 +0530 Subject: [PATCH 53/63] Update command_test.go --- subcommand/health-sync/command_test.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index b8a22b95..b5056fa4 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -151,16 +151,16 @@ func TestRun(t *testing.T) { expectedDataplaneHealthStatus: api.HealthPassing, consulLogin: consulLoginCfg, }, - //"two unhealthy health sync containers": { - // healthSyncContainers: map[string]healthSyncContainerMetaData{ - // "container-1": { - // status: ecs.HealthStatusUnhealthy, - // }, - // "container-2": { - // status: ecs.HealthStatusUnhealthy, - // }, - // }, - //}, + "two unhealthy health sync containers": { + healthSyncContainers: map[string]healthSyncContainerMetaData{ + "container-1": { + status: ecs.HealthStatusUnhealthy, + }, + "container-2": { + status: ecs.HealthStatusUnhealthy, + }, + }, + }, "missing dataplane container": { missingDataplaneContainer: true, }, From bc42a857432e92d1d62176e100e10f607162520d Mon Sep 17 00:00:00 2001 From: Abhishek Date: Wed, 11 Dec 2024 01:27:58 +0530 Subject: [PATCH 54/63] Update command_test.go --- subcommand/health-sync/command_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index b5056fa4..1e439f59 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -160,6 +160,7 @@ func TestRun(t *testing.T) { status: ecs.HealthStatusUnhealthy, }, }, + expectedDataplaneHealthStatus: api.HealthCritical, }, "missing dataplane container": { missingDataplaneContainer: true, From 41d02ac9d040d6fa63ac6367062357af2b16d7f2 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Wed, 11 Dec 2024 01:36:26 +0530 Subject: [PATCH 55/63] Removed comments --- subcommand/health-sync/command_test.go | 28 ++++++-------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index 1e439f59..e47e23b8 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -128,12 +128,10 @@ func TestRun(t *testing.T) { "one healthy and one unhealthy health sync containers": { healthSyncContainers: map[string]healthSyncContainerMetaData{ "container-1": { - missing: false, - status: ecs.HealthStatusHealthy, + status: ecs.HealthStatusHealthy, }, "container-2": { - missing: false, - status: ecs.HealthStatusUnhealthy, + status: ecs.HealthStatusUnhealthy, }, }, expectedDataplaneHealthStatus: api.HealthCritical, @@ -376,27 +374,21 @@ func TestRun(t *testing.T) { // Align the expectations for checks according to the // state of health sync containers - log.Printf("Expected Svc Checks: %+v\n", expectedSvcChecks) - for _, check := range append(expectedSvcChecks, expectedProxyCheck) { - log.Printf("Check Name: %s, Status: %s, ServiceName: %s, CheckId: %s\n", check.Name, check.Status, check.ServiceName, check.CheckID) - } markDataplaneContainerUnhealthy := false for _, expCheck := range expectedSvcChecks { found := false for name, hsc := range c.healthSyncContainers { checkID := constructCheckID(makeServiceID(serviceName, taskID), name) - log.Printf("Checking for container: %s, hsc %s, CheckId: %s\n", name, hsc.status, checkID) if expCheck.CheckID == checkID { if hsc.missing { expCheck.Status = api.HealthCritical - //log.Printf("Marking the datplane container unhealthy due to :%s \n", name) - //markDataplaneContainerUnhealthy = true } else { expCheck.Status = ecsHealthToConsulHealth(hsc.status) // If there are multiple health sync containers and one of them is unhealthy // then the service check should be critical. for containerName := range c.healthSyncContainers { - if c.healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy && c.healthSyncContainers[containerName].missing == false { + if c.healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy && + c.healthSyncContainers[containerName].missing == false { expCheck.Status = api.HealthCritical log.Printf("Marking the datplane container unhealthy due to :%s \n", containerName) markDataplaneContainerUnhealthy = true @@ -409,10 +401,8 @@ func TestRun(t *testing.T) { break } } - log.Printf("dataplane container for expCheck: %s, markDataplaneContainerUnhealthy :%t , found: %t\n", expCheck.CheckID, markDataplaneContainerUnhealthy, found) - if !found { - log.Printf("BEFORE: Updating dataplane container with Status markDataplaneContainerUnhealthy :%t and expCheck.Status %s\n", markDataplaneContainerUnhealthy, expCheck.Status) + if !found { if c.expectedDataplaneHealthStatus != "" { expCheck.Status = c.expectedDataplaneHealthStatus } else { @@ -421,10 +411,6 @@ func TestRun(t *testing.T) { } else if len(c.healthSyncContainers) == 0 || !markDataplaneContainerUnhealthy { expCheck.Status = api.HealthPassing } - log.Printf("AFTER: Updating dataplane container with Status markDataplaneContainerUnhealthy :%t and expCheck.Status %s\n", markDataplaneContainerUnhealthy, expCheck.Status) - if markDataplaneContainerUnhealthy { - log.Printf("Marking expCheck for dataplane container :%s \n", expCheck.Status) - } } } } @@ -433,13 +419,11 @@ func TestRun(t *testing.T) { } else { expectedProxyCheck.Status = api.HealthPassing } - log.Printf("ExpectedProxyCheck Name: %s and expCheck :%s \n", expectedProxyCheck.Name, expectedProxyCheck.Status) + if c.missingDataplaneContainer { - log.Printf("Dataplane container is missing and marking proxy check Critical\n") expectedProxyCheck.Status = api.HealthCritical } - log.Printf("Asserting HEalth checks - 1") assertHealthChecks(t, consulClient, expectedSvcChecks, expectedProxyCheck) // Test server watch From 2e47b1efd531a5edf4a3c0a1a3a9f38b779dcc4c Mon Sep 17 00:00:00 2001 From: Abhishek Date: Wed, 11 Dec 2024 01:51:26 +0530 Subject: [PATCH 56/63] Update command_test.go --- subcommand/health-sync/command_test.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index e47e23b8..a35acce6 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -7,7 +7,6 @@ import ( "context" "encoding/json" "fmt" - "log" "os" "path/filepath" "sync/atomic" @@ -390,7 +389,6 @@ func TestRun(t *testing.T) { if c.healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy && c.healthSyncContainers[containerName].missing == false { expCheck.Status = api.HealthCritical - log.Printf("Marking the datplane container unhealthy due to :%s \n", containerName) markDataplaneContainerUnhealthy = true break } @@ -494,7 +492,6 @@ func TestRun(t *testing.T) { expCheck.Status = api.HealthCritical } expectedProxyCheck.Status = api.HealthCritical - log.Printf("Asserting HEalth checks - 2") assertHealthChecks(t, consulClient, expectedSvcChecks, expectedProxyCheck) // Stop dataplane container manually because @@ -839,7 +836,6 @@ func injectContainersIntoTaskMetaResponse(t *testing.T, taskMetadataResponse *aw taskMetadataResponse.Containers = taskMetaContainersResponse taskMetaRespStr, err := constructTaskMetaResponseString(taskMetadataResponse) require.NoError(t, err) - log.Printf("TaskMetaResponseStr: %s, \n", taskMetaRespStr) return taskMetaRespStr } @@ -861,9 +857,7 @@ func assertHealthChecks(t *testing.T, consulClient *api.Client, expectedServiceC filter := fmt.Sprintf("CheckID == `%s`", expCheck.CheckID) checks, _, err := consulClient.Health().Checks(expCheck.ServiceName, &api.QueryOptions{Filter: filter, Namespace: expCheck.Namespace, Partition: expCheck.Partition}) require.NoError(r, err) - for _, check := range checks { - log.Printf("checkId:%s , expCheck:%s , Actual Status:%s \n", expCheck.CheckID, expCheck.Status, check.Status) require.Equal(r, expCheck.Status, check.Status) } } @@ -873,7 +867,6 @@ func assertHealthChecks(t *testing.T, consulClient *api.Client, expectedServiceC checks, _, err := consulClient.Health().Checks(expectedProxyCheck.ServiceName, &api.QueryOptions{Filter: filter, Namespace: expectedProxyCheck.Namespace, Partition: expectedProxyCheck.Partition}) require.NoError(r, err) require.Equal(r, 1, len(checks)) - log.Printf("ProxyCheckName:%s , expProxyCheck:%s , Actual procy Status:%s \n", expectedProxyCheck.Name, expectedProxyCheck.Status, checks[0].Status) require.Equal(r, expectedProxyCheck.Status, checks[0].Status) }) } From 55a6de5b7185f5896cc80baa064c5df023e09ad3 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Wed, 11 Dec 2024 01:57:16 +0530 Subject: [PATCH 57/63] Update command_test.go --- subcommand/health-sync/command_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index a35acce6..c9a3fbfb 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -464,9 +464,7 @@ func TestRun(t *testing.T) { expCheck.Status = ecsHealthToConsulHealth(hsc.status) if len(c.healthSyncContainers) > 1 { for containerName := range c.healthSyncContainers { - if c.healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy && - containerName != config.ConsulDataplaneContainerName && - c.shouldMissingContainersReappear == false { + if c.healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy { expCheck.Status = api.HealthCritical break } @@ -492,6 +490,7 @@ func TestRun(t *testing.T) { expCheck.Status = api.HealthCritical } expectedProxyCheck.Status = api.HealthCritical + assertHealthChecks(t, consulClient, expectedSvcChecks, expectedProxyCheck) // Stop dataplane container manually because @@ -857,6 +856,7 @@ func assertHealthChecks(t *testing.T, consulClient *api.Client, expectedServiceC filter := fmt.Sprintf("CheckID == `%s`", expCheck.CheckID) checks, _, err := consulClient.Health().Checks(expCheck.ServiceName, &api.QueryOptions{Filter: filter, Namespace: expCheck.Namespace, Partition: expCheck.Partition}) require.NoError(r, err) + for _, check := range checks { require.Equal(r, expCheck.Status, check.Status) } From d58260e3f9d35a5f6d2db2b7d0701b46e363dd40 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Wed, 11 Dec 2024 02:06:06 +0530 Subject: [PATCH 58/63] Update command_test.go --- subcommand/health-sync/command_test.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/subcommand/health-sync/command_test.go b/subcommand/health-sync/command_test.go index c9a3fbfb..55135cf7 100644 --- a/subcommand/health-sync/command_test.go +++ b/subcommand/health-sync/command_test.go @@ -462,14 +462,6 @@ func TestRun(t *testing.T) { checkID := constructCheckID(makeServiceID(serviceName, taskID), name) if expCheck.CheckID == checkID { expCheck.Status = ecsHealthToConsulHealth(hsc.status) - if len(c.healthSyncContainers) > 1 { - for containerName := range c.healthSyncContainers { - if c.healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy { - expCheck.Status = api.HealthCritical - break - } - } - } found = true break } From 4066c86475f51c08f77f5ba1acc61dccad763167 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Wed, 11 Dec 2024 02:27:54 +0530 Subject: [PATCH 59/63] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c04a941..273a7225 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,6 @@ ## Unreleased +BUG FIXES +* Fix the issue where the service was accepting traffic even though it wasn't healthy. This fix updates the health check status for `consul-dataplane` container and takes into account the health of the service container as well. IMPROVEMENTS * Bump Go version to `1.22.7` From 1b369c1de0d390fdc7a14ccbf49de427db216ed7 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Thu, 9 Jan 2025 18:34:25 +0530 Subject: [PATCH 60/63] Address review comment --- subcommand/health-sync/checks.go | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/subcommand/health-sync/checks.go b/subcommand/health-sync/checks.go index 9c520614..e50d5a59 100644 --- a/subcommand/health-sync/checks.go +++ b/subcommand/health-sync/checks.go @@ -130,7 +130,6 @@ func (c *Command) syncChecks(consulClient *api.Client, } } - overallDataplaneHealth := 0 parsedContainers := make(map[string]string) // iterate over parse for _, container := range containersToSync { @@ -161,27 +160,16 @@ func (c *Command) syncChecks(consulClient *api.Client, currentStatuses[container.Name] = container.Health.Status } } - if container.Name == config.ConsulDataplaneContainerName { - if container.Health.Status == ecs.HealthStatusHealthy { - overallDataplaneHealth = 1 - } - } - } - for containerName, healthStatus := range parsedContainers { + } - if containerName != config.ConsulDataplaneContainerName { - currentContainerHealth := 0 - if healthStatus == ecs.HealthStatusHealthy { - currentContainerHealth = 1 - } - overallDataplaneHealth = overallDataplaneHealth & currentContainerHealth + overallDataplaneHealthStatus := ecs.HealthStatusHealthy + for _, healthStatus := range parsedContainers { + if healthStatus != ecs.HealthStatusHealthy { + overallDataplaneHealthStatus = ecs.HealthStatusUnhealthy + break } } - overallDataplaneHealthStatus := ecs.HealthStatusUnhealthy - if overallDataplaneHealth == 1 { - overallDataplaneHealthStatus = ecs.HealthStatusHealthy - } err = c.handleHealthForDataplaneContainer(consulClient, taskMeta.TaskID(), serviceName, clusterARN, config.ConsulDataplaneContainerName, overallDataplaneHealthStatus) if err != nil { From dc2695eb1ad43dd42696d363977c6492216de991 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Thu, 9 Jan 2025 18:47:57 +0530 Subject: [PATCH 61/63] Revert suggested changes --- subcommand/health-sync/checks.go | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/subcommand/health-sync/checks.go b/subcommand/health-sync/checks.go index e50d5a59..9c520614 100644 --- a/subcommand/health-sync/checks.go +++ b/subcommand/health-sync/checks.go @@ -130,6 +130,7 @@ func (c *Command) syncChecks(consulClient *api.Client, } } + overallDataplaneHealth := 0 parsedContainers := make(map[string]string) // iterate over parse for _, container := range containersToSync { @@ -160,16 +161,27 @@ func (c *Command) syncChecks(consulClient *api.Client, currentStatuses[container.Name] = container.Health.Status } } - + if container.Name == config.ConsulDataplaneContainerName { + if container.Health.Status == ecs.HealthStatusHealthy { + overallDataplaneHealth = 1 + } + } } - overallDataplaneHealthStatus := ecs.HealthStatusHealthy - for _, healthStatus := range parsedContainers { - if healthStatus != ecs.HealthStatusHealthy { - overallDataplaneHealthStatus = ecs.HealthStatusUnhealthy - break + for containerName, healthStatus := range parsedContainers { + + if containerName != config.ConsulDataplaneContainerName { + currentContainerHealth := 0 + if healthStatus == ecs.HealthStatusHealthy { + currentContainerHealth = 1 + } + overallDataplaneHealth = overallDataplaneHealth & currentContainerHealth } } + overallDataplaneHealthStatus := ecs.HealthStatusUnhealthy + if overallDataplaneHealth == 1 { + overallDataplaneHealthStatus = ecs.HealthStatusHealthy + } err = c.handleHealthForDataplaneContainer(consulClient, taskMeta.TaskID(), serviceName, clusterARN, config.ConsulDataplaneContainerName, overallDataplaneHealthStatus) if err != nil { From 36dd1d9d92b7408491175a806635b7f13b5b0c6b Mon Sep 17 00:00:00 2001 From: Abhishek Date: Thu, 9 Jan 2025 21:07:39 +0530 Subject: [PATCH 62/63] Update checks.go --- subcommand/health-sync/checks.go | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/subcommand/health-sync/checks.go b/subcommand/health-sync/checks.go index 9c520614..87ae2d05 100644 --- a/subcommand/health-sync/checks.go +++ b/subcommand/health-sync/checks.go @@ -130,7 +130,6 @@ func (c *Command) syncChecks(consulClient *api.Client, } } - overallDataplaneHealth := 0 parsedContainers := make(map[string]string) // iterate over parse for _, container := range containersToSync { @@ -161,26 +160,22 @@ func (c *Command) syncChecks(consulClient *api.Client, currentStatuses[container.Name] = container.Health.Status } } - if container.Name == config.ConsulDataplaneContainerName { - if container.Health.Status == ecs.HealthStatusHealthy { - overallDataplaneHealth = 1 - } - } - } - - for containerName, healthStatus := range parsedContainers { - if containerName != config.ConsulDataplaneContainerName { - currentContainerHealth := 0 - if healthStatus == ecs.HealthStatusHealthy { - currentContainerHealth = 1 + } + overallDataplaneHealthStatus, ok := parsedContainers[config.ConsulDataplaneContainerName] + // if dataplane container exist and healthy then proceed to checking the other containers health + if ok && overallDataplaneHealthStatus == ecs.HealthStatusHealthy { + // + for name, healthStatus := range parsedContainers { + // as soon as we find any unhealthy container, we can set the dataplane health to unhealthy + if healthStatus != ecs.HealthStatusHealthy && name != config.ConsulDataplaneContainerName { + overallDataplaneHealthStatus = ecs.HealthStatusUnhealthy + break } - overallDataplaneHealth = overallDataplaneHealth & currentContainerHealth } - } - overallDataplaneHealthStatus := ecs.HealthStatusUnhealthy - if overallDataplaneHealth == 1 { - overallDataplaneHealthStatus = ecs.HealthStatusHealthy + } else { + // If no dataplane container or dataplane container is not healthy set overall health to healthy + overallDataplaneHealthStatus = ecs.HealthStatusUnhealthy } err = c.handleHealthForDataplaneContainer(consulClient, taskMeta.TaskID(), serviceName, clusterARN, config.ConsulDataplaneContainerName, overallDataplaneHealthStatus) From afe3540ea7b0e0b979b1710b6ca94d191313f304 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Mon, 13 Jan 2025 11:23:56 +0530 Subject: [PATCH 63/63] Remove redundant check and typo correction --- subcommand/health-sync/checks.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/subcommand/health-sync/checks.go b/subcommand/health-sync/checks.go index 87ae2d05..f84d4ddf 100644 --- a/subcommand/health-sync/checks.go +++ b/subcommand/health-sync/checks.go @@ -166,15 +166,15 @@ func (c *Command) syncChecks(consulClient *api.Client, // if dataplane container exist and healthy then proceed to checking the other containers health if ok && overallDataplaneHealthStatus == ecs.HealthStatusHealthy { // - for name, healthStatus := range parsedContainers { + for _, healthStatus := range parsedContainers { // as soon as we find any unhealthy container, we can set the dataplane health to unhealthy - if healthStatus != ecs.HealthStatusHealthy && name != config.ConsulDataplaneContainerName { + if healthStatus != ecs.HealthStatusHealthy { overallDataplaneHealthStatus = ecs.HealthStatusUnhealthy break } } } else { - // If no dataplane container or dataplane container is not healthy set overall health to healthy + // If no dataplane container or dataplane container is not healthy set overall health to unhealthy overallDataplaneHealthStatus = ecs.HealthStatusUnhealthy }