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

Rename Kubelet.Client -> EtcdClient #227

Merged
merged 1 commit into from
Jun 24, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pkg/kubelet/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ type CadvisorInterface interface {
// The main kubelet implementation
type Kubelet struct {
Hostname string
Client util.EtcdClient
EtcdClient util.EtcdClient
DockerClient DockerInterface
CadvisorClient CadvisorInterface
FileCheckFrequency time.Duration
Expand Down Expand Up @@ -106,7 +106,7 @@ func (kl *Kubelet) RunKubelet(config_path, manifest_url, etcd_servers, address s
if etcd_servers != "" {
servers := []string{etcd_servers}
log.Printf("Creating etcd client pointing to %v", servers)
kl.Client = etcd.NewClient(servers)
kl.EtcdClient = etcd.NewClient(servers)
go util.Forever(func() { kl.SyncAndSetupEtcdWatch(updateChannel) }, 20*time.Second)
}
if address != "" {
Expand Down Expand Up @@ -135,7 +135,7 @@ type SyncHandler interface {

// Log an event to the etcd backend.
func (kl *Kubelet) LogEvent(event *api.Event) error {
if kl.Client == nil {
if kl.EtcdClient == nil {
return fmt.Errorf("no etcd client connection.")
}
event.Timestamp = time.Now().Unix()
Expand All @@ -145,7 +145,7 @@ func (kl *Kubelet) LogEvent(event *api.Event) error {
}

var response *etcd.Response
response, err = kl.Client.AddChild(fmt.Sprintf("/events/%s", event.Container.Name), string(data), 60*60*48 /* 2 days */)
response, err = kl.EtcdClient.AddChild(fmt.Sprintf("/events/%s", event.Container.Name), string(data), 60*60*48 /* 2 days */)
// TODO(bburns) : examine response here.
if err != nil {
log.Printf("Error writing event: %s\n", err)
Expand Down Expand Up @@ -513,7 +513,7 @@ func (kl *Kubelet) ResponseToManifests(response *etcd.Response) ([]api.Container
}

func (kl *Kubelet) getKubeletStateFromEtcd(key string, updateChannel chan<- manifestUpdate) error {
response, err := kl.Client.Get(key+"/kubelet", true, false)
response, err := kl.EtcdClient.Get(key+"/kubelet", true, false)
if err != nil {
if util.IsEtcdNotFound(err) {
return nil
Expand Down Expand Up @@ -558,7 +558,7 @@ func (kl *Kubelet) SyncAndSetupEtcdWatch(updateChannel chan<- manifestUpdate) {

kl.getKubeletStateFromEtcd(key, updateChannel)
log.Printf("Setting up a watch for configuration changes in etcd for %s", key)
kl.Client.Watch(key, 0, true, watchChannel, done)
kl.EtcdClient.Watch(key, 0, true, watchChannel, done)
}
}

Expand Down
12 changes: 6 additions & 6 deletions pkg/kubelet/kubelet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ func (cr *channelReader) GetList() [][]api.ContainerManifest {
func TestGetKubeletStateFromEtcdNoData(t *testing.T) {
fakeClient := util.MakeFakeEtcdClient(t)
kubelet := Kubelet{
Client: fakeClient,
EtcdClient: fakeClient,
}
channel := make(chan manifestUpdate)
reader := startReading(channel)
Expand All @@ -422,7 +422,7 @@ func TestGetKubeletStateFromEtcdNoData(t *testing.T) {
func TestGetKubeletStateFromEtcd(t *testing.T) {
fakeClient := util.MakeFakeEtcdClient(t)
kubelet := Kubelet{
Client: fakeClient,
EtcdClient: fakeClient,
}
channel := make(chan manifestUpdate)
reader := startReading(channel)
Expand All @@ -446,7 +446,7 @@ func TestGetKubeletStateFromEtcd(t *testing.T) {
func TestGetKubeletStateFromEtcdNotFound(t *testing.T) {
fakeClient := util.MakeFakeEtcdClient(t)
kubelet := Kubelet{
Client: fakeClient,
EtcdClient: fakeClient,
}
channel := make(chan manifestUpdate)
reader := startReading(channel)
Expand All @@ -468,7 +468,7 @@ func TestGetKubeletStateFromEtcdNotFound(t *testing.T) {
func TestGetKubeletStateFromEtcdError(t *testing.T) {
fakeClient := util.MakeFakeEtcdClient(t)
kubelet := Kubelet{
Client: fakeClient,
EtcdClient: fakeClient,
}
channel := make(chan manifestUpdate)
reader := startReading(channel)
Expand Down Expand Up @@ -570,7 +570,7 @@ func TestSyncManifestsDeletes(t *testing.T) {
func TestEventWriting(t *testing.T) {
fakeEtcd := util.MakeFakeEtcdClient(t)
kubelet := &Kubelet{
Client: fakeEtcd,
EtcdClient: fakeEtcd,
}
expectedEvent := api.Event{
Event: "test",
Expand All @@ -597,7 +597,7 @@ func TestEventWriting(t *testing.T) {
func TestEventWritingError(t *testing.T) {
fakeEtcd := util.MakeFakeEtcdClient(t)
kubelet := &Kubelet{
Client: fakeEtcd,
EtcdClient: fakeEtcd,
}
fakeEtcd.Err = fmt.Errorf("test error")
err := kubelet.LogEvent(&api.Event{
Expand Down