当前位置: 首页>>代码示例>>Golang>>正文


Golang Container.GetKnownStatus方法代码示例

本文整理汇总了Golang中github.com/aws/amazon-ecs-agent/agent/api.Container.GetKnownStatus方法的典型用法代码示例。如果您正苦于以下问题:Golang Container.GetKnownStatus方法的具体用法?Golang Container.GetKnownStatus怎么用?Golang Container.GetKnownStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/aws/amazon-ecs-agent/agent/api.Container的用法示例。


在下文中一共展示了Container.GetKnownStatus方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: containerNextState

// containerNextState determines the next state a container should go to.
// It returns: The state it should transition to, a bool indicating whether any
// action is required, and a bool indicating whether a known status change is
// possible.
// 'Stopped, false, true' -> "You can move it to known stopped, but you don't have to call a transition function"
// 'Running, true, true' -> "You can move it to running and you need to call the transition function"
// 'None, false, false' -> "This should not be moved; it has unresolved dependencies or is complete; no knownstatus change"
func (mtask *managedTask) containerNextState(container *api.Container) (api.ContainerStatus, bool, bool) {
	clog := log.New("task", mtask.Task, "container", container)
	containerKnownStatus := container.GetKnownStatus()
	containerDesiredStatus := container.GetDesiredStatus()
	if containerKnownStatus == containerDesiredStatus {
		clog.Debug("Container at desired status", "desired", containerDesiredStatus)
		return api.ContainerStatusNone, false, false
	}
	if containerKnownStatus > containerDesiredStatus {
		clog.Debug("Container past desired status")
		return api.ContainerStatusNone, false, false
	}
	if !dependencygraph.DependenciesAreResolved(container, mtask.Containers) {
		clog.Debug("Can't apply state to container yet; dependencies unresolved", "state", containerDesiredStatus)
		return api.ContainerStatusNone, false, false
	}

	var nextState api.ContainerStatus
	if container.DesiredTerminal() {
		nextState = api.ContainerStopped
		if containerKnownStatus != api.ContainerRunning {
			// If it's not currently running we do not need to do anything to make it become stopped.
			return nextState, false, true
		}
	} else {
		nextState = containerKnownStatus + 1
	}
	return nextState, true, true
}
开发者ID:umaptechnologies,项目名称:amazon-ecs-agent,代码行数:36,代码来源:task_manager.go

示例2: emitContainerEvent

// emitContainerEvent passes a given event up through the containerEvents channel if necessary.
// It will omit events the backend would not process and will perform best-effort deduplication of events.
func (engine *DockerTaskEngine) emitContainerEvent(task *api.Task, cont *api.Container, reason string) {
	contKnownStatus := cont.GetKnownStatus()
	if !contKnownStatus.BackendRecognized() {
		return
	}
	if cont.IsInternal {
		return
	}
	if cont.SentStatus >= contKnownStatus {
		log.Debug("Already sent container event; no need to re-send", "task", task.Arn, "container", cont.Name, "event", contKnownStatus.String())
		return
	}

	if reason == "" && cont.ApplyingError != nil {
		reason = cont.ApplyingError.Error()
	}
	event := api.ContainerStateChange{
		TaskArn:       task.Arn,
		ContainerName: cont.Name,
		Status:        contKnownStatus,
		ExitCode:      cont.KnownExitCode,
		PortBindings:  cont.KnownPortBindings,
		Reason:        reason,
		SentStatus:    &cont.SentStatus,
	}
	log.Debug("Container change event", "event", event)
	engine.containerEvents <- event
	log.Debug("Container change event passed on", "event", event)
}
开发者ID:umaptechnologies,项目名称:amazon-ecs-agent,代码行数:31,代码来源:docker_task_engine.go

示例3: linkIsResolved

func linkIsResolved(target *api.Container, link *api.Container) bool {
	targetDesiredStatus := target.GetDesiredStatus()
	if targetDesiredStatus == api.ContainerCreated {
		knownStatus := link.GetKnownStatus()
		return knownStatus == api.ContainerCreated || knownStatus == api.ContainerRunning
	} else if targetDesiredStatus == api.ContainerRunning {
		return link.GetKnownStatus() == api.ContainerRunning
	}
	log.Error("Unexpected desired status", "target", target)
	return false
}
开发者ID:umaptechnologies,项目名称:amazon-ecs-agent,代码行数:11,代码来源:graph.go

示例4: volumeIsResolved

func volumeIsResolved(target *api.Container, volume *api.Container) bool {
	targetDesiredStatus := target.GetDesiredStatus()
	if targetDesiredStatus == api.ContainerCreated || targetDesiredStatus == api.ContainerRunning {
		knownStatus := volume.GetKnownStatus()
		return knownStatus == api.ContainerCreated ||
			knownStatus == api.ContainerRunning ||
			knownStatus == api.ContainerStopped
	}

	log.Error("Unexpected desired status", "target", target)
	return false
}
开发者ID:umaptechnologies,项目名称:amazon-ecs-agent,代码行数:12,代码来源:graph.go

示例5: onRunIsResolved

// onRunIsResolved defines a relationship where a target cannot be created until
// 'run' has reached a running state.
func onRunIsResolved(target *api.Container, run *api.Container) bool {
	if target.GetDesiredStatus() >= api.ContainerCreated {
		return run.GetKnownStatus() >= api.ContainerRunning
	}
	return false
}
开发者ID:umaptechnologies,项目名称:amazon-ecs-agent,代码行数:8,代码来源:graph.go


注:本文中的github.com/aws/amazon-ecs-agent/agent/api.Container.GetKnownStatus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。