1111from vttest import sharding_utils
1212
1313import sandbox
14- import sandbox_utils
1514import sandlet
1615import subprocess_component
1716
@@ -92,7 +91,6 @@ def _generate_helm_keyspaces(self):
9291
9392 for shard_index , shard_name in enumerate (
9493 sharding_utils .get_shard_names (ks ['shard_count' ])):
95- shard_name = sandbox_utils .fix_shard_name (shard_name )
9694 shard = dict (
9795 name = shard_name ,
9896 tablets = [dict (
@@ -187,12 +185,15 @@ def _generate_helm_values_config(self):
187185 keyspaces = copy .deepcopy (keyspaces ),
188186 )
189187 # Each tablet's UID must be unique, so increment the uidBase for tablets
190- # by the cell epsilon value to ensure uniqueness. This logic will go away
191- # once StatefulSet is available.
188+ # by the cell epsilon value to ensure uniqueness. Also convert the UID to
189+ # a string, or else the parser will attempt to parse UID as a float, which
190+ # causes issues when UID's are large. This logic will go away once
191+ # StatefulSet is available.
192192 for keyspace in cell_dict ['keyspaces' ]:
193193 for shard in keyspace ['shards' ]:
194194 for tablets in shard ['tablets' ]:
195- tablets ['uidBase' ] += index * self .cell_epsilon
195+ tablets ['uidBase' ] = str (
196+ tablets ['uidBase' ] + index * self .cell_epsilon )
196197 yaml_values ['topology' ]['cells' ].append (cell_dict )
197198
198199 if index == 0 :
@@ -214,24 +215,31 @@ def generate_helm_sandlet(self):
214215 helm_sandlet = sandlet .Sandlet ('helm' )
215216 helm_sandlet .components .add_component (kubernetes_components .HelmComponent (
216217 'helm' , self .name , self ._generate_helm_values_config ()))
218+
219+ # Add a subprocess task to wait for all mysql instances to be healthy.
220+ tablet_count = 0
221+ for keyspace in self .app_options .keyspaces :
222+ tablet_count += (keyspace ['shard_count' ] * len (self .app_options .cells ) * (
223+ keyspace ['replica_count' ] + keyspace ['rdonly_count' ]))
224+ wait_for_mysql_subprocess = subprocess_component .Subprocess (
225+ 'wait_for_mysql' , self .name , 'wait_for_mysql.py' ,
226+ self .log_dir , namespace = self .name ,
227+ cells = ',' .join (self .app_options .cells ),
228+ tablet_count = tablet_count )
229+ wait_for_mysql_subprocess .dependencies = ['helm' ]
230+ helm_sandlet .components .add_component (wait_for_mysql_subprocess )
231+
232+ # Add a subprocess task for each keyspace to perform the initial reparent.
217233 for keyspace in self .app_options .keyspaces :
218234 name = keyspace ['name' ]
219235 shard_count = keyspace ['shard_count' ]
220- wait_for_mysql_subprocess = subprocess_component .Subprocess (
221- 'wait_for_mysql_%s' % name , self .name , 'wait_for_mysql.py' ,
222- self .log_dir , namespace = self .name ,
223- cells = ',' .join (self .app_options .cells ),
224- tablet_count = (shard_count * (
225- keyspace ['replica_count' ] + keyspace ['rdonly_count' ])))
226- wait_for_mysql_subprocess .dependencies = ['helm' ]
227236 initial_reparent_subprocess = subprocess_component .Subprocess (
228- 'initial_reparent_%s ' % name , self .name ,
237+ 'initial_reparent_%s_%d ' % ( name , shard_count ) , self .name ,
229238 'initial_reparent.py' , self .log_dir , namespace = self .name ,
230239 keyspace = name , shard_count = shard_count ,
231240 master_cell = self .app_options .cells [0 ])
232241 initial_reparent_subprocess .dependencies = [
233242 wait_for_mysql_subprocess .name ]
234- helm_sandlet .components .add_component (wait_for_mysql_subprocess )
235243 helm_sandlet .components .add_component (initial_reparent_subprocess )
236244 self .sandlets .add_component (helm_sandlet )
237245
0 commit comments