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

Support docker rename events #1332

Merged
merged 3 commits into from
Apr 20, 2016
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
10 changes: 5 additions & 5 deletions client/app/scripts/charts/nodes-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,6 @@ export default class NodesChart extends React.Component {

const stateNodes = this.initNodes(props.nodes, state.nodes);
const stateEdges = this.initEdges(props.nodes, stateNodes);
const nodeMetrics = stateNodes.map(node => makeMap({
metrics: node.get('metrics')
}));
const nodeScale = this.getNodeScale(props.nodes, state.width, state.height);
const nextState = { nodeScale };

Expand All @@ -355,12 +352,15 @@ export default class NodesChart extends React.Component {
log(`graph layout took ${timedLayouter.time}ms`);

// inject metrics and save coordinates for restore

This comment was marked as abuse.

const layoutNodes = graph.nodes
.mergeDeep(nodeMetrics)
let layoutNodes = graph.nodes
.map(node => node.merge({
px: node.get('x'),
py: node.get('y')
}));

// Re-apply in case layout runner's node cache applied stale node metadata
layoutNodes = layoutNodes.mergeDeep(stateNodes);

const layoutEdges = graph.edges
.map(edge => edge.set('ppoints', edge.get('points')));

Expand Down
3 changes: 2 additions & 1 deletion probe/docker/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
const (
CreateEvent = "create"
DestroyEvent = "destroy"
RenameEvent = "rename"
StartEvent = "start"
DieEvent = "die"
PauseEvent = "pause"
Expand Down Expand Up @@ -238,7 +239,7 @@ func (r *registry) updateImages() error {

func (r *registry) handleEvent(event *docker_client.APIEvents) {
switch event.Status {
case CreateEvent, StartEvent, DieEvent, DestroyEvent, PauseEvent, UnpauseEvent:
case CreateEvent, RenameEvent, StartEvent, DieEvent, DestroyEvent, PauseEvent, UnpauseEvent:
r.updateContainerState(event.ID)
}
}
Expand Down
31 changes: 28 additions & 3 deletions probe/docker/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,22 @@ var (
},
},
}
apiContainer1 = client.APIContainers{ID: "ping"}
apiContainer2 = client.APIContainers{ID: "wiff"}
apiImage1 = client.APIImages{ID: "baz", RepoTags: []string{"bang", "not-chosen"}}
renamedContainer = &client.Container{
ID: "renamed",
Name: "renamed",
Image: "baz",
State: client.State{Pid: 1, Running: true},
Config: &client.Config{
Labels: map[string]string{
"foo1": "bar1",
"foo2": "bar2",
},
},
}
apiContainer1 = client.APIContainers{ID: "ping"}
apiContainer2 = client.APIContainers{ID: "wiff"}
renamedAPIContainer = client.APIContainers{ID: "renamed"}
apiImage1 = client.APIImages{ID: "baz", RepoTags: []string{"bang", "not-chosen"}}
)

func newMockClient() *mockDockerClient {
Expand Down Expand Up @@ -350,5 +363,17 @@ func TestRegistryEvents(t *testing.T) {
want := []docker.Container{}
check(want)
}

{
mdc.Lock()
mdc.apiContainers = []client.APIContainers{renamedAPIContainer}
mdc.containers[renamedContainer.ID] = renamedContainer
mdc.Unlock()
mdc.send(&client.APIEvents{Status: docker.RenameEvent, ID: renamedContainer.ID})
runtime.Gosched()

want := []docker.Container{&mockContainer{renamedContainer}}
check(want)
}
})
}