-
Notifications
You must be signed in to change notification settings - Fork 419
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
Stop Error noise from 'test -e' #389
Conversation
@@ -51,7 +51,7 @@ | |||
- require: | |||
- file: {{ basedir }} | |||
{%- if not update %} | |||
- unless: test -e {{ gitdir }} >/dev/null 2>&1 | |||
- onlyif: rm -fr {{ gitdir }} >/dev/null 2>&1 | true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@noelmcloughlin , this onlyif
always evaluate to true
. Am I missing something?
gitdir
exists and is removed ->true
gitdir
exists but can't be removed for any reason -> ors totrue
$ sudo mkdir /tmp/deleteable
$ ls -ld /tmp/deleteable
drwxr-xr-x 2 root root 4096 Dec 13 08:28 /tmp/deleteable
$ rm -rf /tmp/deleteable; echo $?
rm: cannot remove '/tmp/deleteable': Operation not permitted
1
gitdir
does not exist,rm -rf
won't fail ->true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is quick solution without adding new file.absent state - the goal is to clone the repo and noise from conditional is a Salt bug imho. Open to other ideas - it's an irritation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry yes - I am following 80/20 rule in assuming rm command just works. sudo rm -fr {{gitdir}}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I understand. Comparing with other formulas, I see that we use test -<whatever>
in many places, both with onlyif
and with unless
, and they don't add noise when used.
I'm suspicious of the stderr -> stdout redirection here as the culprit of the noise, and I wonder if just using
unless: test -e {{ gitdir }}
(as I see it being used in other formulas) won't fix the issue? It's worth a try, dyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using onlyif/unless Salt should generate FALSE or TRUE.
However today Salt generates either TRUE or FALSE+STDERR
Here is example from lvm-formula - FALSE is enough - the STDERR output is unwanted.
[ERROR ] Command '[u'vgdisplay', u'-c', u'cinder_volumes']' failed with return code: 5
[ERROR ] stderr: Volume group "cinder_volumes" not found
Cannot process volume group cinder_volumes
I added the stderr->stdout->/dev/null in #384 but it didn't work ( I probably tried `test -d {{ gitdir}}` too). Any ideas why it happens?
…On Thu, Dec 13, 2018 at 1:31 PM Javier Bértoli ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In salt/formulas.sls
<#389 (comment)>
:
> @@ -51,7 +51,7 @@
- require:
- file: {{ basedir }}
{%- if not update %}
- - unless: test -e {{ gitdir }} >/dev/null 2>&1
+ - onlyif: rm -fr {{ gitdir }} >/dev/null 2>&1 | true
Yes, I understand. Comparing with other formulas, I see that we use test
-<whatever> in many places, both with onlyif and with unless, and they
don't add noise when used.
I'm suspicious of the stderr -> stdout redirection here as the culprit of
the noise, and I wonder if just using
unless: test -e {{ gitdir }}
(as I see it being used in other formulas) won't fix the issue? It's worth
a try, dyt?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#389 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AMtKQgJpsMCj1QjrQyUvK7VzUGrh8fX7ks5u4lawgaJpZM4ZQo0e>
.
|
@javierbertoli I found an unexpected and undocumented solution. Studying the API shows that kwargs are supported. I passed
The salt Anyway it works - I'm closing the PR as not needed. |
I opened replacement PR #390 |
This PR stops SALT ERROR output when cloning formulas and
unless
check fails.