xorpaul/g10k

g10k crashes with a confusing error when config.CacheDir is not writable.

pillarsdotnet opened this issue · 2 comments

I recently changed my workflow to run g10k as the puppet user instead of running it as root.

I was confused by the g10k output at first:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x8591f7]

goroutine 1 [running]:
main.isDir(0xc000090820, 0x16, 0x1)
        /home/andpaul/dev/go/src/github.com/xorpaul/g10k/helper.go:95 +0xb7
main.checkDirAndCreate(0xc000090820, 0x16, 0x9141d7, 0xe, 0x6, 0xc000090820)
        /home/andpaul/dev/go/src/github.com/xorpaul/g10k/helper.go:123 +0x155
main.readConfigfile(0x7ffe4bdad83f, 0x1e, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /home/andpaul/dev/go/src/github.com/xorpaul/g10k/config.go:51 +0x61b
main.main()
        /home/andpaul/dev/go/src/github.com/xorpaul/g10k/g10k.go:237 +0xf8f

The g10k program should check writability of cache dirs and output an error message instead of crashing.

👍

Weirdly I'm not getting a error message instead of a stack trace segmentation fault:

total 40K
drwxrwxr-x   2 root root 4,0K Jul  2 17:38 ./
drwxrwxrwt 263 root root  32K Jul  2 17:38 ../
# runuser -u andpaul -- ./g10k -config test.yaml
checkDirAndCreate(): Error: failed to create directory: /tmp/g10k/forge/

Maybe your SELinux settings?

Anyway, still a helpful check, thanks!

@xorpaul -- Yes, I am now sure that SELinux is the culprit. Maybe I can figure out how to modify settings to explicitly grant g10k write-access to environment dirs. Meanwhile, I'm still getting occasional SegFaults, such as:

2019/07/22 17:41:59 createOrPurgeDir(): error: removing dir failedunlinkat /etc/puppetlabs/code/environments/dev/modules/iptables: directory not empty
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x84d363]

goroutine 504 [running]:
main.unTar(0x99e9c0, 0xc000272a50, 0xc0001b8680, 0x37)
        /home/andpaul/dev/go/src/github.com/xorpaul/g10k/forge.go:396 +0x5f3
main.syncToModuleDir(0xc0001b3a90, 0x44, 0xc0001b8680, 0x37, 0x912a34, 0x6, 0x101, 0xc000018d87, 0x3, 0x7f4ebaac9000)
        /home/andpaul/dev/go/src/github.com/xorpaul/g10k/git.go:190 +0x9dd
main.resolvePuppetfile.func3(0xc00000e080, 0xc0001d06c0, 0x2e, 0xc0003acca0, 0xc0000166f0, 0x26, 0xc000073560, 0xc0004cf074, 0x8, 0x0, ...)
        /home/andpaul/dev/go/src/github.com/xorpaul/g10k/puppetfile.go:370 +0x825
created by main.resolvePuppetfile
        /home/andpaul/dev/go/src/github.com/xorpaul/g10k/puppetfile.go:316 +0x182a

Any chance of a new release?