예제 #1
0
func (p *dockerProvisioner) fixContainer(container *container.Container, info container.NetworkInfo) error {
	if info.HTTPHostPort == "" {
		return nil
	}
	appInstance, err := app.GetByName(container.AppName)
	if err != nil {
		return err
	}
	r, err := getRouterForApp(appInstance)
	if err != nil {
		return err
	}
	err = r.RemoveRoute(container.AppName, container.Address())
	if err != nil && err != router.ErrRouteNotFound {
		return err
	}
	container.IP = info.IP
	container.HostPort = info.HTTPHostPort
	err = r.AddRoute(container.AppName, container.Address())
	if err != nil && err != router.ErrRouteExists {
		return err
	}
	coll := p.Collection()
	defer coll.Close()
	return coll.Update(bson.M{"id": container.ID}, container)
}
예제 #2
0
파일: fix.go 프로젝트: zhenruyan/tsuru
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},
	})
	lockedRoutesRebuildOrEnqueue(container.AppName)
	return err
}