-
Notifications
You must be signed in to change notification settings - Fork 949
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add cpu period and quota for containers
Signed-off-by: Allen Sun <[email protected]>
- Loading branch information
1 parent
f3325f0
commit ce44269
Showing
9 changed files
with
186 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package opts | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
// ValidateCPUPeriod validates CPU options for container. | ||
func ValidateCPUPeriod(period int64) error { | ||
if period == 0 { | ||
return nil | ||
} | ||
if period < 1000 || period > 1000000 { | ||
return fmt.Errorf("CPU cfs period %d cannot be less than 1ms (i.e. 1000) or larger than 1s (i.e. 1000000)", period) | ||
} | ||
return nil | ||
} | ||
|
||
// ValidateCPUQuota validates CPU options for container. | ||
func ValidateCPUQuota(quota int64) error { | ||
if quota == 0 { | ||
return nil | ||
} | ||
if quota < 1000 { | ||
return fmt.Errorf("CPU cfs quota %d cannot be less than 1ms (i.e. 1000)", quota) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters