Skip to content

Conversation

@pasanw
Copy link
Member

@pasanw pasanw commented Dec 30, 2025

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

  • Tests
  • Documentation
  • Release note

Release Note

TBD

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.

Copilot AI review requested due to automatic review settings December 30, 2025 19:38
@pasanw pasanw requested a review from a team as a code owner December 30, 2025 19:38
@marvin-tigera marvin-tigera added this to the Calico v3.32.0 milestone Dec 30, 2025
@marvin-tigera marvin-tigera added release-note-required Change has user-facing impact (no matter how small) docs-pr-required Change is not yet documented labels Dec 30, 2025
@pasanw pasanw added docs-not-required Docs not required for this change release-note-not-required Change has no user-facing impact skip-bot-cherry-pick and removed release-note-required Change has user-facing impact (no matter how small) docs-pr-required Change is not yet documented labels Dec 30, 2025
Copy link
Contributor

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

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 collectUnsupportedAnnotations that scans all collected diagnostic files for the unsupported.operator.tigera.io annotation
  • 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)
Copy link

Copilot AI Dec 30, 2025

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.

Suggested change
err = os.WriteFile(filePath, []byte(content), 0644)
err = os.WriteFile(filePath, []byte(content), 0600)

Copilot uses AI. Check for mistakes.
Comment on lines +772 to +776
content, err := os.ReadFile(path)
if err != nil {
return err
}
if strings.Contains(string(content), "unsupported.operator.tigera.io") {
Copy link

Copilot AI Dec 30, 2025

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-not-required Docs not required for this change release-note-not-required Change has no user-facing impact skip-bot-cherry-pick

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants