@@ -85,42 +85,39 @@ func run(cmd *cobra.Command, args []string) {
8585 }
8686
8787 // Go through each host and add it to the cluster
88- for i := range config .ExecHosts {
88+ //
89+ for key := range config .ExecHosts {
8990 // add "master" host (here in the container) to be load
9091 // report host for the simulated host
91- if config .ExecHosts [i ].ComplexValues == nil {
92- config . ExecHosts [ i ]. ComplexValues = make ( map [ string ] string )
92+ if config .ExecHosts [key ].ComplexValues == nil {
93+ //
9394 }
94- config .ExecHosts [i ].ComplexValues ["load_report_host" ] = "master"
95+ config .ExecHosts [key ].ComplexValues ["load_report_host" ] = "master"
9596 // add to @allhosts
96- allhosts .Hosts = append (allhosts .Hosts , config .ExecHosts [i ].Name )
97+ allhosts .Hosts = append (allhosts .Hosts , config .ExecHosts [key ].Name )
9798 }
9899
99100 // add @allhosts to the list of host groups (TODO should be map)
100- found := false
101- for i , hg := range config .HostGroups {
102- if hg .Name == "@allhosts" {
103- config .HostGroups [i ] = allhosts
104- found = true
105- break
106- }
107- }
108- if ! found {
109- config .HostGroups = append (config .HostGroups , allhosts )
101+ if _ , ok := config .HostGroups ["@allhosts" ]; ! ok {
102+ config .HostGroups ["@allhosts" ] = allhosts
110103 }
111104
112105 // append "master" host to the list of hosts as it severs
113106 // the fake load for all simulated hosts and is not in the
114107 // list of hosts from the JSON file
115- config .ExecHosts = append (config .ExecHosts , qconf.HostExecConfig {
108+ if config .ExecHosts == nil {
109+ config .ExecHosts = make (map [string ]qconf.HostExecConfig )
110+ }
111+ config .ExecHosts ["master" ] = qconf.HostExecConfig {
116112 Name : "master" ,
117- })
118-
113+ }
119114 // add root as operator
120- config .Users = append (config .Users ,
121- qconf.UserConfig {
122- Name : "root" ,
123- })
115+ if config .Users == nil {
116+ config .Users = make (map [string ]qconf.UserConfig )
117+ }
118+ config .Users ["root" ] = qconf.UserConfig {
119+ Name : "root" ,
120+ }
124121 config .Operators = append (config .Operators , "root" )
125122 config .Managers = append (config .Managers , "root" )
126123
@@ -157,6 +154,8 @@ func RestartQmaster(config qconf.ClusterConfig, cs *qconf.CommandLineQConf) erro
157154 if err != nil {
158155 return fmt .Errorf ("Error shutting down qmaster: %s" , err )
159156 }
157+ <- time .After (5 * time .Second )
158+ cs .ShutdownMasterDaemon ()
160159 fmt .Printf ("waiting for qmaster to shut down...\n " )
161160 <- time .After (30 * time .Second )
162161 sgemaster := filepath .Join (config .ClusterEnvironment .Root ,
@@ -185,7 +184,8 @@ func AddHostsToEtcHosts(config qconf.ClusterConfig) error {
185184 baseIP := [4 ]int {10 , 0 , 0 , 0 }
186185
187186 // Add simulated hosts to /etc/hosts so that they are resolvable
188- for i , host := range config .ExecHosts {
187+ i := 0
188+ for _ , host := range config .ExecHosts {
189189 thirdOctet := i / 256
190190 fourthOctet := i % 256
191191 ip := fmt .Sprintf ("10.%d.%d.%d" , baseIP [1 ], baseIP [2 ]+ thirdOctet , fourthOctet )
@@ -200,6 +200,7 @@ func AddHostsToEtcHosts(config qconf.ClusterConfig) error {
200200 baseIP [1 ]++
201201 baseIP [2 ] = 0
202202 }
203+ i ++
203204 }
204205 return nil
205206}
@@ -235,18 +236,16 @@ func addComplexToConfig(config *qconf.ClusterConfig) {
235236 return
236237 }
237238 }
238- config .ComplexEntries = append (config .ComplexEntries ,
239- qconf.ComplexEntryConfig {
240- Name : "load_report_host" ,
241- Shortcut : "lrh" ,
242- Type : "STRING" ,
243- Relop : "==" ,
244- Requestable : "YES" ,
245- Consumable : "NO" ,
246- Default : "NONE" ,
247- Urgency : 0 ,
248- })
249-
239+ config .ComplexEntries ["load_report_host" ] = qconf.ComplexEntryConfig {
240+ Name : "load_report_host" ,
241+ Shortcut : "lrh" ,
242+ Type : "STRING" ,
243+ Relop : "==" ,
244+ Requestable : "YES" ,
245+ Consumable : "NO" ,
246+ Default : "NONE" ,
247+ Urgency : 0 ,
248+ }
250249}
251250
252251func addGlobalConfig (cs * qconf.CommandLineQConf ) error {
@@ -256,7 +255,7 @@ func addGlobalConfig(cs *qconf.CommandLineQConf) error {
256255 }
257256 global .QmasterParams = append (global .QmasterParams , "SIMULATE_EXECDS=TRUE" )
258257 global .ExecdParams = append (global .ExecdParams , "SIMULATE_JOBS=TRUE" )
259- return cs .ModifyGlobalConfig (global )
258+ return cs .ModifyGlobalConfig (* global )
260259}
261260
262261func addGlobalConfigToConfig (config * qconf.ClusterConfig ) {
0 commit comments