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

ceph-volume: fix stderr failure to decode/encode when redirected #30274

Merged
merged 7 commits into from
Sep 10, 2019
Merged

ceph-volume: fix stderr failure to decode/encode when redirected #30274

merged 7 commits into from
Sep 10, 2019

Conversation

alfredodeza
Copy link
Contributor

This has taken a tremendous amount of work, and it is rolling back most/all of the automatic encoding/decoding effort done in 77912c0c718

In addition to the removal, I am making sure that

  • previous tests are passing almost without modifying
  • new functional tests demonstrate the problem and ensure the fix (need hooks into the CI though)
  • adds a fallback when all fails with the logging module
  • adds tests that verify that the logging module is used when encoding/decoding is failing

This PR should not be definite, and there should be new work put into place to fully remove the custom terminal logging so that the logging module is used instead. Since it is critical to have this fixed right away, my intention is to move this forward all the way to luminous and then start thinking about a proper solution to the terminal logging problem.

Fixes: https://tracker.ceph.com/issues/41660

Signed-off-by: Alfredo Deza <adeza@redhat.com>
Copy link
Contributor

@jan--f jan--f left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code-wise this looks good to me. I'm wondering though, this patch falls back to using the terminal logger if _writer.write throws something. Why not use the terminal logger right away?

This PR should not be definite, and there should be new work put into place to fully remove the custom terminal logging so that the logging module is used instead. Since it is critical to have this fixed right away, my intention is to move this forward all the way to luminous and then start thinking about a proper solution to the terminal logging problem.

Agreed. Having terminal.write use the terminal logger should get us there most of the way though, shouldn't it? Not pretty, but the unnecessary code can be stripped out at a later stage.

src/ceph-volume/ceph_volume/log.py Outdated Show resolved Hide resolved
@@ -80,34 +82,13 @@ def make(cls, string):
class _Write(object):

def __init__(self, _writer=None, prefix='', suffix='', flush=False):
# we can't set sys.stderr as the default for _writer. Otherwise
# we can't set sys.stderr as the default for _writer. otherwise
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# we can't set sys.stderr as the default for _writer. otherwise
# we can't set sys.stderr as the default for _writer, otherwise

@alfredodeza
Copy link
Contributor Author

Code-wise this looks good to me. I'm wondering though, this patch falls back to using the terminal logger if _writer.write throws something. Why not use the terminal logger right away?

There are more things involved if we want to use the logger. Internally, ceph-volume makes a distinction about stderr and stdout from commandline tools, those have color outputs, and no indication of log levels etc... It would take a bit more effort to get there, I think.

Also, when the work started, I thought it was going to be easier/simpler but it ended up requiring some sort of fallback which happened towards the end.

My preference would be to focus in the fix (with the fallback) and try to get a better solution with logging in a separate PR. I am happy to address any potential problems you see here though. Let's try to make sure this works really well

Alfredo Deza added 6 commits September 10, 2019 08:27
Signed-off-by: Alfredo Deza <adeza@redhat.com>
Signed-off-by: Alfredo Deza <adeza@redhat.com>
This caused problems in environments where stderr was redirected, since
stderr sets the encoding to None. Getting it back again allows
everything to work correctly, and keeps all the current unit tests
passing

Signed-off-by: Alfredo Deza <adeza@redhat.com>
Signed-off-by: Alfredo Deza <adeza@redhat.com>
Signed-off-by: Alfredo Deza <adeza@redhat.com>
Signed-off-by: Alfredo Deza <adeza@redhat.com>
@jan--f
Copy link
Contributor

jan--f commented Sep 10, 2019

Code-wise this looks good to me. I'm wondering though, this patch falls back to using the terminal logger if _writer.write throws something. Why not use the terminal logger right away?

There are more things involved if we want to use the logger. Internally, ceph-volume makes a distinction about stderr and stdout from commandline tools, those have color outputs, and no indication of log levels etc... It would take a bit more effort to get there, I think.

Alright, should have guessed that things are more complicated then that ;)

My preference would be to focus in the fix (with the fallback) and try to get a better solution with logging in a separate PR. I am happy to address any potential problems you see here though. Let's try to make sure this works really well

Sounds good to me. Feel free to get in touch to discuss solutions.

@alfredodeza
Copy link
Contributor Author

@andrewschoen @tchaikov if you could also take a look please... this is a big fix and want to make sure I am getting it 100% right

@alfredodeza
Copy link
Contributor Author

jenkins test ceph-volume tox

Copy link
Contributor

@andrewschoen andrewschoen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good. I'm thinking we should hook in the new functional testing into the CI eventually. If this is really urgent maybe we should not block on that though.

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

Successfully merging this pull request may close these issues.

4 participants