Esempio n. 1
0
func (p *taskProcessor) processActiveContainer(logger lager.Logger, container executor.Container) {
	ok := p.startTask(logger, container.Guid)
	if !ok {
		return
	}

	task, err := p.bbsClient.TaskByGuid(container.Guid)
	if err != nil {
		logger.Error("failed-fetching-task", err)
		return
	}

	runReq, err := rep.NewRunRequestFromTask(task)
	if err != nil {
		logger.Error("failed-to-construct-run-request", err)
		return
	}

	ok = p.containerDelegate.RunContainer(logger, &runReq)
	if !ok {
		p.failTask(logger, container.Guid, TaskCompletionReasonFailedToRunContainer)
	}
}
Esempio n. 2
0
				runReq, err := rep.NewRunRequestFromDesiredLRP(containerGuid, desiredLRP, &actualLRP.ActualLRPKey, &actualLRP.ActualLRPInstanceKey)
				Expect(err).NotTo(HaveOccurred())
				Expect(runReq.DiskScope).To(Equal(executor.TotalDiskLimit))
			})
		})
	})

	Describe("NewRunRequestFromTask", func() {
		var task *models.Task
		BeforeEach(func() {
			task = model_helpers.NewValidTask("task-guid")
			task.RootFs = "preloaded://rootfs"
		})

		It("returns a valid run request", func() {
			runReq, err := rep.NewRunRequestFromTask(task)
			Expect(err).NotTo(HaveOccurred())
			Expect(runReq.Tags).To(Equal(executor.Tags{
				rep.ResultFileTag: task.ResultFile,
			}))

			Expect(runReq.RunInfo).To(Equal(executor.RunInfo{
				DiskScope:  executor.ExclusiveDiskLimit,
				CPUWeight:  uint(task.CpuWeight),
				Privileged: task.Privileged,

				LogConfig: executor.LogConfig{
					Guid:       task.LogGuid,
					SourceName: task.LogSource,
				},
				MetricsConfig: executor.MetricsConfig{
Esempio n. 3
0
			Expect(err).NotTo(HaveOccurred())

			Expect(task.State).To(Equal(models.Task_Running))
		})
	}

	itRunsTheContainer := func(logger *lagertest.TestLogger) {
		itSetsTheTaskToRunning(logger)

		It("runs the container", func() {
			Expect(containerDelegate.RunContainerCallCount()).To(Equal(1))

			task, err := bbsClient.TaskByGuid(taskGuid)
			Expect(err).NotTo(HaveOccurred())

			expectedRunRequest, err := rep.NewRunRequestFromTask(task)
			Expect(err).NotTo(HaveOccurred())

			_, runRequest := containerDelegate.RunContainerArgsForCall(0)
			Expect(*runRequest).To(Equal(expectedRunRequest))
		})

		Context("when running the container fails", func() {
			BeforeEach(func() {
				containerDelegate.RunContainerReturns(false)
			})

			itCompletesTheTaskWithFailure("failed to run container")(logger)
		})
	}