hst/instance: store priv side pid
All checks were successful
Test / Create distribution (push) Successful in 33s
Test / Sandbox (push) Successful in 2m14s
Test / Hakurei (push) Successful in 3m8s
Test / Sandbox (race detector) (push) Successful in 3m58s
Test / Hpkg (push) Successful in 4m1s
Test / Hakurei (race detector) (push) Successful in 4m44s
Test / Flake checks (push) Successful in 1m29s
All checks were successful
Test / Create distribution (push) Successful in 33s
Test / Sandbox (push) Successful in 2m14s
Test / Hakurei (push) Successful in 3m8s
Test / Sandbox (race detector) (push) Successful in 3m58s
Test / Hpkg (push) Successful in 4m1s
Test / Hakurei (race detector) (push) Successful in 4m44s
Test / Flake checks (push) Successful in 1m29s
This can receive signals, so is more useful to the caller. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
parent
dd94818f20
commit
05488bfb8f
@ -66,7 +66,7 @@ func printShowInstance(
|
||||
|
||||
if instance != nil {
|
||||
t.Printf("State\n")
|
||||
t.Printf(" Instance:\t%s (%d)\n", instance.ID.String(), instance.PID)
|
||||
t.Printf(" Instance:\t%s (%d -> %d)\n", instance.ID.String(), instance.PID, instance.ShimPID)
|
||||
t.Printf(" Uptime:\t%s\n", now.Sub(instance.Time).Round(time.Second).String())
|
||||
t.Printf("\n")
|
||||
}
|
||||
|
||||
@ -17,10 +17,11 @@ var (
|
||||
0xb4, 0x6e, 0xb5, 0xc1,
|
||||
}
|
||||
testState = &hst.State{
|
||||
ID: testID,
|
||||
PID: 0xDEADBEEF,
|
||||
Config: hst.Template(),
|
||||
Time: testAppTime,
|
||||
ID: testID,
|
||||
PID: 0xcafebabe,
|
||||
ShimPID: 0xdeadbeef,
|
||||
Config: hst.Template(),
|
||||
Time: testAppTime,
|
||||
}
|
||||
testTime = time.Unix(3752, 1).UTC()
|
||||
testAppTime = time.Unix(0, 9).UTC()
|
||||
@ -131,7 +132,7 @@ Session bus
|
||||
`, false},
|
||||
|
||||
{"instance", testState, hst.Template(), false, false, `State
|
||||
Instance: 8e2c76b066dabe574cf073bdb46eb5c1 (3735928559)
|
||||
Instance: 8e2c76b066dabe574cf073bdb46eb5c1 (3405691582 -> 3735928559)
|
||||
Uptime: 1h2m32s
|
||||
|
||||
App
|
||||
@ -173,7 +174,7 @@ System bus
|
||||
{"instance pd", testState, new(hst.Config), false, false, `Error: configuration missing container state!
|
||||
|
||||
State
|
||||
Instance: 8e2c76b066dabe574cf073bdb46eb5c1 (3735928559)
|
||||
Instance: 8e2c76b066dabe574cf073bdb46eb5c1 (3405691582 -> 3735928559)
|
||||
Uptime: 1h2m32s
|
||||
|
||||
App
|
||||
@ -186,7 +187,8 @@ App
|
||||
`, true},
|
||||
{"json instance", testState, nil, false, true, `{
|
||||
"instance": "8e2c76b066dabe574cf073bdb46eb5c1",
|
||||
"pid": 3735928559,
|
||||
"pid": 3405691582,
|
||||
"shim_pid": 3735928559,
|
||||
"config": {
|
||||
"id": "org.chromium.Chromium",
|
||||
"enablements": {
|
||||
@ -527,13 +529,14 @@ func TestPrintPs(t *testing.T) {
|
||||
`},
|
||||
|
||||
{"valid", map[hst.ID]*hst.State{testID: testState}, false, false, ` Instance PID Application Uptime
|
||||
8e2c76b0 3735928559 9 (org.chromium.Chromium) 1h2m32s
|
||||
8e2c76b0 3405691582 9 (org.chromium.Chromium) 1h2m32s
|
||||
`},
|
||||
{"valid short", map[hst.ID]*hst.State{testID: testState}, true, false, "8e2c76b0\n"},
|
||||
{"valid json", map[hst.ID]*hst.State{testID: testState}, false, true, `{
|
||||
"8e2c76b066dabe574cf073bdb46eb5c1": {
|
||||
"instance": "8e2c76b066dabe574cf073bdb46eb5c1",
|
||||
"pid": 3735928559,
|
||||
"pid": 3405691582,
|
||||
"shim_pid": 3735928559,
|
||||
"config": {
|
||||
"id": "org.chromium.Chromium",
|
||||
"enablements": {
|
||||
|
||||
@ -74,8 +74,11 @@ func (a *ID) UnmarshalText(text []byte) error {
|
||||
type State struct {
|
||||
// Unique instance id, created by [NewInstanceID].
|
||||
ID ID `json:"instance"`
|
||||
// Shim process pid. Runs as the target user.
|
||||
// Monitoring process pid. Runs as the priv user.
|
||||
PID int `json:"pid"`
|
||||
// Shim process pid. Runs as the target user.
|
||||
ShimPID int `json:"shim_pid"`
|
||||
|
||||
// Configuration used to start the container.
|
||||
Config *Config `json:"config"`
|
||||
|
||||
|
||||
@ -290,10 +290,11 @@ func (k *outcome) main(msg message.Msg) {
|
||||
// shim accepted setup payload, create process state
|
||||
if ok, err := ms.store.Do(k.state.identity.unwrap(), func(c state.Cursor) {
|
||||
if err := c.Save(&hst.State{
|
||||
ID: k.state.id.unwrap(),
|
||||
PID: ms.cmd.Process.Pid,
|
||||
Config: k.config,
|
||||
Time: *ms.Time,
|
||||
ID: k.state.id.unwrap(),
|
||||
PID: os.Getpid(),
|
||||
ShimPID: ms.cmd.Process.Pid,
|
||||
Config: k.config,
|
||||
Time: *ms.Time,
|
||||
}); err != nil {
|
||||
ms.fatal("cannot save state entry:", err)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user