Skip to content

[Feature] Previous Pod Logs in DebugPackage #1899

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

Merged
merged 2 commits into from
May 29, 2025

Conversation

ajanikow
Copy link
Collaborator

No description provided.

@cla-bot cla-bot bot added the cla-signed label May 29, 2025
@ajanikow ajanikow merged commit 1b3f558 into master May 29, 2025
3 checks passed
@ajanikow ajanikow deleted the feature/previous_pod_logs_dp branch May 29, 2025 09:55
@jwierzbo jwierzbo requested a review from Copilot May 29, 2025 10:05
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds support for fetching and including previous container logs when pods have restarted.

  • Insert kubernetesPreviousCorePodLogsExtract calls alongside existing log extraction.
  • Implement new kubernetesPreviousCorePodLogsExtract helper function.
  • Update CHANGELOG to record the new feature.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
pkg/debug_package/generators/kubernetes/kubernetes_core_pods.go Added conditional calls for previous logs and implemented extractor function
CHANGELOG.md Added entry for "Previous Pod Logs in DebugPackage"
Comments suppressed due to low confidence (2)

pkg/debug_package/generators/kubernetes/kubernetes_core_pods.go:86

  • New logic for fetching previous pod logs lacks test coverage; consider adding unit or integration tests to validate both successful log retrieval and error conditions.
func kubernetesPreviousCorePodLogsExtract(ctx context.Context, client kclient.Client, item *core.Pod, container string) shared.File {

CHANGELOG.md:15

  • [nitpick] Align the indentation of this entry with existing list items (e.g., prefix with two spaces) to maintain consistent formatting in the CHANGELOG.
- (Feature) Previous Pod Logs in DebugPackage

@@ -45,6 +45,10 @@ func kubernetesCorePodLogs(ctx context.Context, logger zerolog.Logger, client kc
}

files <- kubernetesCorePodLogsExtract(ctx, client, item, s[id].Name)

if s[id].RestartCount > 0 {
Copy link
Preview

Copilot AI May 29, 2025

Choose a reason for hiding this comment

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

This conditional block to fetch previous pod logs is repeated multiple times; consider refactoring into a shared helper or loop to reduce duplication and improve maintainability.

Copilot uses AI. Check for mistakes.

}
}

return nil
}

func kubernetesPreviousCorePodLogsExtract(ctx context.Context, client kclient.Client, item *core.Pod, container string) shared.File {
Copy link
Preview

Copilot AI May 29, 2025

Choose a reason for hiding this comment

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

Add a doc comment for kubernetesPreviousCorePodLogsExtract explaining its purpose, parameters, and return value to match the style of other extractor functions.

Copilot uses AI. Check for mistakes.

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.

2 participants