flant / shell-operator

Shell-operator is a tool for running event-driven scripts in a Kubernetes cluster
https://flant.github.io/shell-operator/
Apache License 2.0
2.39k stars 214 forks source link

Ignore lib directory while processing hooks #620

Closed yalosev closed 2 months ago

yalosev commented 2 months ago

Hook spams like this:

.../hooks/lib/utils.py' is skipped: no executable permissions, chmod +x is required to run this hook"

We can patch this function to ignore the lib directory with hooks

nabokihms commented 2 months ago

Les't add a warning if there is a file with the executable permissions in the lib directory. I think we need this to prevent accidentally putting a hook in the folder where we ignore it.

The behavior also must be documented in all the docs: shell-operator, addon-operator, and deckhouse module development docs.

juev commented 2 months ago

So what do we do?

The task was to get rid of many messages in the logs stating that files in the directory do not have permission to run. And it is suggested to simply ignore the lib directory from scanning. In case we need to check that the lib directory contains executable files, we must scan it. And if there are such files, issue a warning.

Maybe then it's better not to ignore the lib directory from scanning. But just not display a warning that the file is not executable?

In this case, our system behavior will remain the same, but there will be less spam in the logs.

We just need to remove this warning.

yalosev commented 2 months ago

Maybe it would be better to use something like that:

if !IsFileExecutable(f) && !strings.Contains(f.Name(), "/lib/") {
    log.Warnf("File '%s' is skipped: no executable permissions, chmod +x is required to run this hook", path)
    return nil
}