purpleidea / mgmt

Next generation distributed, event-driven, parallel config management!
https://purpleidea.com/tags/mgmtconfig/
GNU General Public License v3.0
3.46k stars 308 forks source link

Pkg autogrouping regression #442

Open purpleidea opened 5 years ago

purpleidea commented 5 years ago
00:48:57 main.go:410: engine: pkg[cowsay]: resource: Set(installed): pkg[autogroup:(cowsay,powertop,sl)]...

00:50:01 main.go:410: engine: pkg[cowsay]: CheckApply(true): Return(false, PackageKit: Timeout: InstallPackages: cowsay;3.04-10.fc28;noarch;fedora, powertop;2.9-8.fc28;x86_64;updates, sl;5.02-8.fc28;x86_64;fedora)
00:50:01 main.go:410: engine: pkg[cowsay]: exit event...
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xfd3166]

goroutine 394 [running]:
github.com/purpleidea/mgmt/engine/graph.(*State).read(0xc4202d4620, 0x0, 0x0, 0xc4202d4620)
    /home/james/code/gopath/src/github.com/purpleidea/mgmt/engine/graph/state.go:299 +0x26
github.com/purpleidea/mgmt/engine/graph.(*State).(github.com/purpleidea/mgmt/engine/graph.read)-fm(0x0, 0x1, 0xc420465ce0)
    /home/james/code/gopath/src/github.com/purpleidea/mgmt/engine/graph/state.go:145 +0x34
github.com/purpleidea/mgmt/engine/resources.(*PkgRes).Watch(0xc4202d5880, 0x0, 0x0)
    /home/james/code/gopath/src/github.com/purpleidea/mgmt/engine/resources/pkg.go:152 +0x465
github.com/purpleidea/mgmt/engine/graph.(*Engine).Worker.func1(0xc420422460, 0x7f14e2f8f450, 0xc4202d5880, 0x1bd07c0, 0xc4202d5880)
    /home/james/code/gopath/src/github.com/purpleidea/mgmt/engine/graph/actions.go:307 +0xbd1
created by github.com/purpleidea/mgmt/engine/graph.(*Engine).Worker
    /home/james/code/gopath/src/github.com/purpleidea/mgmt/engine/graph/actions.go:266 +0x4e4
Command exited with non-zero status 2
0.48user 0.51system 1:11.66elapsed 1%CPU (0avgtext+0avgdata 49984maxresident)k
0inputs+0outputs (0major+4038minor)pagefaults 0swaps

Code:

examples/lang/autogroup1.mcl

pkg "powertop" {
    state => "installed",

    Meta:autogroup => true,
}

pkg "sl" {
    state => "installed",

    Meta:autogroup => true,
}

pkg "cowsay" {
    state => "installed",

    Meta:autogroup => true,
}

Run with:

sudo pkcon remove powertop sl cowsay
sudo time ./mgmt run --tmp-prefix --no-pgp lang --lang examples/lang/autogroup1.mcl
sudo pkcon remove cowsay

I think the "done" installation message is never received after this installs the packages, and then either on timeout or when it received the event from the pkcon remove cowsay, it caused this panic!

Fix this and add a test for this too.

purpleidea commented 5 years ago

I fixed this panic, but it seems there's an occasional problem with the pkg resource getting stuck in func (obj *Conn) InstallPackages

And then that seems to be blocking events? Anyways, we'll need to debug this and add some tests. (It's not autogrouping specific afaict.)