Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error in init() function #247

Closed
je4 opened this issue Apr 4, 2024 · 2 comments
Closed

error in init() function #247

je4 opened this issue Apr 4, 2024 · 2 comments

Comments

@je4
Copy link

je4 commented Apr 4, 2024

We are using siegfried as library in other go projects.
Since a recent update there is an error on miminalistic docker files (no home directory etc.) on kubernetes.

2024/03/28 10:25:26 stat /dev/null/siegfried: not a directory

Last version which was tested ok is v1.10.1.

From our point of view, this error occurs within an init() function.
We think, it could be

if _, err := os.Stat(siegfried.home); err != nil {

If homedirectory points to /dev/null, this line tries to os.Stat("/dev/null/siegfried").
After that, the error is not known and log.Fatal(err) in

log.Fatal(err)

happens.

This error occurs even if we do not use any functionality from siegfried. Using a library which uses siegfried is enough.

Is there a way to make sure, that init() function cannot result in a fatal() or panic()?

It's quite hard to debug the minimalistic docker image, since it has no delve on it.

@je4 je4 changed the title error referencing siegfried library in init() function error in init() function Apr 4, 2024
@richardlehane
Copy link
Owner

Hey @je4 thanks for this detailed report, removing panics from these init functions seems on the face of it a good idea. I'll check if there are any downstream consequences of doing that

@richardlehane
Copy link
Owner

Hi @je4 I've made changes to remove panics altogether and reduce use of init functions. This should be fixed in next release, out in about a week. I've you'd like to test, there's a release candidate here: https://github.com/richardlehane/siegfried/releases/tag/v1.11.1-rc4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants