Commit ca75b4bb authored by Vishnu Karthik Ravindran's avatar Vishnu Karthik Ravindran Committed by Leo Ahnn
Browse files

fix for the wait group reuse panic triggered while agent reboot

cr: https://code.amazon.com/reviews/CR-56842186
parent a4d5f9da
......@@ -242,6 +242,9 @@ func (c *CoreManager) stopCoreModules(stopType contracts.StopType) {
var wg sync.WaitGroup
l := len(c.coreModules)
for i := 0; i < l; i++ {
if stopType == contracts.StopTypeSoftStop {
wg.Add(1)
}
go func(wgc *sync.WaitGroup, i int) {
defer func() {
if r := recover(); r != nil {
......@@ -250,7 +253,6 @@ func (c *CoreManager) stopCoreModules(stopType contracts.StopType) {
}
}()
if stopType == contracts.StopTypeSoftStop {
wgc.Add(1)
defer wgc.Done()
}
......
......@@ -43,7 +43,7 @@ import (
// CrashWorkerTestSuite defines test suite for sending a command to the agent and handling the worker process crash
type CrashWorkerTestSuite struct {
context context.T
context context.T
suite.Suite
ssmAgent agent.ISSMAgent
mdsSdkMock *mdssdkmock.SSMMDSAPI
......
......@@ -43,7 +43,7 @@ import (
// RunCommandOutputTestSuite defines test suite for sending runcommand output, error and exit code to MDS service
type RunCommandOutputTestSuite struct {
context context.T
context context.T
suite.Suite
ssmAgent agent.ISSMAgent
mdsSdkMock *mdssdkmock.SSMMDSAPI
......
......@@ -19,7 +19,6 @@ import (
"runtime/debug"
"testing"
"github.com/aws/amazon-ssm-agent/common/identity"
"github.com/aws/amazon-ssm-agent/agent/agent"
"github.com/aws/amazon-ssm-agent/agent/appconfig"
"github.com/aws/amazon-ssm-agent/agent/context"
......@@ -28,6 +27,7 @@ import (
"github.com/aws/amazon-ssm-agent/agent/log"
logger "github.com/aws/amazon-ssm-agent/agent/log/ssmlog"
messageContracts "github.com/aws/amazon-ssm-agent/agent/runcommand/contracts"
"github.com/aws/amazon-ssm-agent/common/identity"
"github.com/aws/amazon-ssm-agent/internal/tests/testdata"
"github.com/aws/amazon-ssm-agent/internal/tests/testutils"
"github.com/aws/aws-sdk-go/aws/request"
......@@ -41,7 +41,7 @@ import (
// functionality from testify - including a T() method which
// returns the current testing context
type AgentStressTestSuite struct {
context context.T
context context.T
suite.Suite
ssmAgent agent.ISSMAgent
mdsSdkMock *mdssdkmock.SSMMDSAPI
......
......@@ -48,7 +48,7 @@ type SendFailedReplyTestSuite struct {
suite.Suite
ssmAgent agent.ISSMAgent
mdsSdkMock *mdssdkmock.SSMMDSAPI
context context.T
context context.T
}
// SetupTest makes sure that all the components referenced in the test case are initialized
......
......@@ -17,5 +17,5 @@ package testutils
const (
// Test defaults
TestInstanceId = "i-123123123"
TestRegion = "us-west-1"
TestRegion = "us-west-1"
)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment