Skip to content

Add flag to include api server audit logs in support bundle #9701

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 1 commit into from
May 8, 2025

Conversation

charles-large
Copy link
Member

@charles-large charles-large commented Apr 29, 2025

Issue #, if available:
https://github.com/aws/eks-anywhere-internal/issues/3210
Description of changes:
Adds a flag --audit-logs to generate support-bundle command. When specified, will include the latest api server audit log file in the support bundle.

It achieves this by using troubleshoot, with the RunDaemonSet collector. It only runs on control plane nodes, via a node selector. Only the latest log file will be collected, which can be up to 512MB due to audit-log-maxsize: "512" on api server pods. With multiple control plane nodes, the max size of these logs included could be a few GB.

Example run

./bin/eksctl-anywhere generate support-bundle -f ~/vsphere/largchar-colo-mgmt-vsphere.yaml --audit-logs

Example output from my support bundle

[ec2-user@ip-172-31-22-5 eks-anywhere]$ ls -lh support-bundle-2025-04-29T20_31_39/audit-logs/
total 636M
-rw-------. 1 ec2-user ec2-user 282M Apr 29 20:35 largchar-colo-mgmt-vsphere-44jzw.log
-rw-------. 1 ec2-user ec2-user 355M Apr 29 20:35 largchar-colo-mgmt-vsphere-knspr.log

Testing (if applicable):
Tested on Ubuntu, RHEL and Bottlerocket
Documentation added/planned (if applicable):
Flag has been added to public docs

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

@eks-distro-bot eks-distro-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 29, 2025
Copy link

codecov bot commented Apr 29, 2025

Codecov Report

Attention: Patch coverage is 89.47368% with 6 lines in your changes missing coverage. Please review.

Project coverage is 69.85%. Comparing base (08b3131) to head (6789e71).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
cmd/eksctl-anywhere/cmd/supportbundle.go 25.00% 3 Missing ⚠️
pkg/diagnostics/factory.go 50.00% 2 Missing ⚠️
cmd/eksctl-anywhere/cmd/generatebundleconfig.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9701      +/-   ##
==========================================
+ Coverage   69.78%   69.85%   +0.06%     
==========================================
  Files         672      672              
  Lines       49679    49810     +131     
==========================================
+ Hits        34669    34794     +125     
- Misses      13230    13234       +4     
- Partials     1780     1782       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@charles-large charles-large force-pushed the support-bundle-audit-logs branch from 4fe3edc to d6341d2 Compare May 5, 2025 19:33
@@ -122,7 +122,8 @@ func newDiagnosticBundleFromSpec(af AnalyzerFactory, cf CollectorFactory, spec *
WithDefaultCollectors().
WithFileCollectors([]string{logger.GetOutputFilePath()}).
WithPackagesCollectors().
WithLogTextAnalyzers()
WithLogTextAnalyzers().
WithAuditLogs(auditLogs)
Copy link
Member

Choose a reason for hiding this comment

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

It might be better to do

if auditLogs {
  b = b.WithAuditLogs()
}

The WithAuditLogs function will be used to add AuditLogCollector, not checking if we need to add it

Copy link
Member

Choose a reason for hiding this comment

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

I think in WithAuditLogs we already have this check
if !auditLogs {
return e
}

Copy link
Member

Choose a reason for hiding this comment

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

yes I'm suggesting moving this if from WithAuditLogs to newDiagnosticBundleFromSpec

Copy link
Member Author

Choose a reason for hiding this comment

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

I will move the logic outside the method

Copy link
Member Author

Choose a reason for hiding this comment

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

I was basing this flow off other examples like

func (e *EksaDiagnosticBundle) WithManagementCluster(isSelfManaged bool) *EksaDiagnosticBundle {
	if isSelfManaged {
		e.bundle.Spec.Analyzers = append(e.bundle.Spec.Analyzers, e.analyzerFactory.ManagementClusterAnalyzers()...)
		e.bundle.Spec.Collectors = append(e.bundle.Spec.Collectors, e.collectorFactory.ManagementClusterCollectors()...)
	}
	return e
}

@charles-large charles-large force-pushed the support-bundle-audit-logs branch from d6341d2 to 6789e71 Compare May 8, 2025 18:37
@2ez4szliu
Copy link
Member

/lgtm

@rajeshvenkata
Copy link
Member

/approve

@eks-distro-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rajeshvenkata

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@eks-distro-bot eks-distro-bot merged commit a71fe7e into aws:main May 8, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved area/docs Documentation documentation lgtm size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants