From e0f095c6c56d0aedb9a9dfa2b8c69ef02759f5ba Mon Sep 17 00:00:00 2001 From: "malik.hadjri" Date: Fri, 22 Nov 2024 15:14:55 -0500 Subject: [PATCH 1/3] DEVPROD-5498 Do not consider elapased communication time during group teardown --- model/host/host.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/model/host/host.go b/model/host/host.go index e295c2316fd..9b3c783ce87 100644 --- a/model/host/host.go +++ b/model/host/host.go @@ -2169,6 +2169,12 @@ func (h *Host) Replace(ctx context.Context) error { // GetElapsedCommunicationTime returns how long since this host has communicated with evergreen or vice versa func (h *Host) GetElapsedCommunicationTime() time.Duration { + // If the host is currently tearing down a task group, it is not considered idle, and + // can acceptably not communicate with evergreen because the task has completed and will + // no longer be sending heartbeat requests. + if h.IsTearingDown() { + return 0 + } if h.LastCommunicationTime.After(h.CreationTime) { return time.Since(h.LastCommunicationTime) } From 65d3d5ffa040e24652897d779c61f66773f161a1 Mon Sep 17 00:00:00 2001 From: "malik.hadjri" Date: Fri, 22 Nov 2024 15:24:23 -0500 Subject: [PATCH 2/3] wording + test case --- .../fakeparameter/fake_parameter.go | 17 +++++++---------- model/host/host.go | 4 ++-- model/host/host_test.go | 6 ++++++ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/cloud/parameterstore/fakeparameter/fake_parameter.go b/cloud/parameterstore/fakeparameter/fake_parameter.go index 3738078bca8..76c43194431 100644 --- a/cloud/parameterstore/fakeparameter/fake_parameter.go +++ b/cloud/parameterstore/fakeparameter/fake_parameter.go @@ -2,13 +2,10 @@ package fakeparameter import ( "context" - "flag" "time" "github.com/evergreen-ci/evergreen" "github.com/evergreen-ci/evergreen/db/mgo/bson" - "github.com/mongodb/grip" - "github.com/mongodb/grip/message" "go.mongodb.org/mongo-driver/mongo/options" ) @@ -19,13 +16,13 @@ import ( var ExecutionEnvironmentType = "production" func init() { - if ExecutionEnvironmentType != "test" { - grip.EmergencyFatal(message.Fields{ - "message": "fake Parameter Store testing code called in a non-testing environment", - "environment": ExecutionEnvironmentType, - "args": flag.Args(), - }) - } + //if ExecutionEnvironmentType != "test" { + // grip.EmergencyFatal(message.Fields{ + // "message": "fake Parameter Store testing code called in a non-testing environment", + // "environment": ExecutionEnvironmentType, + // "args": flag.Args(), + // }) + //} } // FakeParameter is the data model for a fake parameter stored in the DB. This diff --git a/model/host/host.go b/model/host/host.go index 9b3c783ce87..bb090240067 100644 --- a/model/host/host.go +++ b/model/host/host.go @@ -2170,8 +2170,8 @@ func (h *Host) Replace(ctx context.Context) error { // GetElapsedCommunicationTime returns how long since this host has communicated with evergreen or vice versa func (h *Host) GetElapsedCommunicationTime() time.Duration { // If the host is currently tearing down a task group, it is not considered idle, and - // can acceptably not communicate with evergreen because the task has completed and will - // no longer be sending heartbeat requests. + // it is expected that it will not communicate with evergreen because the task has completed + // and will no longer be sending heartbeat requests. if h.IsTearingDown() { return 0 } diff --git a/model/host/host_test.go b/model/host/host_test.go index 05dda936c05..06b5c74d913 100644 --- a/model/host/host_test.go +++ b/model/host/host_test.go @@ -1791,11 +1791,17 @@ func TestHostElapsedCommTime(t *testing.T) { Id: "hostWithOnlyCreateTime", CreationTime: now.Add(-7 * time.Minute), } + hostThatsRunningTeardown := Host{ + Id: "hostThatsRunningTeardown", + CreationTime: now.Add(-7 * time.Minute), + TaskGroupTeardownStartTime: now.Add(-1 * time.Minute), + } assert.InDelta(int64(10*time.Minute), int64(hostThatRanTask.GetElapsedCommunicationTime()), float64(1*time.Millisecond)) assert.InDelta(int64(1*time.Minute), int64(hostThatJustStarted.GetElapsedCommunicationTime()), float64(1*time.Millisecond)) assert.InDelta(int64(15*time.Minute), int64(hostWithNoCreateTime.GetElapsedCommunicationTime()), float64(1*time.Millisecond)) assert.InDelta(int64(7*time.Minute), int64(hostWithOnlyCreateTime.GetElapsedCommunicationTime()), float64(1*time.Millisecond)) + assert.Zero(hostThatsRunningTeardown.GetElapsedCommunicationTime()) } func TestHostUpsert(t *testing.T) { From c3802341c98e155c175ce5fba85674eb7a6e86fd Mon Sep 17 00:00:00 2001 From: "malik.hadjri" Date: Fri, 22 Nov 2024 15:24:56 -0500 Subject: [PATCH 3/3] wording + test case --- .../fakeparameter/fake_parameter.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/cloud/parameterstore/fakeparameter/fake_parameter.go b/cloud/parameterstore/fakeparameter/fake_parameter.go index 76c43194431..3738078bca8 100644 --- a/cloud/parameterstore/fakeparameter/fake_parameter.go +++ b/cloud/parameterstore/fakeparameter/fake_parameter.go @@ -2,10 +2,13 @@ package fakeparameter import ( "context" + "flag" "time" "github.com/evergreen-ci/evergreen" "github.com/evergreen-ci/evergreen/db/mgo/bson" + "github.com/mongodb/grip" + "github.com/mongodb/grip/message" "go.mongodb.org/mongo-driver/mongo/options" ) @@ -16,13 +19,13 @@ import ( var ExecutionEnvironmentType = "production" func init() { - //if ExecutionEnvironmentType != "test" { - // grip.EmergencyFatal(message.Fields{ - // "message": "fake Parameter Store testing code called in a non-testing environment", - // "environment": ExecutionEnvironmentType, - // "args": flag.Args(), - // }) - //} + if ExecutionEnvironmentType != "test" { + grip.EmergencyFatal(message.Fields{ + "message": "fake Parameter Store testing code called in a non-testing environment", + "environment": ExecutionEnvironmentType, + "args": flag.Args(), + }) + } } // FakeParameter is the data model for a fake parameter stored in the DB. This