Пример #1
0
// DesireLRP creates a DesiredLRPSchedulingInfo and a DesiredLRPRunInfo. In order
// to ensure that the complete model is available and there are no races in
// Desired Watches, DesiredLRPRunInfo is created before DesiredLRPSchedulingInfo.
func (db *ETCDDB) DesireLRP(logger lager.Logger, desiredLRP *models.DesiredLRP) error {
	logger = logger.Session("create-desired-lrp", lager.Data{"process-guid": desiredLRP.ProcessGuid})
	logger.Info("starting")
	defer logger.Info("complete")

	schedulingInfo, runInfo := desiredLRP.Explode()

	err := db.createDesiredLRPRunInfo(logger, &runInfo)
	if err != nil {
		return err
	}

	err = db.createDesiredLRPSchedulingInfo(logger, &schedulingInfo)
	if err != nil {
		return err
	}

	db.startInstanceRange(logger, 0, schedulingInfo.Instances, &schedulingInfo)
	return nil
}
Пример #2
0
func (t *ETCDHelper) SetRawDesiredLRP(lrp *models.DesiredLRP) {
	schedulingInfo, runInfo := lrp.Explode()

	t.SetRawDesiredLRPSchedulingInfo(&schedulingInfo)
	t.SetRawDesiredLRPRunInfo(&runInfo)
}
				BeforeEach(func() {
					_, err := storeClient.Delete(deprecations.DesiredLRPSchemaRoot, true)
					Expect(err).NotTo(HaveOccurred())
				})

				It("continues the migration", func() {
					Expect(migrationErr).NotTo(HaveOccurred())
				})
			})
		})

		Context("when there are already 'migrated' data in the database", func() {
			var existingSplit *models.DesiredLRP
			BeforeEach(func() {
				existingSplit = newValidDesiredLRP("existing-split")
				schedulingInfo, runInfo := existingSplit.Explode()

				schedulingInfoPayload, err := serializer.Marshal(logger, format.ENCRYPTED_PROTO, &schedulingInfo)
				Expect(err).NotTo(HaveOccurred())
				runInfoPayload, err := serializer.Marshal(logger, format.ENCRYPTED_PROTO, &runInfo)
				Expect(err).NotTo(HaveOccurred())

				_, err = storeClient.Set(etcd.DesiredLRPSchedulingInfoSchemaPath("existing-split"), schedulingInfoPayload, 0)
				Expect(err).NotTo(HaveOccurred())
				_, err = storeClient.Set(etcd.DesiredLRPRunInfoSchemaPath("existing-split"), runInfoPayload, 0)
				Expect(err).NotTo(HaveOccurred())
			})

			It("deletes the existing lrp that was already split afterwards", func() {
				Expect(migrationErr).NotTo(HaveOccurred())