Skip to content

Commit

Permalink
wip2
Browse files Browse the repository at this point in the history
  • Loading branch information
sparrc committed Jun 1, 2020
1 parent a871326 commit 74f909f
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 68 deletions.
6 changes: 0 additions & 6 deletions agent/api/task/task_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
)

const (
defaultCPUPeriod = 100 * time.Millisecond // 100ms
// With a 100ms CPU period, we can express 0.01 vCPU to 10 vCPUs
maxTaskVCPULimit = 10
// Reference: http://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ContainerDefinition.html
Expand Down Expand Up @@ -231,11 +230,6 @@ func (task *Task) initializeCredentialSpecResource(config *config.Config, creden
return errors.New("task credentialspec is only supported on windows")
}

// getAllCredentialSpecRequirements is used to build all the credential spec requirements for the task
func (task *Task) getAllCredentialSpecRequirements() []string {
return nil
}

// GetCredentialSpecResource retrieves credentialspec resource from resource map
func (task *Task) GetCredentialSpecResource() ([]taskresource.TaskResource, bool) {
return []taskresource.TaskResource{}, false
Expand Down
2 changes: 2 additions & 0 deletions agent/api/task/task_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ const (
testTaskDefVersion = "1"
testRegion = "testRegion"
testExecutionCredentialsID = "testExecutionCredentialsID"

defaultCPUPeriod = 100 * time.Millisecond // 100ms
)

func TestAddNetworkResourceProvisioningDependencyNop(t *testing.T) {
Expand Down
9 changes: 0 additions & 9 deletions agent/engine/dependencygraph/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,6 @@ func verifyContainerDependenciesResolvedForResource(target taskresource.TaskReso
return true
}

func linksToContainerNames(links []string) []string {
names := make([]string, 0, len(links))
for _, link := range links {
name := strings.Split(link, ":")[0]
names = append(names, name)
}
return names
}

func executionCredentialsResolved(target *apicontainer.Container, id string, manager credentials.Manager) bool {
if target.GetKnownStatus() >= apicontainerstatus.ContainerPulled ||
!target.ShouldPullWithExecutionRole() ||
Expand Down
10 changes: 2 additions & 8 deletions agent/engine/task_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import (
"github.com/aws/amazon-ecs-agent/agent/utils/ttime"

"github.com/cihub/seelog"
"github.com/pkg/errors"
)

const (
Expand All @@ -58,15 +57,10 @@ const (
)

var (
_stoppedSentWaitInterval = stoppedSentWaitInterval
_maxStoppedWaitTimes = int(maxStoppedWaitTimes)
taskNotWaitForSteadyStateError = errors.New("managed task: steady state check context is nil")
_stoppedSentWaitInterval = stoppedSentWaitInterval
_maxStoppedWaitTimes = int(maxStoppedWaitTimes)
)

type acsTaskUpdate struct {
apitaskstatus.TaskStatus
}

type dockerContainerChange struct {
container *apicontainer.Container
event dockerapi.DockerContainerChangeEvent
Expand Down
9 changes: 0 additions & 9 deletions agent/eventhandler/task_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,15 +390,6 @@ func (taskEvents *taskSendableEvents) toStringUnsafe() string {
taskEvents.taskARN, taskEvents.sending, taskEvents.createdAt.String())
}

// getTasksToEventsLen returns the length of the tasksToEvents map. It is
// used only in the test code to ascertain that map has been cleaned up
func (handler *TaskHandler) getTasksToEventsLen() int {
handler.lock.RLock()
defer handler.lock.RUnlock()

return len(handler.tasksToEvents)
}

// handleInvalidParamException removes the event from event queue when its parameters are
// invalid to reduce redundant API call
func handleInvalidParamException(err error, events *list.List, eventToSubmit *list.Element) {
Expand Down
11 changes: 10 additions & 1 deletion agent/eventhandler/task_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,22 @@ func TestCleanupTaskEventAfterSubmit(t *testing.T) {

// Wait for task events to be removed from the tasksToEvents map
for {
if handler.getTasksToEventsLen() == 0 {
if getTasksToEventsLen(handler) == 0 {
break
}
time.Sleep(time.Millisecond)
}
}

// getTasksToEventsLen returns the length of the tasksToEvents map. It is
// used only in the test code to ascertain that map has been cleaned up
func getTasksToEventsLen(handler *TaskHandler) int {
handler.lock.RLock()
defer handler.lock.RUnlock()

return len(handler.tasksToEvents)
}

func containerEvent(arn string) statechange.Event {
return api.ContainerStateChange{TaskArn: arn, ContainerName: "containerName", Status: apicontainerstatus.ContainerRunning, Container: &apicontainer.Container{}}
}
Expand Down
8 changes: 0 additions & 8 deletions agent/eventhandler/task_handler_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@ type sendableEvent struct {
lock sync.RWMutex
}

func newSendableContainerEvent(event api.ContainerStateChange) *sendableEvent {
return &sendableEvent{
isContainerEvent: true,
containerSent: false,
containerChange: event,
}
}

func newSendableTaskEvent(event api.TaskStateChange) *sendableEvent {
return &sendableEvent{
isContainerEvent: false,
Expand Down
8 changes: 8 additions & 0 deletions agent/eventhandler/task_handler_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ import (
"github.com/stretchr/testify/assert"
)

func newSendableContainerEvent(event api.ContainerStateChange) *sendableEvent {
return &sendableEvent{
isContainerEvent: true,
containerSent: false,
containerChange: event,
}
}

func TestShouldContainerEventBeSent(t *testing.T) {
event := newSendableContainerEvent(api.ContainerStateChange{
Status: apicontainerstatus.ContainerStopped,
Expand Down
2 changes: 0 additions & 2 deletions agent/httpclient/httpclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import (
"github.com/aws/amazon-ecs-agent/agent/version"
)

const defaultTimeout = 10 * time.Minute

// Taken from the default http.Client behavior
const defaultDialTimeout = 30 * time.Second
const defaultDialKeepalive = 30 * time.Second
Expand Down
6 changes: 0 additions & 6 deletions agent/metrics/generic_metrics_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,6 @@ func (gm *GenericMetrics) FireCallEnd(callHash, callName string, timestamp time.
}
}

// Simple Timeout function
func startTimeout(timeout chan bool) {
time.Sleep(callTimeout)
timeout <- true
}

// This function increments the call count for a specific API call
// This is invoked at the API call's start, whereas the duration metrics
// are updated at the API call's end.
Expand Down
2 changes: 0 additions & 2 deletions agent/metrics/metrics_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package metrics

import (
"context"
"fmt"
"net/http"
"time"
Expand All @@ -29,7 +28,6 @@ type APIType int32
type MetricsEngine struct {
collection bool
cfg *config.Config
ctx context.Context
Registry *prometheus.Registry
managedMetrics map[APIType]MetricsClient
}
Expand Down
4 changes: 0 additions & 4 deletions agent/stats/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ import (
"github.com/docker/docker/api/types"
)

// networkStatsErrorPattern defines the pattern that is used to evaluate
// if there's an error reading network stats.
const networkStatsErrorPattern = "open /sys/class/net/veth.*: no such file or directory"

var numCores = uint64(runtime.NumCPU())

// nan32 returns a 32bit NaN.
Expand Down
12 changes: 12 additions & 0 deletions agent/taskresource/credentialspec/credentialspec_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ import (
"github.com/pkg/errors"
)

const (
tempFileName = "temp_file"
// filePerm is the permission for the credentialspec file.
filePerm = 0644

s3DownloadTimeout = 30 * time.Second

// Environment variables to setup resource location
envProgramData = "ProgramData"
dockerCredentialSpecDataDir = "docker/credentialspecs"
)

// CredentialSpecResource is the abstraction for credentialspec resources
type CredentialSpecResource struct {
taskARN string
Expand Down
13 changes: 0 additions & 13 deletions agent/taskresource/credentialspec/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,7 @@

package credentialspec

import "time"

const (
// ResourceName is the name of the credentialspec resource
ResourceName = "credentialspec"

tempFileName = "temp_file"

// filePerm is the permission for the credentialspec file.
filePerm = 0644

s3DownloadTimeout = 30 * time.Second

// Environment variables to setup resource location
envProgramData = "ProgramData"
dockerCredentialSpecDataDir = "docker/credentialspecs"
)

0 comments on commit 74f909f

Please sign in to comment.