示例#1
0
func (zk *zkf) RemoveService(service *service.Service) error {
	// acquire the service lock to prevent that service from being scheduled
	// as it is being deleted
	conn, err := zzk.GetLocalConnection(zzk.GeneratePoolPath(service.PoolID))
	if err != nil {
		return err
	}

	// remove the global list of all vhosts deployed
	if rootconn, err := zzk.GetLocalConnection("/"); err != nil {
		return err
	} else if err := zkservice.RemoveServiceVhosts(rootconn, service); err != nil {
		return err
	}

	// Ensure that the service's pool is locked for the duration
	finish := make(chan interface{})
	defer close(finish)
	if err := zkservice.EnsureServiceLock(nil, finish, conn); err != nil {
		return err
	}

	// FIXME: this may be a long-running operation, should we institute a timeout?
	return zkservice.RemoveService(conn, service.ID)
}
示例#2
0
func (z *zkf) RemoveHost(host *host.Host) error {
	// acquire the service lock to prevent services from being scheduled
	// to that pool
	conn, err := zzk.GetLocalConnection(zzk.GeneratePoolPath(host.PoolID))
	if err != nil {
		return err
	}

	cancel := make(chan interface{})
	go func() {
		defer close(cancel)
		<-time.After(2 * time.Minute)
	}()

	// Ensure that the service's pool is locked for the duration
	finish := make(chan interface{})
	defer close(finish)
	if err := zkservice.EnsureServiceLock(cancel, finish, conn); err != nil {
		return err
	}
	return zkhost.RemoveHost(cancel, conn, host.ID)
}