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

[20.10 backport] daemon/logger: read the length header correctly #43165

Merged
merged 4 commits into from Jan 27, 2022

Commits on Jan 20, 2022

  1. daemon/logger: read the length header correctly

    Before this change, if Decode() couldn't read a log record fully,
    the subsequent invocation of Decode() would read the record's non-header part
    as a header and cause a huge heap allocation.
    
    This change prevents such a case by having the intermediate buffer in
    the decoder struct.
    
    Fixes moby#42125.
    
    Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
    (cherry picked from commit 48d387a)
    Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
    kzys authored and thaJeztah committed Jan 20, 2022
    Copy the full SHA
    ada1b01 View commit details
    Browse the repository at this point in the history
  2. daemon/logger: test followLogs' handleDecodeErr case

    Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
    (cherry picked from commit f2e458e)
    Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
    kzys authored and thaJeztah committed Jan 20, 2022
    Copy the full SHA
    3951922 View commit details
    Browse the repository at this point in the history
  3. daemon/logger: refactor followLogs to write more unit tests

    followLogs() is getting really long (170+ lines) and complex.
    The function has multiple inner functions that mutate its variables.
    
    To refactor the function, this change introduces follow{} struct.
    The inner functions are now defined as ordinal methods, which are
    accessible from tests.
    
    Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
    (cherry picked from commit 7a10f5a)
    Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
    kzys authored and thaJeztah committed Jan 20, 2022
    Copy the full SHA
    78d0b93 View commit details
    Browse the repository at this point in the history
  4. daemon/logger: replace flaky TestFollowLogsHandleDecodeErr

    Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
    (cherry picked from commit c91e09b)
    Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
    kzys authored and thaJeztah committed Jan 20, 2022
    Copy the full SHA
    8268f70 View commit details
    Browse the repository at this point in the history