// IsRunning returns if the container with the given id is running
333597
func (e *Executor) IsRunning(id string) (bool, error) {
	status, err := e.client.Status(context.Background(), id)
	return status == containerd.Running, err
}
921423
func (podStatus *PodStatus) GetRunningContainerStatuses() []*ContainerStatus {
	runningContainerStatuses := []*ContainerStatus{}
	for _, containerStatus := range podStatus.ContainerStatuses {
		if containerStatus.State == ContainerStateRunning {
			runningContainerStatuses = append(runningContainerStatuses, containerStatus)
		}
	}
	return runningContainerStatuses
}
53420
func (c *Client) IsRunning() bool {
	c.mu.RLock()
	defer c.mu.RUnlock()
	return c.running
}
606674
func (c *Container) IsRunning(ctx context.Context) (bool, error) {
	return false, project.ErrUnsupported
}
1372702
func (s *Server) RunningChildren(job *structs.Job) (bool, error) {
	state, err := s.fsm.State().Snapshot()
	if err != nil {
		return false, err
	}

	ws := memdb.NewWatchSet()
	prefix := fmt.Sprintf("%s%s", job.ID, structs.PeriodicLaunchSuffix)
	iter, err := state.JobsByIDPrefix(ws, job.Namespace, prefix)
	if err != nil {
		return false, err
	}

	var child *structs.Job
	for i := iter.Next(); i != nil; i = iter.Next() {
		child = i.(*structs.Job)

		// Ensure the job is actually a child.
		if child.ParentID != job.ID {
			continue
		}

		// Get the childs evaluations.
		evals, err := state.EvalsByJob(ws, child.Namespace, child.ID)
		if err != nil {
			return false, err
		}

		// Check if any of the evals are active or have running allocations.
		for _, eval := range evals {
			if !eval.TerminalStatus() {
				return true, nil
			}

			allocs, err := state.AllocsByEval(ws, eval.ID)
			if err != nil {
				return false, err
			}

			for _, alloc := range allocs {
				if !alloc.TerminalStatus() {
					return true, nil
				}
			}
		}
	}

	// There are no evals or allocations that aren't terminal.
	return false, nil
}
397439
func (e *EncodeSession) Running() (running bool) {
	e.Lock()
	running = e.running
	e.Unlock()
	return
}
437637
func IsRunning(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt) {
	client := p.Get("client", nil).(Getter)
	count := p.Get("count", 20).(int)
	for i := 0; i < count; i++ {
		_, err := client.Get("/", false, false)
		if err == nil {
			return true, nil
		}
		log.Infof(c, "Waiting for etcd to come online.")
		time.Sleep(250 * time.Millisecond)
	}
	log.Errf(c, "Etcd is not answering after %d attempts.", count)
	return false, &cookoo.FatalError{"Could not connect to Etcd."}
}
890773
func (c *vaultClient) isRunning() bool {
	c.lock.RLock()
	defer c.lock.RUnlock()
	return c.running
}
1363035
func (v *ProcTableImpl) IsRunning(pvName string) bool {
	v.mutex.RLock()
	defer v.mutex.RUnlock()

	if entry, ok := v.procTable[pvName]; !ok || entry.Status != CSRunning {
		return false
	}

	return true
}
802135
func (ws *watcherState) handlingContainerID(id string) bool {
	ws.Lock()
	defer ws.Unlock()

	_, handled := ws.events[id]
	return handled
}
1305464
func (s *ComputeCapacityStatus) SetRunning(v int64) *ComputeCapacityStatus {
	s.Running = &v
	return s
}
792750
func (p *Pod) IsAfterRun() bool {
	return p.isExitedDeleting || p.isDeleting || p.isExited || p.isGarbage
}
310363
func (tl *TaskLogger) IsRunning() bool {
	if tl.lro != nil && tl.lro.isRunning() {
		return true
	}
	if tl.lre != nil && tl.lre.isRunning() {
		return true
	}

	return false
}
561829
func (c *criClient) IgnoreRunningWorkloads() {
	if c == nil {
		return
	}

	req := &criRuntime.ListPodSandboxRequest{}

	resp, err := c.RuntimeServiceClient.ListPodSandbox(context.Background(), req)
	if err != nil {
		log.WithError(err).Error("unable to get list of pods running")
		return
	}
	for _, pod := range resp.GetItems() {
		scopedLog := log.WithField(logfields.ContainerID, pod.GetId())
		scopedLog.Info("Adding running container to the list of ignored containers")
		startIgnoringContainer(pod.GetId())
		ctx := namespaces.WithNamespace(context.Background(), k8sContainerdNamespace)
		pssr := criRuntime.PodSandboxStatusRequest{
			PodSandboxId: pod.GetId(),
		}
		cont, err := c.RuntimeServiceClient.PodSandboxStatus(ctx, &pssr)
		if err != nil {
			continue
		}
		cIP := c.getCiliumIP(cont.GetStatus())
		if cIP == nil {
			continue
		}
		if err := allocator.AllocateIP(cIP.IP(), "ignored workload"); err != nil {
			continue
		}
		//TODO Release this address when the ignored container leaves
		scopedLog.WithFields(logrus.Fields{
			logfields.IPAddr: cIP.IP(),
		}).Info("Found container running with potential " +
			"collision IP address, adding to the list " +
			"of allocated IPs")
	}
}
941108
func (s *server) Running() bool {
	s.mutex.RLock()
	defer s.mutex.RUnlock()
	return (s.state != Stopped && s.state != Initialized)
}
190175
func PodRunning(event watch.Event) (bool, error) {
	switch event.Type {
	case watch.Deleted:
		return false, errors.NewNotFound(schema.GroupResource{Resource: "pods"}, "")
	}
	switch t := event.Object.(type) {
	case *v1.Pod:
		switch t.Status.Phase {
		case v1.PodRunning:
			return true, nil
		case v1.PodFailed, v1.PodSucceeded:
			return false, ErrPodCompleted
		}
	}
	return false, nil
}
438115
func (t TaskService) FindRunByID(ctx context.Context, taskID, runID platform.ID) (*platform.Run, error) {
	span, _ := tracing.StartSpanFromContext(ctx)
	defer span.Finish()

	u, err := newURL(t.Addr, taskIDRunIDPath(taskID, runID))
	if err != nil {
		return nil, err
	}

	req, err := http.NewRequest("GET", u.String(), nil)
	if err != nil {
		return nil, err
	}

	SetToken(t.Token, req)
	tracing.InjectToHTTPRequest(span, req)

	hc := newClient(u.Scheme, t.InsecureSkipVerify)

	resp, err := hc.Do(req)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	if err := CheckError(resp); err != nil {
		if platform.ErrorCode(err) == platform.ENotFound {
			// ErrRunNotFound is expected as part of the FindRunByID contract,
			// so return that actual error instead of a different error that looks like it.
			// TODO cleanup backend error implementation
			return nil, backend.ErrRunNotFound
		}

		return nil, err
	}
	var rs = &runResponse{}
	if err := json.NewDecoder(resp.Body).Decode(rs); err != nil {
		return nil, err
	}
	return &rs.Run, nil
}