Skip to content

Commit bf68642

Browse files
authored
Merge pull request #1467 from safchain/cri-o
Cri o
2 parents d545ec6 + d5fd822 commit bf68642

File tree

16 files changed

+768
-37
lines changed

16 files changed

+768
-37
lines changed

agent/probes.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import (
3939
"github.com/skydive-project/skydive/topology/probes/neutron"
4040
"github.com/skydive-project/skydive/topology/probes/opencontrail"
4141
"github.com/skydive-project/skydive/topology/probes/ovsdb"
42+
"github.com/skydive-project/skydive/topology/probes/runc"
4243
"github.com/skydive-project/skydive/topology/probes/socketinfo"
4344
)
4445

@@ -114,6 +115,12 @@ func NewTopologyProbeBundleFromConfig(g *graph.Graph, hostNode *graph.Node) (*pr
114115
return nil, fmt.Errorf("Failed to initialize Libvirt probe: %s", err)
115116
}
116117
probes[t] = libvirt
118+
case "runc":
119+
runc, err := runc.NewProbe(nsProbe)
120+
if err != nil {
121+
return nil, fmt.Errorf("Failed to initialize runc probe: %s", err)
122+
}
123+
probes[t] = runc
117124
default:
118125
logging.GetLogger().Errorf("unknown probe type %s", t)
119126
}

common/proc.go

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/*
2+
* Copyright (C) 2018 Red Hat, Inc.
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing,
15+
* software distributed under the License is distributed on an
16+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
* KIND, either express or implied. See the License for the
18+
* specific language governing permissions and limitations
19+
* under the License.
20+
*
21+
*/
22+
23+
package common
24+
25+
import (
26+
"fmt"
27+
"io/ioutil"
28+
"os"
29+
)
30+
31+
// ProcessState describes the state of a process
32+
type ProcessState rune
33+
34+
const (
35+
// Running state
36+
Running ProcessState = 'R'
37+
// Sleeping state
38+
Sleeping ProcessState = 'S'
39+
// Waiting state
40+
Waiting ProcessState = 'D'
41+
// Zombie state
42+
Zombie ProcessState = 'Z'
43+
// Stopped state
44+
Stopped ProcessState = 'T'
45+
// TracingStop state
46+
TracingStop ProcessState = 't'
47+
// Dead state
48+
Dead ProcessState = 'X'
49+
)
50+
51+
// ProcessInfo describes the information of a running process
52+
type ProcessInfo struct {
53+
Process string
54+
Pid int64
55+
Name string
56+
PPid int64
57+
PGrp int64
58+
Session int64
59+
Utime int64
60+
Stime int64
61+
CUtime int64
62+
CStime int64
63+
Priority int64
64+
Nice int64
65+
Threads int64
66+
Start int64
67+
Vsize int64
68+
RSS int64
69+
State ProcessState
70+
}
71+
72+
// GetProcessInfo retrieve process info from /proc
73+
func GetProcessInfo(pid int) (*ProcessInfo, error) {
74+
processPath := fmt.Sprintf("/proc/%d", pid)
75+
exe, err := os.Readlink(processPath + "/exe")
76+
if err != nil {
77+
return nil, err
78+
}
79+
80+
stat, err := ioutil.ReadFile(processPath + "/stat")
81+
if err != nil {
82+
return nil, err
83+
}
84+
85+
pi := &ProcessInfo{
86+
Process: exe,
87+
}
88+
89+
var name string
90+
var state rune
91+
var null int64
92+
93+
fmt.Sscanf(string(stat), "%d %s %c %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d",
94+
&pi.Pid, &name, &state, &pi.PPid, &pi.PGrp, &pi.Session,
95+
&null, &null, &null, &null, &null, &null, &null,
96+
&pi.Utime, &pi.Stime, &pi.CUtime, &pi.CStime, &pi.Priority, &pi.Nice, &pi.Threads,
97+
&null,
98+
&pi.Start, &pi.Vsize, &pi.RSS)
99+
100+
pi.Name = name[1 : len(name)-1]
101+
pi.State = ProcessState(state)
102+
103+
return pi, nil
104+
}

config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ func init() {
8888
cfg.SetDefault("agent.topology.neutron.region_name", "RegionOne")
8989
cfg.SetDefault("agent.topology.neutron.tenant_name", "service")
9090
cfg.SetDefault("agent.topology.neutron.username", "neutron")
91+
cfg.SetDefault("agent.topology.runc.run_path", []string{"/run/containerd/runc", "/run/runc"})
9192
cfg.SetDefault("agent.topology.socketinfo.host_update", 10)
9293

9394
cfg.SetDefault("analyzer.auth.cluster.backend", "noauth")

contrib/ansible/roles/skydive_dev/tasks/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
- ffmpeg
5555
- npm
5656
- gifsicle
57+
- podman
5758

5859
- service:
5960
name: "{{ item }}"

etc/skydive.yml.default

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ agent:
191191
# - socketinfo
192192
# - lxd
193193
# - lldp
194+
# - runc
194195

195196
netlink:
196197
# delay in seconds between two metric updates
@@ -219,6 +220,10 @@ agent:
219220
libvirt:
220221
# url: qemu:///system
221222

223+
runc:
224+
run_path:
225+
# - /var/run/runc
226+
222227
capture:
223228
# Period in second to get capture stats from the probe. Note this
224229
# stats_update: 1

scripts/ci/cleanup.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ function cleanup() {
3232
cleanup_items docker "docker_rm"
3333
cleanup_items lxd "lxc delete --force"
3434

35+
# cleanup podman/runc
36+
podman stop -a
37+
podman rm -fa
38+
podman rmi -fa
39+
3540
"${CURDIR}/../scale.sh" stop 10 10 10
3641

3742
# clean elasticsearch

statics/img/runc.png

386 Bytes
Loading

statics/js/components/layout.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,5 @@ var managerImgMap = setupFixedImages({
6161
"neutron": "openstack",
6262
"k8s": "k8s",
6363
"istio": "istio",
64+
"runc": "runc"
6465
});

tests/runc_test.go

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright (C) 2018 Red Hat, Inc.
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing,
15+
* software distributed under the License is distributed on an
16+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
* KIND, either express or implied. See the License for the
18+
* specific language governing permissions and limitations
19+
* under the License.
20+
*
21+
*/
22+
23+
package tests
24+
25+
import (
26+
"fmt"
27+
"testing"
28+
)
29+
30+
func TestRuncSimple(t *testing.T) {
31+
test := &Test{
32+
setupCmds: []Cmd{
33+
{"podman run -d --name nginx --label Name=test nginx", true},
34+
},
35+
36+
tearDownCmds: []Cmd{
37+
{"podman kill nginx", false},
38+
{"podman rm nginx", false},
39+
},
40+
41+
mode: Replay,
42+
43+
checks: []CheckFunction{func(c *CheckContext) error {
44+
gremlin := c.gremlin.V().Has("Type", "netns", "Manager", "runc")
45+
gremlin = gremlin.Out("Type", "container", "Manager", "runc", "Runc.CreateConfig.Labels.Name", "test")
46+
47+
nodes, err := c.gh.GetNodes(gremlin)
48+
if err != nil {
49+
return err
50+
}
51+
52+
if len(nodes) != 1 {
53+
return fmt.Errorf("Expected 1 node, got %+v", nodes)
54+
}
55+
56+
return nil
57+
}},
58+
}
59+
60+
RunTest(t, test)
61+
}

tests/tests.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ agent:
8989
- lxd
9090
- opencontrail
9191
- lldp
92+
- runc
9293
netlink:
9394
metrics_update: 5
9495
lldp:

0 commit comments

Comments
 (0)