Skip to content

Commit

Permalink
removed BDChild
Browse files Browse the repository at this point in the history
  • Loading branch information
mye956 committed Sep 11, 2023
1 parent f7c9b24 commit 7f1695b
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 129 deletions.
182 changes: 91 additions & 91 deletions agent/app/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ import (
"github.com/aws/aws-sdk-go/aws/awserr"
aws_credentials "github.com/aws/aws-sdk-go/aws/credentials"

// "github.com/aws/amazon-ecs-agent/ecs-agent/api/attachmentinfo"
// apira "github.com/aws/amazon-ecs-agent/ecs-agent/api/resource"
// "github.com/aws/amazon-ecs-agent/ecs-agent/api/status"
"github.com/aws/amazon-ecs-agent/ecs-agent/api/attachmentinfo"
apira "github.com/aws/amazon-ecs-agent/ecs-agent/api/resource"
"github.com/aws/amazon-ecs-agent/ecs-agent/api/status"

"github.com/cihub/seelog"
"github.com/pborman/uuid"
Expand Down Expand Up @@ -473,94 +473,94 @@ func (agent *ecsAgent) doStart(containerChangeEventStream *eventstream.EventStre
agent.startAsyncRoutines(containerChangeEventStream, credentialsManager, imageManager,
taskEngine, deregisterInstanceEventStream, client, taskHandler, attachmentEventHandler, state, doctor)

// tempAttachmentProperties := map[string]string{
// apira.ResourceTypeName: apira.ElasticBlockStorage,
// apira.RequestedSizeName: "5",
// apira.VolumeSizeInGiBName: "7",
// apira.DeviceName: "/dev/nvme1n1",
// apira.VolumeIdName: "vol-09b1fc99d3b9654a5",
// apira.FileSystemTypeName: "testXFS",
// }

// duration := time.Now().Add(2000000 * time.Millisecond)

// if err := agent.startEBSWatcher(state, taskEngine.StateChangeEvents()); err != nil {
// seelog.Criticalf("Unable to start EBS watcher")
// return exitcodes.ExitTerminal
// }

// go agent.ebsWatcher.HandleResourceAttachment(&apira.ResourceAttachment{
// AttachmentInfo: attachmentinfo.AttachmentInfo{
// AttachmentARN: "dummy-arn",
// Status: status.AttachmentNone,
// ExpiresAt: duration,
// AttachStatusSent: false,
// ClusterARN: "dummy-cluster-arn",
// ContainerInstanceARN: "dummy-container-instance-arn",
// },
// AttachmentProperties: tempAttachmentProperties,
// })

// tempAttachmentProperties2 := map[string]string{
// apira.ResourceTypeName: apira.ElasticBlockStorage,
// apira.RequestedSizeName: "5",
// apira.VolumeSizeInGiBName: "7",
// apira.DeviceName: "/dev/nvme1n1",
// apira.VolumeIdName: "vol-09b1fc99d3b9654a1",
// apira.FileSystemTypeName: "testXFS",
// }

// go agent.ebsWatcher.HandleResourceAttachment(&apira.ResourceAttachment{
// AttachmentInfo: attachmentinfo.AttachmentInfo{
// AttachmentARN: "dummy-arn2",
// Status: status.AttachmentNone,
// ExpiresAt: time.Now().Add(30000 * time.Millisecond),
// AttachStatusSent: false,
// ClusterARN: "dummy-cluster-arn2",
// ContainerInstanceARN: "dummy-container-instance-arn2",
// },
// AttachmentProperties: tempAttachmentProperties2,
// })

// tempAttachmentProperties3 := map[string]string{
// apira.ResourceTypeName: apira.ElasticBlockStorage,
// apira.RequestedSizeName: "10",
// apira.VolumeSizeInGiBName: "7",
// apira.DeviceName: "/dev/nvme3n1",
// apira.VolumeIdName: "vol-0797268b9cfec8c66",
// apira.FileSystemTypeName: "testXFS",
// }
// go agent.ebsWatcher.HandleResourceAttachment(&apira.ResourceAttachment{
// AttachmentInfo: attachmentinfo.AttachmentInfo{
// AttachmentARN: "dummy-arn3",
// Status: status.AttachmentNone,
// ExpiresAt: time.Now().Add(360000 * time.Millisecond),
// AttachStatusSent: false,
// ClusterARN: "dummy-cluster-arn3",
// ContainerInstanceARN: "dummy-container-instance-arn3",
// },
// AttachmentProperties: tempAttachmentProperties3,
// })

// tempAttachmentProperties4 := map[string]string{
// apira.ResourceTypeName: apira.ElasticBlockStorage,
// apira.RequestedSizeName: "10",
// apira.VolumeSizeInGiBName: "7",
// apira.DeviceName: "/dev/nvme4n1",
// apira.VolumeIdName: "vol-0797268b9cfec8c61",
// apira.FileSystemTypeName: "testXFS",
// }
// go agent.ebsWatcher.HandleResourceAttachment(&apira.ResourceAttachment{
// AttachmentInfo: attachmentinfo.AttachmentInfo{
// AttachmentARN: "dummy-arn4",
// Status: status.AttachmentNone,
// ExpiresAt: time.Now().Add(20000 * time.Millisecond),
// AttachStatusSent: false,
// ClusterARN: "dummy-cluster-arn4",
// ContainerInstanceARN: "dummy-container-instance-arn4",
// },
// AttachmentProperties: tempAttachmentProperties4,
// })
tempAttachmentProperties := map[string]string{
apira.ResourceTypeName: apira.ElasticBlockStorage,
apira.RequestedSizeName: "5",
apira.VolumeSizeInGiBName: "7",
apira.DeviceName: "/dev/nvme1n1",
apira.VolumeIdName: "vol-09b1fc99d3b9654a5",
apira.FileSystemTypeName: "testXFS",
}

duration := time.Now().Add(2000000 * time.Millisecond)

if err := agent.startEBSWatcher(state, taskEngine.StateChangeEvents()); err != nil {
seelog.Criticalf("Unable to start EBS watcher")
return exitcodes.ExitTerminal
}

go agent.ebsWatcher.HandleResourceAttachment(&apira.ResourceAttachment{
AttachmentInfo: attachmentinfo.AttachmentInfo{
AttachmentARN: "dummy-arn",
Status: status.AttachmentNone,
ExpiresAt: duration,
AttachStatusSent: false,
ClusterARN: "dummy-cluster-arn",
ContainerInstanceARN: "dummy-container-instance-arn",
},
AttachmentProperties: tempAttachmentProperties,
})

tempAttachmentProperties2 := map[string]string{
apira.ResourceTypeName: apira.ElasticBlockStorage,
apira.RequestedSizeName: "5",
apira.VolumeSizeInGiBName: "7",
apira.DeviceName: "/dev/nvme1n1",
apira.VolumeIdName: "vol-09b1fc99d3b9654a1",
apira.FileSystemTypeName: "testXFS",
}

go agent.ebsWatcher.HandleResourceAttachment(&apira.ResourceAttachment{
AttachmentInfo: attachmentinfo.AttachmentInfo{
AttachmentARN: "dummy-arn2",
Status: status.AttachmentNone,
ExpiresAt: time.Now().Add(30000 * time.Millisecond),
AttachStatusSent: false,
ClusterARN: "dummy-cluster-arn2",
ContainerInstanceARN: "dummy-container-instance-arn2",
},
AttachmentProperties: tempAttachmentProperties2,
})

tempAttachmentProperties3 := map[string]string{
apira.ResourceTypeName: apira.ElasticBlockStorage,
apira.RequestedSizeName: "10",
apira.VolumeSizeInGiBName: "7",
apira.DeviceName: "/dev/nvme3n1",
apira.VolumeIdName: "vol-0797268b9cfec8c66",
apira.FileSystemTypeName: "testXFS",
}
go agent.ebsWatcher.HandleResourceAttachment(&apira.ResourceAttachment{
AttachmentInfo: attachmentinfo.AttachmentInfo{
AttachmentARN: "dummy-arn3",
Status: status.AttachmentNone,
ExpiresAt: time.Now().Add(360000 * time.Millisecond),
AttachStatusSent: false,
ClusterARN: "dummy-cluster-arn3",
ContainerInstanceARN: "dummy-container-instance-arn3",
},
AttachmentProperties: tempAttachmentProperties3,
})

tempAttachmentProperties4 := map[string]string{
apira.ResourceTypeName: apira.ElasticBlockStorage,
apira.RequestedSizeName: "10",
apira.VolumeSizeInGiBName: "7",
apira.DeviceName: "/dev/nvme4n1",
apira.VolumeIdName: "vol-0797268b9cfec8c61",
apira.FileSystemTypeName: "testXFS",
}
go agent.ebsWatcher.HandleResourceAttachment(&apira.ResourceAttachment{
AttachmentInfo: attachmentinfo.AttachmentInfo{
AttachmentARN: "dummy-arn4",
Status: status.AttachmentNone,
ExpiresAt: time.Now().Add(20000 * time.Millisecond),
AttachStatusSent: false,
ClusterARN: "dummy-cluster-arn4",
ContainerInstanceARN: "dummy-container-instance-arn4",
},
AttachmentProperties: tempAttachmentProperties4,
})

// Start the acs session, which should block doStart
return agent.startACSSession(credentialsManager, taskEngine,
Expand Down
20 changes: 10 additions & 10 deletions agent/app/agent_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
asmfactory "github.com/aws/amazon-ecs-agent/agent/asm/factory"
"github.com/aws/amazon-ecs-agent/agent/config"

// ebs "github.com/aws/amazon-ecs-agent/agent/ebs"
ebs "github.com/aws/amazon-ecs-agent/agent/ebs"
"github.com/aws/amazon-ecs-agent/agent/ecscni"
"github.com/aws/amazon-ecs-agent/agent/engine"
"github.com/aws/amazon-ecs-agent/agent/engine/dockerstate"
Expand Down Expand Up @@ -151,16 +151,16 @@ func (agent *ecsAgent) startENIWatcher(state dockerstate.TaskEngineState, stateC
return nil
}

// func (agent *ecsAgent) startEBSWatcher(state dockerstate.TaskEngineState, stateChangeEvents chan<- statechange.Event) error {
// seelog.Debug("Setting up EBS Watcher...")
// if agent.ebsWatcher == nil {
// seelog.Debug("Creating new EBS watcher...")
// agent.ebsWatcher = ebs.NewWatcher(agent.ctx, state, stateChangeEvents)
func (agent *ecsAgent) startEBSWatcher(state dockerstate.TaskEngineState, stateChangeEvents chan<- statechange.Event) error {
seelog.Debug("Setting up EBS Watcher...")
if agent.ebsWatcher == nil {
seelog.Debug("Creating new EBS watcher...")
agent.ebsWatcher = ebs.NewWatcher(agent.ctx, state, stateChangeEvents)

// go agent.ebsWatcher.Start()
// }
// return nil
// }
go agent.ebsWatcher.Start()
}
return nil
}

// initializeResourceFields exists mainly for testing doStart() to use mock Control
// object
Expand Down
18 changes: 9 additions & 9 deletions agent/app/agent_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
asmfactory "github.com/aws/amazon-ecs-agent/agent/asm/factory"
"github.com/aws/amazon-ecs-agent/agent/data"

// ebs "github.com/aws/amazon-ecs-agent/agent/ebs"
ebs "github.com/aws/amazon-ecs-agent/agent/ebs"
"github.com/aws/amazon-ecs-agent/agent/ecscni"
"github.com/aws/amazon-ecs-agent/agent/engine"
"github.com/aws/amazon-ecs-agent/agent/engine/dockerstate"
Expand Down Expand Up @@ -352,15 +352,15 @@ func (agent *ecsAgent) startENIWatcher(state dockerstate.TaskEngineState, stateC
return nil
}

// func (agent *ecsAgent) startEBSWatcher(state dockerstate.TaskEngineState, stateChangeEvents chan<- statechange.Event) error {
// seelog.Debug("Setting up EBS Watcher...")
// if agent.ebsWatcher == nil {
// agent.ebsWatcher = ebs.NewWatcher(agent.ctx, state, stateChangeEvents)
func (agent *ecsAgent) startEBSWatcher(state dockerstate.TaskEngineState, stateChangeEvents chan<- statechange.Event) error {
seelog.Debug("Setting up EBS Watcher...")
if agent.ebsWatcher == nil {
agent.ebsWatcher = ebs.NewWatcher(agent.ctx, state, stateChangeEvents)

// go agent.ebsWatcher.Start()
// }
// return nil
// }
go agent.ebsWatcher.Start()
}
return nil
}

// This function verifies that the plugins are available at the given path
// When each plugin is executed with --capabilities then it returns a string representing its capabilities
Expand Down
2 changes: 1 addition & 1 deletion agent/ebs/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (w *EBSWatcher) Start() {
log.Info("Pending attachments to be found...")
foundVolumes := apiebs.ScanEBSVolumes(pendingEBS, w.discoveryClient)
w.NotifyFound(foundVolumes)
w.agentState.RemoveExpiredEBSVolumes()
// w.agentState.RemoveExpiredEBSVolumes()
} else {
log.Info("No volumes to find.")
}
Expand Down
4 changes: 2 additions & 2 deletions agent/engine/dockerstate/docker_task_engine_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func (state *DockerTaskEngineState) GetAllPendingEBSAttachments() []*apiresource
func (state *DockerTaskEngineState) allPendingEBSAttachmentsUnsafe() []*apiresource.ResourceAttachment {
var pendingEBSAttachments []*apiresource.ResourceAttachment
for _, v := range state.ebsAttachments {
if !v.IsAttached() {
if !v.IsAttached() && !v.IsSent() {
pendingEBSAttachments = append(pendingEBSAttachments, v)
}
}
Expand All @@ -320,7 +320,7 @@ func (state *DockerTaskEngineState) GetAllPendingEBSAttachmentWithKey() map[stri
func (state *DockerTaskEngineState) allPendingEBSAttachmentsWithKeyUnsafe() map[string]*apiresource.ResourceAttachment {
pendingEBSAttachments := make(map[string]*apiresource.ResourceAttachment)
for k, v := range state.ebsAttachments {
if !v.IsAttached() {
if !v.IsAttached() && !v.IsSent() {
pendingEBSAttachments[k] = v
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ecs-agent/api/resource/ebs_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
const (
ebsnvmeIDTimeoutDuration = 5 * time.Second
ebsResourceKeyPrefix = "ebs-volume:"
ScanPeriod = 500 * time.Millisecond
ScanPeriod = 300 * time.Second
)

var (
Expand Down
14 changes: 7 additions & 7 deletions ecs-agent/api/resource/ebs_discovery_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ type LsblkOutput struct {
BlockDevies []BD `json:"blockdevices"`
}
type BD struct {
Name string `json:"name"`
Serial string `json:"serial"`
Children []BDChild `json:"children"`
Name string `json:"name"`
Serial string `json:"serial"`
Children []*BD `json:"children,omitempty"`
}

type BDChild struct {
Name string `json:"name"`
Serial string `json:"serial"`
}
// type BDChild struct {
// Name string `json:"name"`
// Serial string `json:"serial"`
// }

func (api *EBSDiscoveryClient) ConfirmEBSVolumeIsAttached(deviceName, volumeID string) error {
var lsblkOut LsblkOutput
Expand Down

0 comments on commit 7f1695b

Please sign in to comment.