func (p *dockerProvisioner) fixContainer(container *container.Container, info container.NetworkInfo) error { if info.HTTPHostPort == "" { return nil } container.IP = info.IP container.HostPort = info.HTTPHostPort coll := p.Collection() defer coll.Close() err := coll.Update(bson.M{"id": container.ID}, bson.M{ "$set": bson.M{"hostport": container.HostPort, "ip": container.IP}, }) rebuild.LockedRoutesRebuildOrEnqueue(container.AppName) return err }
func (s *S) TestRoutesRebuildOrEnqueueLocked(c *check.C) { a := &app.App{ Name: "almah", Platform: "static", TeamOwner: s.team.Name, } err := app.CreateApp(a, s.user) c.Assert(err, check.IsNil) locked, err := app.AcquireApplicationLock(a.Name, "me", "mine") c.Assert(err, check.IsNil) c.Assert(locked, check.Equals, true) invalidAddr, err := url.Parse("http://invalid.addr") c.Assert(err, check.IsNil) err = routertest.FakeRouter.AddRoute(a.GetName(), invalidAddr) c.Assert(err, check.IsNil) rebuild.LockedRoutesRebuildOrEnqueue(a.GetName()) c.Assert(routertest.FakeRouter.HasRoute(a.GetName(), invalidAddr.String()), check.Equals, true) app.ReleaseApplicationLock(a.Name) err = queue.TestingWaitQueueTasks(1, 10*time.Second) c.Assert(err, check.IsNil) c.Assert(routertest.FakeRouter.HasRoute(a.GetName(), invalidAddr.String()), check.Equals, false) }