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

fix: Validation for Resource Limits #2201

Closed

Conversation

Hacks4Snacks
Copy link
Contributor

@Hacks4Snacks Hacks4Snacks commented Jul 26, 2024

Description

Intermittently we are observing unexpected and invalid memory resource limits being set for the ScanJob pods.

Example:
trivy-system scan-vulnerabilityreport-5594588b7b-w9m7l 500m (3%) 750m (4%) 512Mi (1%) 1288490188800m (3%) 7s

Operator Log:
{"level":"info","ts":"2024-07-26T07:42:18Z","logger":"KubeAPIWarningLogger","msg":"spec.template.spec.containers[6].resources.limits[memory]: fractional byte value \"1288490188800m\" is invalid, must be an integer"}

As such, this PR introduces validations in config.go for ResourceMemory, ResourceEphemeralStorage, and ResourceCPU to ensure the values passed from the configuration (or default) are valid as well as validating the parsed values match the expected values to prevent unexpected resource allocations.

Additionally, this PR updates the documentation to use the Mi unit for memory allocation as it is more commonly used in Kubernetes configurations

Related issues

  • No existing bug

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

Copy link

This PR is stale because it has been labeled with inactivity.

@github-actions github-actions bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and will be auto-closed. label Sep 25, 2024
@Hacks4Snacks Hacks4Snacks deleted the hacks4snacks/resourcelimits branch October 8, 2024 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug lifecycle/stale Denotes an issue or PR has remained open with no activity and will be auto-closed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant