Skip to content

Commit

Permalink
revert the following commits to exclude from release v1.78.1:
Browse files Browse the repository at this point in the history
1. Revert "Load Managed Daemon images in background (aws#3984)"

This reverts commit 75db5cb.

2. Revert "update daemon log path host root in container (aws#3982)"

This reverts commit 6166b6e.

3. Revert "Fix loading CSI driver container from state if it exists"

This reverts commit 1391502.

4. Revert "Latest FE model files (aws#3974)"

This reverts commit b589a08.

5. Revert "Move utils function Uint16SliceToStringSlice to shared lib"

This reverts commit 882bcb2.

6. Revert "Move remaining credentials module to shared library"

This reverts commit f58f228.

7. Revert "fix merge import failure (aws#3976)"

This reverts commit 46e21e6.

8. Revert "Fixing task volumes from payload for EBS-backed tasks"

This reverts commit fc97633.

9. Revert "Create Generic Attachment to decouple from ENI and save attachment state. (aws#3969)"

This reverts commit 12e23ed.

10. Revert "Add support for finding EBS devices on Xen instances (aws#3971)"

This reverts commit 3500ac2.

11. Revert "Add network builder and platform APIs (aws#3939)"

This reverts commit b8d2a7f.

12. Revert "Minor refactor of TTL cache (allow nil TTL + get TTL)"

This reverts commit 4b33664.

13. Revert "Move httpclient to ecs-agent/ and minor refactor"

This reverts commit 041ca3f.

14. Revert "Add missing EBSTaskAttach changes from feature branch"

This reverts commit 7a0d116.
  • Loading branch information
singholt committed Oct 26, 2023
1 parent 8f6ad52 commit cd649fa
Show file tree
Hide file tree
Showing 192 changed files with 1,819 additions and 44,309 deletions.
2 changes: 1 addition & 1 deletion agent/acs/session/attach_eni_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (eniHandler *eniHandler) removeENIAttachmentData(mac string) {
seelog.Errorf("Unable to retrieve ENI Attachment for mac address %s: ", mac)
return
}
attachmentId, err := utils.GetAttachmentId(attachmentToRemove.AttachmentARN)
attachmentId, err := utils.GetENIAttachmentId(attachmentToRemove.AttachmentARN)
if err != nil {
seelog.Errorf("Failed to get attachment id for %s: %v", attachmentToRemove.AttachmentARN, err)
} else {
Expand Down
10 changes: 5 additions & 5 deletions agent/acs/session/attach_eni_common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/aws/amazon-ecs-agent/agent/data"
"github.com/aws/amazon-ecs-agent/agent/engine/dockerstate"
"github.com/aws/amazon-ecs-agent/ecs-agent/acs/session/testconst"
"github.com/aws/amazon-ecs-agent/ecs-agent/api/attachment"
"github.com/aws/amazon-ecs-agent/ecs-agent/api/attachmentinfo"
ni "github.com/aws/amazon-ecs-agent/ecs-agent/netlib/model/networkinterface"
)

Expand All @@ -53,7 +53,7 @@ func testENIAckTimeout(t *testing.T, attachmentType string) {

expiresAt := time.Now().Add(time.Millisecond * testconst.WaitTimeoutMillis)
eniAttachment := &ni.ENIAttachment{
AttachmentInfo: attachment.AttachmentInfo{
AttachmentInfo: attachmentinfo.AttachmentInfo{
TaskARN: testconst.TaskARN,
AttachmentARN: attachmentArn,
ExpiresAt: expiresAt,
Expand Down Expand Up @@ -99,7 +99,7 @@ func testENIAckWithinTimeout(t *testing.T, attachmentType string) {
dataClient := data.NewNoopClient()
expiresAt := time.Now().Add(time.Millisecond * testconst.WaitTimeoutMillis)
eniAttachment := &ni.ENIAttachment{
AttachmentInfo: attachment.AttachmentInfo{
AttachmentInfo: attachmentinfo.AttachmentInfo{
TaskARN: testconst.TaskARN,
AttachmentARN: attachmentArn,
ExpiresAt: expiresAt,
Expand Down Expand Up @@ -141,7 +141,7 @@ func testHandleENIAttachment(t *testing.T, attachmentType, taskArn string) {
taskEngineState := dockerstate.NewTaskEngineState()
expiresAt := time.Now().Add(time.Millisecond * testconst.WaitTimeoutMillis)
eniAttachment := &ni.ENIAttachment{
AttachmentInfo: attachment.AttachmentInfo{
AttachmentInfo: attachmentinfo.AttachmentInfo{
TaskARN: taskArn,
AttachmentARN: attachmentArn,
ExpiresAt: expiresAt,
Expand Down Expand Up @@ -188,7 +188,7 @@ func testHandleExpiredENIAttachment(t *testing.T, attachmentType, taskArn string
dataClient := data.NewNoopClient()

eniAttachment := &ni.ENIAttachment{
AttachmentInfo: attachment.AttachmentInfo{
AttachmentInfo: attachmentinfo.AttachmentInfo{
TaskARN: taskArn,
AttachmentARN: attachmentArn,
ExpiresAt: expiresAt,
Expand Down
4 changes: 2 additions & 2 deletions agent/acs/session/attach_instance_eni_responder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"github.com/aws/amazon-ecs-agent/ecs-agent/acs/model/ecsacs"
acssession "github.com/aws/amazon-ecs-agent/ecs-agent/acs/session"
"github.com/aws/amazon-ecs-agent/ecs-agent/acs/session/testconst"
"github.com/aws/amazon-ecs-agent/ecs-agent/api/attachment"
"github.com/aws/amazon-ecs-agent/ecs-agent/api/attachmentinfo"
ni "github.com/aws/amazon-ecs-agent/ecs-agent/netlib/model/networkinterface"
)

Expand Down Expand Up @@ -113,7 +113,7 @@ func TestInstanceENIAckSingleMessageWithDuplicateENIAttachment(t *testing.T) {
mockState.EXPECT().
ENIByMac(testconst.RandomMAC).
Return(&ni.ENIAttachment{
AttachmentInfo: attachment.AttachmentInfo{
AttachmentInfo: attachmentinfo.AttachmentInfo{
ExpiresAt: expiresAt,
},
}, true).
Expand Down
4 changes: 2 additions & 2 deletions agent/acs/session/attach_task_eni_responder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"github.com/aws/amazon-ecs-agent/ecs-agent/acs/model/ecsacs"
acssession "github.com/aws/amazon-ecs-agent/ecs-agent/acs/session"
"github.com/aws/amazon-ecs-agent/ecs-agent/acs/session/testconst"
"github.com/aws/amazon-ecs-agent/ecs-agent/api/attachment"
"github.com/aws/amazon-ecs-agent/ecs-agent/api/attachmentinfo"
ni "github.com/aws/amazon-ecs-agent/ecs-agent/netlib/model/networkinterface"
)

Expand Down Expand Up @@ -113,7 +113,7 @@ func TestTaskENIAckSingleMessageWithDuplicateENIAttachment(t *testing.T) {
mockState.EXPECT().
ENIByMac(testconst.RandomMAC).
Return(&ni.ENIAttachment{
AttachmentInfo: attachment.AttachmentInfo{
AttachmentInfo: attachmentinfo.AttachmentInfo{
ExpiresAt: expiresAt,
},
}, true).
Expand Down
36 changes: 1 addition & 35 deletions agent/acs/session/payload_responder.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/aws/amazon-ecs-agent/agent/engine"
"github.com/aws/amazon-ecs-agent/agent/eventhandler"
"github.com/aws/amazon-ecs-agent/ecs-agent/acs/model/ecsacs"
apiresource "github.com/aws/amazon-ecs-agent/ecs-agent/api/attachment/resource"
apitaskstatus "github.com/aws/amazon-ecs-agent/ecs-agent/api/task/status"
"github.com/aws/amazon-ecs-agent/ecs-agent/credentials"
"github.com/aws/amazon-ecs-agent/ecs-agent/logger"
Expand Down Expand Up @@ -107,16 +106,6 @@ func (pmHandler *payloadMessageHandler) addPayloadTasks(payload *ecsacs.PayloadM
allTasksOK = false
continue
}

// Note: If we receive an EBS-backed task, we'll also received an incomplete volume configuration in the list of Volumes
// To accomodate this, we'll first check if the task IS EBS-backed then we'll mark the corresponding Volume object to be
// of type "attachment". This volume object will be replaced by the newly created EBS volume configuration when we parse
// through the task attachments.
volName, ok := hasEBSAttachment(task)
if ok {
initializeAttachmentTypeVolume(task, volName)
}

apiTask, err := apitask.TaskFromACS(task, payload)
if err != nil {
pmHandler.handleInvalidTask(task, err, payload)
Expand Down Expand Up @@ -151,7 +140,7 @@ func (pmHandler *payloadMessageHandler) addPayloadTasks(payload *ecsacs.PayloadM

// Add ENI information to the task struct.
for _, acsENI := range task.ElasticNetworkInterfaces {
eni, err := ni.InterfaceFromACS(acsENI)
eni, err := ni.ENIFromACS(acsENI)
if err != nil {
pmHandler.handleInvalidTask(task, err, payload)
allTasksOK = false
Expand Down Expand Up @@ -317,26 +306,3 @@ func isTaskStatusStopped(status apitaskstatus.TaskStatus) bool {
func isTaskStatusNotStopped(status apitaskstatus.TaskStatus) bool {
return status != apitaskstatus.TaskStopped
}

func hasEBSAttachment(acsTask *ecsacs.Task) (string, bool) {
// TODO: This will only work if there's one EBS volume per task. If we there is a case where we have multi-attach for a task, this needs to be modified
for _, attachment := range acsTask.Attachments {
if *attachment.AttachmentType == apiresource.EBSTaskAttach {
for _, property := range attachment.AttachmentProperties {
if *property.Name == apiresource.VolumeNameKey {
return *property.Value, true
}
}
}
}
return "", false
}

func initializeAttachmentTypeVolume(acsTask *ecsacs.Task, volName string) {
for _, volume := range acsTask.Volumes {
if *volume.Name == volName && volume.Type == nil {
newType := "attachment"
volume.Type = &newType
}
}
}
14 changes: 4 additions & 10 deletions agent/acs/session/payload_responder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ import (
"github.com/aws/amazon-ecs-agent/ecs-agent/acs/model/ecsacs"
acssession "github.com/aws/amazon-ecs-agent/ecs-agent/acs/session"
"github.com/aws/amazon-ecs-agent/ecs-agent/acs/session/testconst"
apiresource "github.com/aws/amazon-ecs-agent/ecs-agent/api/attachment/resource"
"github.com/aws/amazon-ecs-agent/ecs-agent/api/eni"
apiresource "github.com/aws/amazon-ecs-agent/ecs-agent/api/resource"
apitaskstatus "github.com/aws/amazon-ecs-agent/ecs-agent/api/task/status"
"github.com/aws/amazon-ecs-agent/ecs-agent/credentials"
ni "github.com/aws/amazon-ecs-agent/ecs-agent/netlib/model/networkinterface"
"github.com/aws/amazon-ecs-agent/ecs-agent/wsclient"
"github.com/aws/aws-sdk-go/aws"
"github.com/golang/mock/gomock"
Expand Down Expand Up @@ -725,12 +725,6 @@ func TestHandlePayloadMessageAddedEBSToTask(t *testing.T) {
AttachmentType: aws.String(apiresource.EBSTaskAttach),
},
},
Volumes: []*ecsacs.Volume{
{
Name: aws.String(taskresourcevolume.TestVolumeName),
Type: aws.String(apitask.AttachmentType),
},
},
},
}

Expand Down Expand Up @@ -864,7 +858,7 @@ func TestHandlePayloadMessageAddedENITrunkToTask(t *testing.T) {
Arn: aws.String(testconst.TaskARN),
ElasticNetworkInterfaces: []*ecsacs.ElasticNetworkInterface{
{
InterfaceAssociationProtocol: aws.String(ni.VLANInterfaceAssociationProtocol),
InterfaceAssociationProtocol: aws.String(eni.VLANInterfaceAssociationProtocol),
AttachmentArn: aws.String(attachmentARN),
Ec2Id: aws.String(ec2ID),
Ipv4Addresses: []*ecsacs.IPv4AddressAssignment{
Expand Down Expand Up @@ -896,7 +890,7 @@ func TestHandlePayloadMessageAddedENITrunkToTask(t *testing.T) {

// Validate the added task has the ENI trunk information as expected.
taskeni := addedTask.GetPrimaryENI()
assert.Equal(t, ni.VLANInterfaceAssociationProtocol, taskeni.InterfaceAssociationProtocol)
assert.Equal(t, eni.VLANInterfaceAssociationProtocol, taskeni.InterfaceAssociationProtocol)
assert.Equal(t, testconst.RandomMAC, taskeni.InterfaceVlanProperties.TrunkInterfaceMacAddress)
assert.Equal(t, vlanID, taskeni.InterfaceVlanProperties.VlanID)
}
Expand Down
5 changes: 2 additions & 3 deletions agent/acs/updater/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ import (
"github.com/aws/amazon-ecs-agent/agent/data"
"github.com/aws/amazon-ecs-agent/agent/engine"
"github.com/aws/amazon-ecs-agent/agent/engine/dockerstate"
"github.com/aws/amazon-ecs-agent/agent/httpclient"
"github.com/aws/amazon-ecs-agent/agent/sighandlers"
"github.com/aws/amazon-ecs-agent/agent/sighandlers/exitcodes"
"github.com/aws/amazon-ecs-agent/agent/utils"
agentversion "github.com/aws/amazon-ecs-agent/agent/version"
"github.com/aws/amazon-ecs-agent/ecs-agent/acs/model/ecsacs"
"github.com/aws/amazon-ecs-agent/ecs-agent/httpclient"
"github.com/aws/amazon-ecs-agent/ecs-agent/utils/ttime"
"github.com/aws/amazon-ecs-agent/ecs-agent/wsclient"

Expand Down Expand Up @@ -80,7 +79,7 @@ func NewUpdater(cfg *config.Config, state dockerstate.TaskEngineState, dataClien
taskEngine engine.TaskEngine) *updater {
return &updater{
config: cfg,
httpclient: httpclient.New(updateDownloadTimeout, false, agentversion.String(), config.OSType),
httpclient: httpclient.New(updateDownloadTimeout, false),
state: state,
dataClient: dataClient,
taskEngine: taskEngine,
Expand Down
7 changes: 3 additions & 4 deletions agent/acs/updater/updater_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ import (
"github.com/aws/amazon-ecs-agent/agent/data"
"github.com/aws/amazon-ecs-agent/agent/engine"
"github.com/aws/amazon-ecs-agent/agent/engine/dockerstate"
agentversion "github.com/aws/amazon-ecs-agent/agent/version"
"github.com/aws/amazon-ecs-agent/agent/httpclient"
mock_http "github.com/aws/amazon-ecs-agent/agent/httpclient/mock"
"github.com/aws/amazon-ecs-agent/ecs-agent/acs/model/ecsacs"
"github.com/aws/amazon-ecs-agent/ecs-agent/httpclient"
mock_http "github.com/aws/amazon-ecs-agent/ecs-agent/httpclient/mock"
mock_client "github.com/aws/amazon-ecs-agent/ecs-agent/wsclient/mock"

"github.com/golang/mock/gomock"
Expand All @@ -59,7 +58,7 @@ func mocks(t *testing.T, cfg *config.Config) (*updater, *gomock.Controller, *moc

mockacs := mock_client.NewMockClientServer(ctrl)
mockhttp := mock_http.NewMockRoundTripper(ctrl)
httpClient := httpclient.New(updateDownloadTimeout, false, agentversion.String(), config.OSType)
httpClient := httpclient.New(updateDownloadTimeout, false)
httpClient.Transport.(httpclient.OverridableTransport).SetTransport(mockhttp)

u := NewUpdater(cfg, dockerstate.NewTaskEngineState(), data.NewNoopClient(),
Expand Down
13 changes: 0 additions & 13 deletions agent/api/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -1508,16 +1508,3 @@ func (c *Container) GetContainerPortRangeMap() map[string]string {
defer c.lock.RUnlock()
return c.ContainerPortRangeMap
}

func (c *Container) IsManagedDaemonContainer() bool {
c.lock.RLock()
defer c.lock.RUnlock()
return c.Type == ContainerManagedDaemon
}

func (c *Container) GetImageName() string {
c.lock.RLock()
defer c.lock.RUnlock()
containerImage := strings.Split(c.Image, ":")[0]
return containerImage
}
42 changes: 1 addition & 41 deletions agent/api/container/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,53 +130,13 @@ func TestIsInternal(t *testing.T) {
}

for _, tc := range testCases {
t.Run(fmt.Sprintf("IsInternal should return %t for %s", tc.internal, tc.container.String()),
t.Run(fmt.Sprintf("IsInternal shoukd return %t for %s", tc.internal, tc.container.String()),
func(t *testing.T) {
assert.Equal(t, tc.internal, tc.container.IsInternal())
})
}
}

func TestIsManagedDaemonContainer(t *testing.T) {
testCases := []struct {
container *Container
internal bool
isManagedDaemon bool
}{
{&Container{}, false, false},
{&Container{Type: ContainerNormal, Image: "someImage:latest"}, false, false},
{&Container{Type: ContainerManagedDaemon, Image: "someImage:latest"}, true, true},
}

for _, tc := range testCases {
t.Run(fmt.Sprintf("IsManagedDaemonContainer should return %t for %s", tc.isManagedDaemon, tc.container.String()),
func(t *testing.T) {
assert.Equal(t, tc.internal, tc.container.IsInternal())
ok := tc.container.IsManagedDaemonContainer()
assert.Equal(t, tc.isManagedDaemon, ok)
})
}
}

func TestGetImageName(t *testing.T) {
testCases := []struct {
container *Container
imageName string
}{
{&Container{}, ""},
{&Container{Image: "someImage:latest"}, "someImage"},
{&Container{Image: "someImage"}, "someImage"},
}

for _, tc := range testCases {
t.Run(fmt.Sprintf("GetImageName should return %s for %s", tc.imageName, tc.container.String()),
func(t *testing.T) {
imageName := tc.container.GetImageName()
assert.Equal(t, tc.imageName, imageName)
})
}
}

// TestSetupExecutionRoleFlag tests whether or not the container appropriately
// sets the flag for using execution roles
func TestSetupExecutionRoleFlag(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion agent/api/container/containertype.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ var stringToContainerType = map[string]ContainerType{
"EMPTY_HOST_VOLUME": ContainerEmptyHostVolume,
"CNI_PAUSE": ContainerCNIPause,
"NAMESPACE_PAUSE": ContainerNamespacePause,
"MANAGED_DAEMON": ContainerManagedDaemon,
}

// String converts the container type enum to a string
Expand Down
Loading

0 comments on commit cd649fa

Please sign in to comment.