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

drenv: Improve gather logs #1748

Merged
merged 4 commits into from
Jan 29, 2025
Merged

drenv: Improve gather logs #1748

merged 4 commits into from
Jan 29, 2025

Conversation

nirs
Copy link
Member

@nirs nirs commented Jan 14, 2025

We used to drop gather info logs. Watch the gather process and log the
gather logs as they are written to stderr.

If drenv is run with --verbose we pass the option to kubectl-gather to log
more verbose logs. This may help to debug issues in kubect-gather in the CI
environment.

Example logs with this change:

% drenv gather envs/regional-dr.yaml
2025-01-15 22:04:20,865 INFO    [rdr] Gathering environment
2025-01-15 22:04:21,124 INFO    [gather] Using kubeconfig "/Users/nsoffer/.kube/config"
2025-01-15 22:04:21,126 INFO    [gather] Gathering from all namespaces
2025-01-15 22:04:21,126 INFO    [gather] Using all addons
2025-01-15 22:04:21,126 INFO    [gather] Storing data in "gather.20250115220421"
2025-01-15 22:04:21,126 INFO    [gather] Gathering from cluster "dr1"
2025-01-15 22:04:21,126 INFO    [gather] Gathering from cluster "dr2"
2025-01-15 22:04:21,126 INFO    [gather] Gathering from cluster "hub"
2025-01-15 22:04:23,095 INFO    [gather] Gathered 1535 resources from cluster "hub" in 1.969 seconds
2025-01-15 22:04:24,395 INFO    [gather] Gathered 1909 resources from cluster "dr1" in 3.269 seconds
2025-01-15 22:04:24,544 INFO    [gather] Gathered 1920 resources from cluster "dr2" in 3.417 seconds
2025-01-15 22:04:24,544 INFO    [gather] Gathered 5364 resources from 3 clusters in 3.418 seconds
2025-01-15 22:04:24,555 INFO    [rdr] Environment gathered in 3.69 seconds

Note: This change requires kubectl-gather 0.6.0. Developers that want to
use the drenv gather command will have to upgrade kubectl-gather to
latest version.

@nirs nirs mentioned this pull request Jan 14, 2025
@nirs nirs force-pushed the gather-logs branch 8 times, most recently from ae86c28 to 1e024de Compare January 15, 2025 21:44
@nirs nirs marked this pull request as ready for review January 16, 2025 16:08
@nirs nirs requested a review from parikshithb January 23, 2025 17:15
test/drenv/zap.py Outdated Show resolved Hide resolved
Copy link
Member

@parikshithb parikshithb left a comment

Choose a reason for hiding this comment

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

lgtm, minor comment.

test/drenv/kubectl.py Outdated Show resolved Hide resolved
nirs added 2 commits January 27, 2025 16:24
Update the install instructions to install the latest version on Linux
and macOS, and add a note about required version (0.6.0).

Signed-off-by: Nir Soffer <nsoffer@redhat.com>
The module parses and log JSON lines logged by programs using Go zap
module. This is needed for logging kubectl-gather JSON logs, but can
also be used with other tools, since zap is very popular.

Signed-off-by: Nir Soffer <nsoffer@redhat.com>
@nirs nirs force-pushed the gather-logs branch 2 times, most recently from 2d793c3 to c80a217 Compare January 27, 2025 14:30
@nirs nirs requested a review from parikshithb January 27, 2025 14:30
nirs added 2 commits January 27, 2025 16:57
We used to drop gather info logs. Watch the gather process and log the
gather logs as they are written to stderr.

Example logs with this change:

    % drenv gather envs/regional-dr.yaml
    2025-01-15 22:04:20,865 INFO    [rdr] Gathering environment
    2025-01-15 22:04:21,124 INFO    [gather] Using kubeconfig "/Users/nsoffer/.kube/config"
    2025-01-15 22:04:21,126 INFO    [gather] Gathering from all namespaces
    2025-01-15 22:04:21,126 INFO    [gather] Using all addons
    2025-01-15 22:04:21,126 INFO    [gather] Storing data in "gather.20250115220421"
    2025-01-15 22:04:21,126 INFO    [gather] Gathering from cluster "dr1"
    2025-01-15 22:04:21,126 INFO    [gather] Gathering from cluster "dr2"
    2025-01-15 22:04:21,126 INFO    [gather] Gathering from cluster "hub"
    2025-01-15 22:04:23,095 INFO    [gather] Gathered 1535 resources from cluster "hub" in 1.969 seconds
    2025-01-15 22:04:24,395 INFO    [gather] Gathered 1909 resources from cluster "dr1" in 3.269 seconds
    2025-01-15 22:04:24,544 INFO    [gather] Gathered 1920 resources from cluster "dr2" in 3.417 seconds
    2025-01-15 22:04:24,544 INFO    [gather] Gathered 5364 resources from 3 clusters in 3.418 seconds
    2025-01-15 22:04:24,555 INFO    [rdr] Environment gathered in 3.69 seconds

Note: This change requires kubectl-gather 0.6.0. Developers that want to
use the `drenv gather` command will have to upgrade kubectl-gather to
latest version.

Signed-off-by: Nir Soffer <nsoffer@redhat.com>
If drenv is run in verbose mode, pass --verbose flag to kubectl-gather
to log more verbose gather logs. This may be useful to debug issues in
kubectl gather in the CI environment.

Example log with this change:

    % drenv gather envs/regional-dr.yaml -v
    2025-01-15 22:13:31,064 DEBUG   [envfile] Detected os: 'darwin'
    2025-01-15 22:13:31,064 DEBUG   [envfile] Detected machine: 'arm64'
    2025-01-15 22:13:31,064 DEBUG   [envfile] Using provider: 'lima'
    2025-01-15 22:13:31,064 DEBUG   [envfile] Using driver: ''
    2025-01-15 22:13:31,064 DEBUG   [envfile] Using network: ''
    2025-01-15 22:13:31,064 DEBUG   [envfile] Detected os: 'darwin'
    2025-01-15 22:13:31,064 DEBUG   [envfile] Detected machine: 'arm64'
    2025-01-15 22:13:31,064 DEBUG   [envfile] Using provider: 'lima'
    2025-01-15 22:13:31,064 DEBUG   [envfile] Using driver: ''
    2025-01-15 22:13:31,064 DEBUG   [envfile] Using network: ''
    2025-01-15 22:13:31,064 DEBUG   [envfile] Detected os: 'darwin'
    2025-01-15 22:13:31,064 DEBUG   [envfile] Detected machine: 'arm64'
    2025-01-15 22:13:31,064 DEBUG   [envfile] Using provider: 'lima'
    2025-01-15 22:13:31,064 DEBUG   [envfile] Using driver: ''
    2025-01-15 22:13:31,064 DEBUG   [envfile] Using network: ''
    2025-01-15 22:13:31,064 INFO    [rdr] Gathering environment
    2025-01-15 22:13:31,356 INFO    [gather] Using kubeconfig "/Users/nsoffer/.kube/config"
    2025-01-15 22:13:31,359 INFO    [gather] Gathering from all namespaces
    2025-01-15 22:13:31,359 INFO    [gather] Using all addons
    2025-01-15 22:13:31,359 INFO    [gather] Storing data in "gather.20250115221331"
    2025-01-15 22:13:31,359 INFO    [gather] Gathering from cluster "dr1"
    2025-01-15 22:13:31,359 INFO    [gather] Gathering from cluster "dr2"
    2025-01-15 22:13:31,359 INFO    [gather] Gathering from cluster "hub"
    2025-01-15 22:13:31,406 DEBUG   [gather.dr2] Listed 133 api resources in 0.038 seconds
    2025-01-15 22:13:31,406 DEBUG   [gather.hub] Listed 105 api resources in 0.038 seconds
    2025-01-15 22:13:31,410 DEBUG   [gather.dr1] Listed 133 api resources in 0.042 seconds
    2025-01-15 22:13:31,416 DEBUG   [gather.dr2] Listed 0 "podtemplates" in 0.010 seconds
    2025-01-15 22:13:31,416 DEBUG   [gather.dr2] Gathered 0 "podtemplates" in 0.010 seconds

Signed-off-by: Nir Soffer <nsoffer@redhat.com>
@nirs
Copy link
Member Author

nirs commented Jan 29, 2025

Thanks for reviwing!

@nirs nirs merged commit e74b085 into RamenDR:main Jan 29, 2025
23 checks passed
@nirs nirs deleted the gather-logs branch January 29, 2025 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants