orchestra/remote: extend mktemp() to accept data #1634
Conversation
teuthology/orchestra/remote.py
Outdated
| kwargs['path'] = self.mktemp(kwargs.pop('suffix', None), | ||
| kwargs.pop('parentdir', None)) |
There was a problem hiding this comment.
| kwargs['path'] = self.mktemp(kwargs.pop('suffix', None), | |
| kwargs.pop('parentdir', None)) | |
| kwargs['path'] = self.mktemp(suffix=suffix, parentdir=parentdir) |
kshtsk
left a comment
There was a problem hiding this comment.
I suggest to just use mktemp with data paremeter, then adding another one write_file method.
18caf08 to
69ad856
Compare
|
Removed write_temp_file() and upgraded mktemp() instead in last push. |
69ad856 to
ebf4288
Compare
teuthology/orchestra/remote.py
Outdated
| path = self.sh(args).strip() | ||
|
|
||
| if data: | ||
| # sudo is set to False since root user can't write files in /tmp |
There was a problem hiding this comment.
this is strange clause, root user can write to any directory in fact
There was a problem hiding this comment.
And btw, if the file is created by other user, than current, you must use sudo, but the whole idea of temporary files is to use the same user you operate.
There was a problem hiding this comment.
No, it can not anymore. Try writing files using sudo on kernel version post 4.19, I guess. Try ubuntu 20. This is what the entire is about. Please take a look at the commit message/PR description and at the ticket linked.
There was a problem hiding this comment.
Ah... I see it is because of the new kernel feature, but anyways, why would you explicitly declare False, if it is already a default value?
There was a problem hiding this comment.
As for https://tracker.ceph.com/issues/49466 this looks like a test bug, not the teuthology. The client code should care about tracking users or just always use default and not use sudo_write_file when it is not needed.
There was a problem hiding this comment.
Ah... I see it is because of the new kernel feature, but anyways, why would you explicitly declare False, if it is already a default value?
So that the reader know it's intentional and required even if the reader isn't aware of context.
There was a problem hiding this comment.
It is self explanatory, if you create a random file and use write_file api, it is with user without sudo.
There was a problem hiding this comment.
It is self explanatory, if you create a random file and use write_file api, it is with user without sudo.
If it was, I wouldn't have written this in the first place - #1634 (comment). :)
There was a problem hiding this comment.
I am sorry :-) I don't get it, what can be read differently when we have sudo_write_file and write_file? Why would we have sudo_write_file if write_file would have sudo=True?
There was a problem hiding this comment.
It's worth mentioning why we need sudo should be set ot False IMHO (the note is more comprehensible if it's immediately visible that sudo is set to False). However, I've gotten rid of the comment and "redundant" parameter from the call.
|
The bug referred in the commit message is related to the code from And rather be fixed in it instead of trying to fix teuthology api. |
|
Why just instead of: write: (wondering if new kernel allows to use sudo for changing mode and ownership in tmp files?) |
I never said the bug is in teuthology API. About the code referred to in the commit message , it's already being fixed. PTAL at ceph/ceph#40431. |
|
So why this change is required? I don't think we need it. |
No, that won't fix the issue. What is need is - But what is much much better than this is - This is simpler and more powerful because I get to create and write temporary file in a single call. But, much more importantly, it closes the possibility of having a test failure because someone forgot to set |
You said this "Helps fix https://tracker.ceph.com/issues/49466" which is not true. |
It is the same as:
As I said, teuthology api sudo=False is default, you should not point it exclusively, so there is no difference.
It depends on your needs, I agree it is more handy, as I mentioned earlier.
Again, we have standard api write_file, and we change it to |
This code It's best not to just fix the bug but to also fix the root cause of the bug, so that it can't occur again. |
|
Summarising:
|
But you still can use standard API to fix the issue, so no need to mention it here, so it is not necessary to have it.
You are not fixing the root cause of the bug with this PR. The root cause was incorrect usage of sudo_write_file in test. |
b3b6ce1 to
79393ee
Compare
|
@batrick I've removed every mention of why sudo must not be used from this PR in last update |
79393ee to
ed41381
Compare
ed41381 to
6e90e0b
Compare
|
@susebot run deploy |
|
Commit 6e90e0b is OK. |
Extend remote.Remote.mktemp() to accept data as a parameter and write the data to the temporary file after it is created. Signed-off-by: Rishabh Dave <ridave@redhat.com>
6e90e0b to
1966a88
Compare
kshtsk
left a comment
There was a problem hiding this comment.
Looks good to go now, thanks for the patience, and sorry that it took that much time.
|
@batrick I think your change request is outdated. |
Dismissing change request because it was outdated with new commits and become irrelevant.
No description provided.