示例#1
0
func minionRegistryMaker(c *Config) registry.MinionRegistry {
	var minionRegistry registry.MinionRegistry
	if c.Cloud != nil && len(c.MinionRegexp) > 0 {
		var err error
		minionRegistry, err = registry.MakeCloudMinionRegistry(c.Cloud, c.MinionRegexp)
		if err != nil {
			glog.Errorf("Failed to initalize cloud minion registry reverting to static registry (%#v)", err)
		}
	}
	if minionRegistry == nil {
		minionRegistry = registry.MakeMinionRegistry(c.Minions)
	}
	if c.HealthCheckMinions {
		minionRegistry = registry.NewHealthyMinionRegistry(minionRegistry, &http.Client{})
	}
	if c.MinionCacheTTL > 0 {
		cachingMinionRegistry, err := registry.NewCachingMinionRegistry(minionRegistry, c.MinionCacheTTL)
		if err != nil {
			glog.Errorf("Failed to initialize caching layer, ignoring cache.")
		} else {
			minionRegistry = cachingMinionRegistry
		}
	}
	return minionRegistry
}
示例#2
0
func minionRegistryMaker(minions []string, cloud cloudprovider.Interface, minionRegexp string, healthCheck bool, cacheTTL time.Duration) registry.MinionRegistry {
	var minionRegistry registry.MinionRegistry
	if cloud != nil && len(minionRegexp) > 0 {
		var err error
		minionRegistry, err = registry.MakeCloudMinionRegistry(cloud, minionRegexp)
		if err != nil {
			glog.Errorf("Failed to initalize cloud minion registry reverting to static registry (%#v)", err)
		}
	}
	if minionRegistry == nil {
		minionRegistry = registry.MakeMinionRegistry(minions)
	}
	if healthCheck {
		minionRegistry = registry.NewHealthyMinionRegistry(minionRegistry, &http.Client{})
	}
	if cacheTTL > 0 {
		cachingMinionRegistry, err := registry.NewCachingMinionRegistry(minionRegistry, cacheTTL)
		if err != nil {
			glog.Errorf("Failed to initialize caching layer, ignoring cache.")
		} else {
			minionRegistry = cachingMinionRegistry
		}
	}
	return minionRegistry
}
示例#3
0
func minionRegistryMaker(minions []string, cloud cloudprovider.Interface, minionRegexp string) registry.MinionRegistry {
	if cloud != nil && len(minionRegexp) > 0 {
		minionRegistry, err := registry.MakeCloudMinionRegistry(cloud, minionRegexp)
		if err != nil {
			glog.Errorf("Failed to initalize cloud minion registry reverting to static registry (%#v)", err)
		}
		return minionRegistry
	}
	return registry.MakeMinionRegistry(minions)
}
示例#4
0
// Returns a new apiserver.
func New(etcdServers, minions []string, cloud cloudprovider.Interface, minionRegexp string) *Master {
	etcdClient := etcd.NewClient(etcdServers)
	var minionRegistry registry.MinionRegistry
	if cloud != nil && len(minionRegexp) > 0 {
		var err error
		minionRegistry, err = registry.MakeCloudMinionRegistry(cloud, minionRegexp)
		if err != nil {
			glog.Errorf("Failed to initalize cloud minion registry reverting to static registry (%#v)", err)
			minionRegistry = registry.MakeMinionRegistry(minions)
		}
	} else {
		minionRegistry = registry.MakeMinionRegistry(minions)
	}
	m := &Master{
		podRegistry:        registry.MakeEtcdRegistry(etcdClient, minionRegistry),
		controllerRegistry: registry.MakeEtcdRegistry(etcdClient, minionRegistry),
		serviceRegistry:    registry.MakeEtcdRegistry(etcdClient, minionRegistry),
		minionRegistry:     minionRegistry,
	}
	m.init(cloud)
	return m
}