Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract the minion registry from the etcd implementation into the pod registry. #1416

Merged
merged 1 commit into from
Sep 23, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 9 additions & 5 deletions pkg/master/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,16 @@ func NewEtcdHelper(etcdServers []string, version string) (helper tools.EtcdHelpe
// New returns a new instance of Master connected to the given etcd server.
func New(c *Config) *Master {
minionRegistry := makeMinionRegistry(c)
serviceRegistry := etcd.NewRegistry(c.EtcdHelper, nil)
manifestFactory := &pod.BasicManifestFactory{
ServiceRegistry: serviceRegistry,
}
m := &Master{
podRegistry: etcd.NewRegistry(c.EtcdHelper),
controllerRegistry: etcd.NewRegistry(c.EtcdHelper),
serviceRegistry: etcd.NewRegistry(c.EtcdHelper),
endpointRegistry: etcd.NewRegistry(c.EtcdHelper),
bindingRegistry: etcd.NewRegistry(c.EtcdHelper),
podRegistry: etcd.NewRegistry(c.EtcdHelper, manifestFactory),
controllerRegistry: etcd.NewRegistry(c.EtcdHelper, nil),
serviceRegistry: serviceRegistry,
endpointRegistry: etcd.NewRegistry(c.EtcdHelper, nil),
bindingRegistry: etcd.NewRegistry(c.EtcdHelper, manifestFactory),
minionRegistry: minionRegistry,
client: c.Client,
}
Expand Down
9 changes: 4 additions & 5 deletions pkg/registry/etcd/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
etcderr "github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors/etcd"
"github.com/GoogleCloudPlatform/kubernetes/pkg/constraint"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/pod"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
Expand All @@ -37,17 +38,15 @@ import (
// with backed by etcd.
type Registry struct {
tools.EtcdHelper
manifestFactory ManifestFactory
manifestFactory pod.ManifestFactory
}

// NewRegistry creates an etcd registry.
func NewRegistry(helper tools.EtcdHelper) *Registry {
func NewRegistry(helper tools.EtcdHelper, manifestFactory pod.ManifestFactory) *Registry {
registry := &Registry{
EtcdHelper: helper,
}
registry.manifestFactory = &BasicManifestFactory{
serviceRegistry: registry,
}
registry.manifestFactory = manifestFactory
return registry
}

Expand Down
9 changes: 5 additions & 4 deletions pkg/registry/etcd/etcd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/pod"
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/registrytest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
Expand All @@ -32,10 +33,10 @@ import (
)

func NewTestEtcdRegistry(client tools.EtcdClient) *Registry {
registry := NewRegistry(tools.EtcdHelper{client, latest.Codec, latest.ResourceVersioner})
registry.manifestFactory = &BasicManifestFactory{
serviceRegistry: &registrytest.ServiceRegistry{},
}
registry := NewRegistry(tools.EtcdHelper{client, latest.Codec, latest.ResourceVersioner},
&pod.BasicManifestFactory{
ServiceRegistry: &registrytest.ServiceRegistry{},
})
return registry
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package etcd
package pod

import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
Expand All @@ -27,11 +27,12 @@ type ManifestFactory interface {
}

type BasicManifestFactory struct {
serviceRegistry service.Registry
// TODO: this should really point at the API rather than a registry
ServiceRegistry service.Registry
}

func (b *BasicManifestFactory) MakeManifest(machine string, pod api.Pod) (api.ContainerManifest, error) {
envVars, err := service.GetServiceEnvironmentVariables(b.serviceRegistry, machine)
envVars, err := service.GetServiceEnvironmentVariables(b.ServiceRegistry, machine)
if err != nil {
return api.ContainerManifest{}, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package etcd
package pod

import (
"reflect"
Expand All @@ -28,7 +28,7 @@ import (
func TestMakeManifestNoServices(t *testing.T) {
registry := registrytest.ServiceRegistry{}
factory := &BasicManifestFactory{
serviceRegistry: &registry,
ServiceRegistry: &registry,
}

manifest, err := factory.MakeManifest("machine", api.Pod{
Expand Down Expand Up @@ -74,7 +74,7 @@ func TestMakeManifestServices(t *testing.T) {
},
}
factory := &BasicManifestFactory{
serviceRegistry: &registry,
ServiceRegistry: &registry,
}

manifest, err := factory.MakeManifest("machine", api.Pod{
Expand Down Expand Up @@ -150,7 +150,7 @@ func TestMakeManifestServicesExistingEnvVar(t *testing.T) {
},
}
factory := &BasicManifestFactory{
serviceRegistry: &registry,
ServiceRegistry: &registry,
}

manifest, err := factory.MakeManifest("machine", api.Pod{
Expand Down