Skip to content

Commit

Permalink
Revert 08/15/2024-08/16/2024 commits in dev branch (#4296)
Browse files Browse the repository at this point in the history
* Revert "Expose FaultInjection status in TaskResponse (#4285)"

This reverts commit fd3693c.

* Revert "Implementing network blackhole port handler"

This reverts commit 177dbd2.

* Revert "TaskStopVerificationACKResponder integration tests (#4282)"

This reverts commit d6fbc04.

* Revert "Container transition to MANIFEST_PULLED state should happen after network pause container reaches RESOURCES_PROVISIONED state (#4286)"

This reverts commit 6c7758d.
  • Loading branch information
danehlim authored Aug 18, 2024
1 parent 5c60c23 commit 7a0fa96
Show file tree
Hide file tree
Showing 22 changed files with 132 additions and 1,487 deletions.
227 changes: 0 additions & 227 deletions agent/acs/session/task_stop_verification_ack_responder_integ_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion agent/api/task/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -1491,7 +1491,7 @@ func (task *Task) addNetworkResourceProvisioningDependencyAwsvpc(cfg *config.Con
if container.IsInternal() {
continue
}
container.BuildContainerDependency(NetworkPauseContainerName, apicontainerstatus.ContainerResourcesProvisioned, apicontainerstatus.ContainerManifestPulled)
container.BuildContainerDependency(NetworkPauseContainerName, apicontainerstatus.ContainerResourcesProvisioned, apicontainerstatus.ContainerPulled)
pauseContainer.BuildContainerDependency(container.Name, apicontainerstatus.ContainerStopped, apicontainerstatus.ContainerStopped)
}

Expand Down
22 changes: 4 additions & 18 deletions agent/engine/common_integ_testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ var (
sdkClientFactory sdkclientfactory.Factory
)

const (
taskSteadyStatePollInterval = 100 * time.Millisecond
taskSteadyStatePollIntervalJitter = 10 * time.Millisecond
)

func init() {
sdkClientFactory = sdkclientfactory.NewFactory(context.TODO(), dockerEndpoint)
}
Expand All @@ -74,7 +69,7 @@ func CreateTestTask(arn string) *apitask.Task {
Family: "family",
Version: "1",
DesiredStatusUnsafe: apitaskstatus.TaskRunning,
Containers: []*apicontainer.Container{CreateTestContainer()},
Containers: []*apicontainer.Container{createTestContainer()},
}
}

Expand Down Expand Up @@ -124,10 +119,6 @@ func setupGMSALinux(cfg *config.Config, state dockerstate.TaskEngineState, t *te
taskEngine := NewDockerTaskEngine(cfg, dockerClient, credentialsManager,
eventstream.NewEventStream("ENGINEINTEGTEST", context.Background()), imageManager, &hostResourceManager, state, metadataManager,
resourceFields, execcmd.NewManager(), engineserviceconnect.NewManager(), daemonManagers)
// Set the steady state poll interval to a low value so that tasks transition from their current state to their
// desired state faster. This prevents tests from appearing to hang while waiting for state change events.
taskEngine.taskSteadyStatePollInterval = taskSteadyStatePollInterval
taskEngine.taskSteadyStatePollIntervalJitter = taskSteadyStatePollIntervalJitter
taskEngine.MustInit(context.TODO())
return taskEngine, func() {
taskEngine.Shutdown()
Expand Down Expand Up @@ -168,7 +159,7 @@ func VerifyTaskManifestPulledStateChange(t *testing.T, taskEngine TaskEngine) {
func VerifyContainerRunningStateChange(t *testing.T, taskEngine TaskEngine) {
stateChangeEvents := taskEngine.StateChangeEvents()
event := <-stateChangeEvents
assert.Equal(t, apicontainerstatus.ContainerRunning, event.(api.ContainerStateChange).Status,
assert.Equal(t, event.(api.ContainerStateChange).Status, apicontainerstatus.ContainerRunning,
"Expected container to be RUNNING")
}

Expand All @@ -182,7 +173,7 @@ func VerifyTaskRunningStateChange(t *testing.T, taskEngine TaskEngine) {
func verifyContainerRunningStateChangeWithRuntimeID(t *testing.T, taskEngine TaskEngine) {
stateChangeEvents := taskEngine.StateChangeEvents()
event := <-stateChangeEvents
assert.Equal(t, apicontainerstatus.ContainerRunning, event.(api.ContainerStateChange).Status,
assert.Equal(t, event.(api.ContainerStateChange).Status, apicontainerstatus.ContainerRunning,
"Expected container to be RUNNING")
assert.NotEqual(t, "", event.(api.ContainerStateChange).RuntimeID,
"Expected container runtimeID should not empty")
Expand All @@ -205,9 +196,8 @@ func verifyExecAgentStateChange(t *testing.T, taskEngine TaskEngine,
func VerifyContainerStoppedStateChange(t *testing.T, taskEngine TaskEngine) {
stateChangeEvents := taskEngine.StateChangeEvents()
event := <-stateChangeEvents
sc := event.(api.ContainerStateChange)
assert.Equal(t, event.(api.ContainerStateChange).Status, apicontainerstatus.ContainerStopped,
"Expected container %s from task %s to be STOPPED", sc.RuntimeID, sc.TaskArn)
"Expected container to be STOPPED")
}

func verifyContainerStoppedStateChangeWithReason(t *testing.T, taskEngine TaskEngine, reason string) {
Expand Down Expand Up @@ -269,10 +259,6 @@ func SetupIntegTestTaskEngine(cfg *config.Config, state dockerstate.TaskEngineSt
taskEngine := NewDockerTaskEngine(cfg, dockerClient, credentialsManager,
eventstream.NewEventStream("ENGINEINTEGTEST", context.Background()), imageManager, &hostResourceManager, state, metadataManager,
nil, execcmd.NewManager(), engineserviceconnect.NewManager(), daemonManagers)
// Set the steady state poll interval to a low value so that tasks transition from their current state to their
// desired state faster. This prevents tests from appearing to hang while waiting for state change events.
taskEngine.taskSteadyStatePollInterval = taskSteadyStatePollInterval
taskEngine.taskSteadyStatePollIntervalJitter = taskSteadyStatePollIntervalJitter
taskEngine.MustInit(context.TODO())
return taskEngine, func() {
taskEngine.Shutdown()
Expand Down
6 changes: 3 additions & 3 deletions agent/engine/common_unix_integ_testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ const (
dockerEndpoint = "unix:///var/run/docker.sock"
)

func CreateTestContainer() *apicontainer.Container {
func createTestContainer() *apicontainer.Container {
return createTestContainerWithImageAndName(testRegistryImage, "netcat")
}

// GetLongRunningCommand returns the command that keeps the container running for the container
// getLongRunningCommand returns the command that keeps the container running for the container
// that uses the default integ test image (amazon/amazon-ecs-netkitten for unix)
func GetLongRunningCommand() []string {
func getLongRunningCommand() []string {
return []string{"-loop=true"}
}

Expand Down
45 changes: 4 additions & 41 deletions agent/engine/docker_task_engine_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -822,15 +822,6 @@ func TestTaskWithSteadyStateResourcesProvisioned(t *testing.T) {
waitForStopEvents(t, taskEngine.StateChangeEvents(), true, false)
}

// Tests a happy case scenario for an AWSVPC task.
//
// This test also verifies that
// any DockerClient calls that interact with an image repository (PullContainerManifest
// and PullContainer, currently) happen after the pause container has reached
// ContainerResourcesProvisioned state.
//
// If you are updating this test then make sure that you call assertPauseContainerIsRunning()
// in any dockerClient expected calls that are supposed to interact with an image repository.
func TestPauseContainerHappyPath(t *testing.T) {
ctx, cancel := context.WithCancel(context.TODO())
defer cancel()
Expand Down Expand Up @@ -866,19 +857,6 @@ func TestPauseContainerHappyPath(t *testing.T) {
dockerClient.EXPECT().ContainerEvents(gomock.Any()).Return(eventStream, nil)
serviceConnectManager.EXPECT().GetAppnetContainerTarballDir().AnyTimes()

// A function to assert that the network pause container in the task is in
// ContainerResourcesProvisioned state. This will be used by dockerClient mock later.
assertPauseContainerIsRunning := func() {
assert.Len(t, sleepTask.Containers, 3, "expected pause container to be populated")
pauseContainer := sleepTask.Containers[2]
assert.Equal(t, apitask.NetworkPauseContainerName, pauseContainer.Name)
assert.Equal(t, apicontainer.ContainerCNIPause, pauseContainer.Type)
assert.Equal(t,
apicontainerstatus.ContainerResourcesProvisioned,
pauseContainer.GetKnownStatus(),
"expected pause container to be running before image repository is called")
}

sleepContainerID1 := containerID + "1"
sleepContainerID2 := containerID + "2"
pauseContainerID := "pauseContainerID"
Expand All @@ -892,13 +870,8 @@ func TestPauseContainerHappyPath(t *testing.T) {
assert.True(t, ok)
assert.Equal(t, apitask.NetworkPauseContainerName, name)
}).Return(dockerapi.DockerContainerMetadata{DockerID: "pauseContainerID"}),
dockerClient.EXPECT().
StartContainer(gomock.Any(), pauseContainerID, defaultConfig.ContainerStartTimeout).
Do(func(ctx interface{}, id string, timeout time.Duration) {
// Simulate some startup time
time.Sleep(5 * time.Millisecond)
}).
Return(dockerapi.DockerContainerMetadata{DockerID: "pauseContainerID"}),
dockerClient.EXPECT().StartContainer(gomock.Any(), pauseContainerID, defaultConfig.ContainerStartTimeout).Return(
dockerapi.DockerContainerMetadata{DockerID: "pauseContainerID"}),
dockerClient.EXPECT().InspectContainer(gomock.Any(), gomock.Any(), gomock.Any()).Return(
&types.ContainerJSON{
ContainerJSONBase: &types.ContainerJSONBase{
Expand All @@ -919,19 +892,9 @@ func TestPauseContainerHappyPath(t *testing.T) {
imageManager.EXPECT().AddAllImageStates(gomock.Any()).AnyTimes()
dockerClient.EXPECT().WithVersion(dockerclient.Version_1_35).Times(2).Return(manifestPullClient, nil)
manifestPullClient.EXPECT().
PullImageManifest(gomock.Any(), gomock.Any(), gomock.Any()).
Times(2).
Do(func(context.Context, string, *apicontainer.RegistryAuthenticationData) {
assertPauseContainerIsRunning() // Ensure that pause container is already RUNNING
}).
PullImageManifest(gomock.Any(), gomock.Any(), gomock.Any()).Times(2).
Return(registry.DistributionInspect{}, nil)
dockerClient.EXPECT().
PullImage(gomock.Any(), gomock.Any(), nil, gomock.Any()).
Do(func(context.Context, string, *apicontainer.RegistryAuthenticationData, time.Duration) {
assertPauseContainerIsRunning() // Ensure that pause container is already RUNNING
}).
Return(dockerapi.DockerContainerMetadata{}).
Times(2)
dockerClient.EXPECT().PullImage(gomock.Any(), gomock.Any(), nil, gomock.Any()).Return(dockerapi.DockerContainerMetadata{}).Times(2)
imageManager.EXPECT().RecordContainerReference(gomock.Any()).Return(nil).Times(2)
imageManager.EXPECT().GetImageStateFromImageName(gomock.Any()).Return(nil, false).Times(2)
dockerClient.EXPECT().APIVersion().Return(defaultDockerClientAPIVersion, nil).Times(2)
Expand Down
Loading

0 comments on commit 7a0fa96

Please sign in to comment.