mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 18:20:27 +00:00
Merge pull request #1332 from weaveworks/1091-docker-rename
Support docker rename events
This commit is contained in:
@@ -334,9 +334,6 @@ export default class NodesChart extends React.Component {
|
|||||||
|
|
||||||
const stateNodes = this.initNodes(props.nodes, state.nodes);
|
const stateNodes = this.initNodes(props.nodes, state.nodes);
|
||||||
const stateEdges = this.initEdges(props.nodes, stateNodes);
|
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 nodeScale = this.getNodeScale(props.nodes, state.width, state.height);
|
||||||
const nextState = { nodeScale };
|
const nextState = { nodeScale };
|
||||||
|
|
||||||
@@ -356,12 +353,15 @@ export default class NodesChart extends React.Component {
|
|||||||
log(`graph layout took ${timedLayouter.time}ms`);
|
log(`graph layout took ${timedLayouter.time}ms`);
|
||||||
|
|
||||||
// inject metrics and save coordinates for restore
|
// inject metrics and save coordinates for restore
|
||||||
const layoutNodes = graph.nodes
|
let layoutNodes = graph.nodes
|
||||||
.mergeDeep(nodeMetrics)
|
|
||||||
.map(node => node.merge({
|
.map(node => node.merge({
|
||||||
px: node.get('x'),
|
px: node.get('x'),
|
||||||
py: node.get('y')
|
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
|
const layoutEdges = graph.edges
|
||||||
.map(edge => edge.set('ppoints', edge.get('points')));
|
.map(edge => edge.set('ppoints', edge.get('points')));
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import (
|
|||||||
const (
|
const (
|
||||||
CreateEvent = "create"
|
CreateEvent = "create"
|
||||||
DestroyEvent = "destroy"
|
DestroyEvent = "destroy"
|
||||||
|
RenameEvent = "rename"
|
||||||
StartEvent = "start"
|
StartEvent = "start"
|
||||||
DieEvent = "die"
|
DieEvent = "die"
|
||||||
PauseEvent = "pause"
|
PauseEvent = "pause"
|
||||||
@@ -238,7 +239,7 @@ func (r *registry) updateImages() error {
|
|||||||
|
|
||||||
func (r *registry) handleEvent(event *docker_client.APIEvents) {
|
func (r *registry) handleEvent(event *docker_client.APIEvents) {
|
||||||
switch event.Status {
|
switch event.Status {
|
||||||
case CreateEvent, StartEvent, DieEvent, DestroyEvent, PauseEvent, UnpauseEvent:
|
case CreateEvent, RenameEvent, StartEvent, DieEvent, DestroyEvent, PauseEvent, UnpauseEvent:
|
||||||
r.updateContainerState(event.ID)
|
r.updateContainerState(event.ID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -203,8 +203,21 @@ var (
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
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"}
|
apiContainer1 = client.APIContainers{ID: "ping"}
|
||||||
apiContainer2 = client.APIContainers{ID: "wiff"}
|
apiContainer2 = client.APIContainers{ID: "wiff"}
|
||||||
|
renamedAPIContainer = client.APIContainers{ID: "renamed"}
|
||||||
apiImage1 = client.APIImages{ID: "baz", RepoTags: []string{"bang", "not-chosen"}}
|
apiImage1 = client.APIImages{ID: "baz", RepoTags: []string{"bang", "not-chosen"}}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -350,5 +363,17 @@ func TestRegistryEvents(t *testing.T) {
|
|||||||
want := []docker.Container{}
|
want := []docker.Container{}
|
||||||
check(want)
|
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)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user