mirror of
https://github.com/intel/intel-device-plugins-for-kubernetes.git
synced 2025-06-03 03:59:37 +00:00
Merge pull request #544 from mythi/PR-2021-003
sgx: change getDefaultPodCount() logic
This commit is contained in:
commit
771b0c7432
@ -34,7 +34,7 @@ const (
|
||||
deviceTypeProvision = "provision"
|
||||
devicePath = "/dev"
|
||||
podsPerCoreEnvVariable = "PODS_PER_CORE"
|
||||
defaultPodsPerCore uint = 10
|
||||
defaultPodCount uint = 110
|
||||
)
|
||||
|
||||
type devicePlugin struct {
|
||||
@ -107,29 +107,27 @@ func getDefaultPodCount(nCPUs uint) uint {
|
||||
// limit by multiplying the number of cores in the system with env variable
|
||||
// "PODS_PER_CORE".
|
||||
|
||||
podsPerCore := defaultPodsPerCore
|
||||
|
||||
envPodsPerCore := os.Getenv(podsPerCoreEnvVariable)
|
||||
if envPodsPerCore != "" {
|
||||
tmp, err := strconv.ParseUint(envPodsPerCore, 10, 32)
|
||||
if err != nil {
|
||||
klog.Errorf("Error: failed to parse %s value as uint, using default value.", podsPerCoreEnvVariable)
|
||||
} else {
|
||||
podsPerCore = uint(tmp)
|
||||
return uint(tmp) * nCPUs
|
||||
}
|
||||
}
|
||||
|
||||
return podsPerCore * nCPUs
|
||||
return defaultPodCount
|
||||
}
|
||||
|
||||
func main() {
|
||||
var enclaveLimit uint
|
||||
var provisionLimit uint
|
||||
|
||||
defaultPodCount := getDefaultPodCount(uint(runtime.NumCPU()))
|
||||
podCount := getDefaultPodCount(uint(runtime.NumCPU()))
|
||||
|
||||
flag.UintVar(&enclaveLimit, "enclave-limit", defaultPodCount, "Number of \"enclave\" resources")
|
||||
flag.UintVar(&provisionLimit, "provision-limit", defaultPodCount, "Number of \"provision\" resources")
|
||||
flag.UintVar(&enclaveLimit, "enclave-limit", podCount, "Number of \"enclave\" resources")
|
||||
flag.UintVar(&provisionLimit, "provision-limit", podCount, "Number of \"provision\" resources")
|
||||
flag.Parse()
|
||||
|
||||
klog.V(4).Infof("SGX device plugin started with %d \"%s/enclave\" resources and %d \"%s/provision\" resources.", enclaveLimit, namespace, provisionLimit, namespace)
|
||||
|
@ -50,16 +50,15 @@ func TestPodCount(t *testing.T) {
|
||||
expectedPodCount uint
|
||||
}{
|
||||
{
|
||||
name: "Only CPU count",
|
||||
name: "Default pod count",
|
||||
envValue: "",
|
||||
nCPUs: 5,
|
||||
expectedPodCount: defaultPodsPerCore * 5,
|
||||
expectedPodCount: defaultPodCount,
|
||||
},
|
||||
{
|
||||
name: "Broken ENV",
|
||||
envValue: "foobar",
|
||||
nCPUs: 5,
|
||||
expectedPodCount: defaultPodsPerCore * 5,
|
||||
expectedPodCount: defaultPodCount,
|
||||
},
|
||||
{
|
||||
name: "Valid ENV",
|
||||
|
Loading…
Reference in New Issue
Block a user