@@ -78,6 +78,9 @@ const (
7878 // 720 * acn.FiveSeconds sec sleeps = 1Hr
7979 maxRetryNodeRegister = 720
8080 initCNSInitalDelay = 10 * time .Second
81+
82+ // envVarEnableCNIConflistGeneration enables cni conflist generation if set (value doesn't matter)
83+ envVarEnableCNIConflistGeneration = "CNS_ENABLE_CNI_CONFLIST_GENERATION"
8184)
8285
8386type cniConflistScenario string
@@ -287,6 +290,20 @@ var args = acn.ArgumentList{
287290 Type : "bool" ,
288291 DefaultValue : false ,
289292 },
293+ {
294+ Name : acn .OptCNIConflistFilepath ,
295+ Shorthand : acn .OptCNIConflistFilepathAlias ,
296+ Description : "Filepath to write CNI conflist when CNI conflist generation is enabled" ,
297+ Type : "string" ,
298+ DefaultValue : "" ,
299+ },
300+ {
301+ Name : acn .OptCNIConflistScenario ,
302+ Shorthand : acn .OptCNIConflistScenarioAlias ,
303+ Description : "Scenario to generate CNI conflist for" ,
304+ Type : "string" ,
305+ DefaultValue : "" ,
306+ },
290307}
291308
292309// init() is executed before main() whenever this package is imported
@@ -446,6 +463,8 @@ func main() {
446463 clientDebugArg := acn .GetArg (acn .OptDebugArg ).(string )
447464 cmdLineConfigPath := acn .GetArg (acn .OptCNSConfigPath ).(string )
448465 telemetryDaemonEnabled := acn .GetArg (acn .OptTelemetryService ).(bool )
466+ cniConflistFilepathArg := acn .GetArg (acn .OptCNIConflistFilepath ).(string )
467+ cniConflistScenarioArg := acn .GetArg (acn .OptCNIConflistScenario ).(string )
449468
450469 if vers {
451470 printVersion ()
@@ -489,15 +508,28 @@ func main() {
489508 configuration .SetCNSConfigDefaults (cnsconfig )
490509 logger .Printf ("[Azure CNS] Read config :%+v" , cnsconfig )
491510
511+ _ , envEnableConflistGeneration := os .LookupEnv (envVarEnableCNIConflistGeneration )
512+
492513 var conflistGenerator restserver.CNIConflistGenerator
493- if cnsconfig .EnableCNIConflistGeneration {
494- writer , newWriterErr := fs .NewAtomicWriter (cnsconfig .CNIConflistFilepath )
514+ if cnsconfig .EnableCNIConflistGeneration || envEnableConflistGeneration {
515+ conflistFilepath := cnsconfig .CNIConflistFilepath
516+ if cniConflistFilepathArg != "" {
517+ // allow the filepath to get overidden by command line arg
518+ conflistFilepath = cniConflistFilepathArg
519+ }
520+ writer , newWriterErr := fs .NewAtomicWriter (conflistFilepath )
495521 if newWriterErr != nil {
496522 logger .Errorf ("unable to create atomic writer to generate cni conflist: %v" , newWriterErr )
497523 os .Exit (1 )
498524 }
499525
500- switch scenario := cniConflistScenario (cnsconfig .CNIConflistScenario ); scenario {
526+ // allow the scenario to get overridden by command line arg
527+ scenarioString := cnsconfig .CNIConflistScenario
528+ if cniConflistScenarioArg != "" {
529+ scenarioString = cniConflistScenarioArg
530+ }
531+
532+ switch scenario := cniConflistScenario (scenarioString ); scenario {
501533 case scenarioV4Overlay :
502534 conflistGenerator = & cniconflist.V4OverlayGenerator {Writer : writer }
503535 default :
0 commit comments