-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Collect unsupported annotation usage in diags #11601
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds functionality to detect and report the usage of unsupported annotations in Kubernetes resources during diagnostics collection. The change enhances the diagnostics tool to identify resources that use the unsupported.operator.tigera.io annotation, helping users identify potentially problematic configurations.
Key Changes:
- Added a new function
collectUnsupportedAnnotationsthat scans all collected diagnostic files for theunsupported.operator.tigera.ioannotation - Integrated this check into the diagnostics collection workflow
- When detected, outputs a warning and creates a file listing all resources containing the unsupported annotation
| fmt.Println("\n==== WARNING: Unsupported annotation usage detected in the cluster ====") | ||
| content := strings.Join(filesWithString, "\n") | ||
| filePath := fmt.Sprintf("%s/%s/files_with_unsupported_annotation.txt", tempDir, directoryName) | ||
| err = os.WriteFile(filePath, []byte(content), 0644) |
Copilot
AI
Dec 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file permissions 0644 make the file world-readable. Since this file contains diagnostic information about cluster resources with unsupported annotations, consider using more restrictive permissions like 0600 to limit access to the file owner only.
| err = os.WriteFile(filePath, []byte(content), 0644) | |
| err = os.WriteFile(filePath, []byte(content), 0600) |
| content, err := os.ReadFile(path) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| if strings.Contains(string(content), "unsupported.operator.tigera.io") { |
Copilot
AI
Dec 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading entire file contents into memory for every file and converting to string can be inefficient for large files. Consider using a buffered scanner (bufio.Scanner) to search line-by-line, or checking file size before reading to skip very large files that are unlikely to be YAML/JSON resource definitions.
Description
Adds collection for unsupported annotation usage to the diag bundle collection.
Picks https://github.com/tigera/calico-private/pull/10465. Ideally it should have been merged through OS first - this PR corrects that.
Related issues/PRs
Todos
Release Note
Reminder for the reviewer
Make sure that this PR has the correct labels and milestone set.
Every PR needs one
docs-*label.docs-pr-required: This change requires a change to the documentation that has not been completed yet.docs-completed: This change has all necessary documentation completed.docs-not-required: This change has no user-facing impact and requires no docs.Every PR needs one
release-note-*label.release-note-required: This PR has user-facing changes. Most PRs should have this label.release-note-not-required: This PR has no user-facing changes.Other optional labels:
cherry-pick-candidate: This PR should be cherry-picked to an earlier release. For bug fixes only.needs-operator-pr: This PR is related to install and requires a corresponding change to the operator.