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

CP-14444: Debug logging for PodStore #21

Merged
merged 3 commits into from
Nov 20, 2023
Merged

Conversation

bdrennz
Copy link
Collaborator

@bdrennz bdrennz commented Nov 15, 2023

Description of changes

This PR adds debug logs for PodStore to surface more information about cache operations. This should help with issues where the PodStore fails to scrape metrics from Pods in a cluster and any other potential cache related issues.

Most of the logs are added to PodStore.refreshInternal() which is ultimately called by PodStore.Decorate() any time the cache needs to be refreshed. PodStore also now implements ExposeCache() which lists all entries in the cache along with the remaining time to expiry. Assuming the cache is not empty, the output will look something like:

2023-11-16T14:23:54Z D! [PodStore.ExposeCache] Exposing cache with '5' entries...
2023-11-16T14:23:54Z D! [PodStore.ExposeCache] Entry: [podKey: namespace:default,podName:prometheus-kube-state-metrics-59649d78f-st99c, remainingTime: 89s]
2023-11-16T14:23:54Z D! [PodStore.ExposeCache] Entry: [podKey: namespace:kube-system,podName:aws-node-mbgps, remainingTime: 89s]
2023-11-16T14:23:54Z D! [PodStore.ExposeCache] Entry: [podKey: namespace:kube-system,podName:kube-proxy-wt8bj, remainingTime: 89s]
2023-11-16T14:23:54Z D! [PodStore.ExposeCache] Entry: [podKey: namespace:cloudzero-metrics,podName:cloudzero-cloudwatch-metrics-ggjmv, remainingTime: 89s]
2023-11-16T14:23:54Z D! [PodStore.ExposeCache] Entry: [podKey: namespace:default,podName:prometheus-prometheus-node-exporter-wdf64, remainingTime: 89s]
2023-11-16T14:23:54Z D! [PodStore.ExposeCache] Finished exposing cache

There's some other general information about pods, nodes, containers, etc.

2023-11-16T14:23:54Z D! [PodStore.refreshInternal] Refreshing Pod: 'cloudzero-cloudwatch-metrics-ggjmv':
2023-11-16T14:23:54Z D! [PodStore.refreshInternal] PodKey: 'namespace:cloudzero-metrics,podName:cloudzero-cloudwatch-metrics-ggjmv'
2023-11-16T14:23:54Z D! [PodStore.refreshInternal] Pod Phase: 'Running'
2023-11-16T14:23:54Z D! [PodStore.refreshInternal] Node Name: 'ip-192-168-23-0.ec2.internal'
2023-11-16T14:23:54Z D! [PodStore.refreshInternal] Container Information: [name: 'cloudzero-cloudwatch-metrics', state: '{nil &ContainerStateRunning{StartedAt:2023-11-16 14:18:15 +0000 UTC,} nil}']
2023-11-16T14:23:54Z D! [PodStore.refreshInternal] Refresh for Pod 'cloudzero-cloudwatch-metrics-ggjmv' is complete!

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Tests

Ideally ExposeCache() should have a unit test, but validating logs might be more trouble than it's worth.

Requirements

Before commit the code, please do the following steps.

  1. Run make fmt and make fmt-sh
  2. Run make linter

@bdrennz bdrennz changed the title Add Additional Logging to PodStore (Draft) CP-14444: Add Additional Logging to PodStore Nov 15, 2023
@bdrennz bdrennz closed this Nov 15, 2023
@bdrennz bdrennz reopened this Nov 15, 2023
@bdrennz bdrennz changed the title (Draft) CP-14444: Add Additional Logging to PodStore (Draft) CP-14444: Debug logging for PodStore Nov 16, 2023
@bdrennz bdrennz changed the title (Draft) CP-14444: Debug logging for PodStore CP-14444: Debug logging for PodStore Nov 16, 2023
@bdrennz bdrennz marked this pull request as ready for review November 16, 2023 14:30
Copy link

@dmepham dmepham left a comment

Choose a reason for hiding this comment

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

lgtm!

@bdrennz bdrennz merged commit c907885 into cloudzero-optimized Nov 20, 2023
1 of 2 checks passed
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.

2 participants