@@ -222,6 +222,7 @@ func useConfigFromEnvVar() {
222
222
func checkMemorySettingsMiBFromEnvVar (envVar string , memTotalSizeMiB int ) int {
223
223
// Check if the memory limit is specified via the env var
224
224
// Ensure memory limit is valid
225
+ args := os .Args [1 :]
225
226
var envVarResult int = 0
226
227
envVarVal := os .Getenv (envVar )
227
228
switch {
@@ -237,6 +238,8 @@ func checkMemorySettingsMiBFromEnvVar(envVar string, memTotalSizeMiB int) int {
237
238
envVarResult = val
238
239
case memTotalSizeMiB > 0 :
239
240
break
241
+ case contains (args , "--config" ):
242
+ break
240
243
default :
241
244
log .Printf ("Usage: %s=12345 %s=us0 %s=684 %s=1024 %s=256 %s" , tokenEnvVarName , realmEnvVarName , ballastEnvVarName , memLimitMiBEnvVarName , memSpikeMiBEnvVarName , os .Args [0 ])
242
245
log .Fatalf ("ERROR: Missing environment variable %s" , envVar )
@@ -245,12 +248,16 @@ func checkMemorySettingsMiBFromEnvVar(envVar string, memTotalSizeMiB int) int {
245
248
}
246
249
247
250
func useMemorySettingsMiBFromEnvVar (memTotalSizeMiB int ) {
251
+ args := os .Args [1 :]
248
252
// Check if memory limit is specified via environment variable
249
253
memLimit := checkMemorySettingsMiBFromEnvVar (memLimitMiBEnvVarName , memTotalSizeMiB )
250
- // Use if set, otherwise memory total size must be specified
254
+ // Use if set, otherwise check if memory total size is specified via environment variable
251
255
if memLimit == 0 {
256
+ // Use if set, otherwise config parameter must be passed
252
257
if memTotalSizeMiB == 0 {
253
- panic ("PANIC: Both memory limit MiB and memory total size are set to zero. This should never happen." )
258
+ if ! contains (args , "--config" ) {
259
+ panic ("PANIC: Both memory limit MiB and memory total size are set to zero. This should never happen." )
260
+ }
254
261
}
255
262
// If not set, compute based on memory total size specified
256
263
// and default memory limit percentage const
@@ -262,14 +269,19 @@ func useMemorySettingsMiBFromEnvVar(memTotalSizeMiB int) {
262
269
} else {
263
270
memLimit = (memTotalSizeMiB - defaultMemoryLimitMaxMiB )
264
271
}
265
- log .Printf ("Set memory limit to %d MiB" , memLimit )
272
+ if memLimit != 0 {
273
+ log .Printf ("Set memory limit to %d MiB" , memLimit )
274
+ }
266
275
}
267
276
// Check if memory spike is specified via environment variable
268
277
memSpike := checkMemorySettingsMiBFromEnvVar (memSpikeMiBEnvVarName , memTotalSizeMiB )
269
- // Use if set, otherwise memory total size must be specified
278
+ // Use if set, otherwise check if memory total size is specified via environment variable
270
279
if memSpike == 0 {
280
+ // Use if set, otherwise config parameter must be passed
271
281
if memTotalSizeMiB == 0 {
272
- panic ("PANIC: Both memory limit MiB and memory total size are set to zero. This should never happen." )
282
+ if ! contains (args , "--config" ) {
283
+ panic ("PANIC: Both memory limit MiB and memory total size are set to zero. This should never happen." )
284
+ }
273
285
}
274
286
// If not set, compute based on memory total size specified
275
287
// and default memory spike percentage const
@@ -281,7 +293,9 @@ func useMemorySettingsMiBFromEnvVar(memTotalSizeMiB int) {
281
293
} else {
282
294
memSpike = defaultMemorySpikeMaxMiB
283
295
}
284
- log .Printf ("Set memory spike limit to %d MiB" , memSpike )
296
+ if memSpike != 0 {
297
+ log .Printf ("Set memory spike limit to %d MiB" , memSpike )
298
+ }
285
299
}
286
300
setMemorySettingsToEnvVar (memLimit , memLimitMiBEnvVarName , memSpike , memSpikeMiBEnvVarName )
287
301
}
@@ -315,13 +329,15 @@ func useMemorySettingsPercentageFromEnvVar() {
315
329
316
330
func setMemorySettingsToEnvVar (limit int , limitName string , spike int , spikeName string ) {
317
331
// Ensure spike and limit are valid
318
- if spike >= limit {
332
+ if spike >= limit && spike != 0 {
319
333
log .Fatalf ("%s env variable must be less than %s env variable but got %d and %d respectively" , spikeName , limitName , spike , limit )
320
334
}
321
335
322
336
// Set memory environment variables
323
- os .Setenv (limitName , strconv .Itoa (limit ))
324
- os .Setenv (spikeName , strconv .Itoa (spike ))
337
+ if spike != 0 {
338
+ os .Setenv (limitName , strconv .Itoa (limit ))
339
+ os .Setenv (spikeName , strconv .Itoa (spike ))
340
+ }
325
341
}
326
342
327
343
func runInteractive (params service.Parameters ) error {
0 commit comments