コード例 #1
0
func (p *ordinaryLRPProcessor) processReservedContainer(logger lager.Logger, lrpContainer *lrpContainer) {
	logger = logger.Session("process-reserved-container")
	ok := p.claimLRPContainer(logger, lrpContainer)
	if !ok {
		return
	}

	desired, err := p.bbsClient.DesiredLRPByProcessGuid(lrpContainer.ProcessGuid)
	if err != nil {
		logger.Error("failed-to-fetch-desired", err)
		return
	}

	runReq, err := rep.NewRunRequestFromDesiredLRP(lrpContainer.Guid, desired, lrpContainer.ActualLRPKey, lrpContainer.ActualLRPInstanceKey)
	if err != nil {
		logger.Error("failed-to-construct-run-request", err)
		return
	}
	ok = p.containerDelegate.RunContainer(logger, &runReq)
	if !ok {
		p.bbsClient.RemoveActualLRP(lrpContainer.ProcessGuid, int(lrpContainer.Index))
		return
	}
}
コード例 #2
0
	Describe("NewRunRequestFromDesiredLRP", func() {
		var (
			containerGuid string
			desiredLRP    *models.DesiredLRP
			actualLRP     *models.ActualLRP
		)

		BeforeEach(func() {
			containerGuid = "the-container-guid"
			desiredLRP = model_helpers.NewValidDesiredLRP("the-process-guid")
			actualLRP = model_helpers.NewValidActualLRP("the-process-guid", 9)
			desiredLRP.RootFs = "preloaded://foobar"
		})

		It("returns a valid run request", func() {
			runReq, err := rep.NewRunRequestFromDesiredLRP(containerGuid, desiredLRP, &actualLRP.ActualLRPKey, &actualLRP.ActualLRPInstanceKey)
			Expect(err).NotTo(HaveOccurred())
			Expect(runReq.Tags).To(Equal(executor.Tags{}))
			Expect(runReq.RunInfo).To(Equal(executor.RunInfo{
				CPUWeight: uint(desiredLRP.CpuWeight),
				DiskScope: executor.ExclusiveDiskLimit,
				Ports:     rep.ConvertPortMappings(desiredLRP.Ports),
				LogConfig: executor.LogConfig{
					Guid:       desiredLRP.LogGuid,
					Index:      int(actualLRP.Index),
					SourceName: desiredLRP.LogSource,
				},

				MetricsConfig: executor.MetricsConfig{
					Guid:  desiredLRP.MetricsGuid,
					Index: int(actualLRP.Index),
コード例 #3
0
					})

					It("does not delete the container", func() {
						Expect(containerDelegate.DeleteContainerCallCount()).To(Equal(0))
					})

					It("does not try to run the container", func() {
						Expect(containerDelegate.RunContainerCallCount()).To(Equal(0))
					})
				})

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

						expectedRunRequest, err := rep.NewRunRequestFromDesiredLRP(container.Guid, desiredLRP, &expectedLrpKey, &expectedInstanceKey)
						Expect(err).NotTo(HaveOccurred())

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

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

						It("removes the actual LRP", func() {
							Expect(bbsClient.RemoveActualLRPCallCount()).To(Equal(1))
							processGuid, index := bbsClient.RemoveActualLRPArgsForCall(0)