File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -238,6 +238,28 @@ func (this *MigrationContext) RequiresBinlogFormatChange() bool {
238
238
return this .OriginalBinlogFormat != "ROW"
239
239
}
240
240
241
+ // GetApplierHostname is a safe access method to the applier hostname
242
+ func (this * MigrationContext ) GetApplierHostname () string {
243
+ if this .ApplierConnectionConfig == nil {
244
+ return ""
245
+ }
246
+ if this .ApplierConnectionConfig .ImpliedKey == nil {
247
+ return ""
248
+ }
249
+ return this .ApplierConnectionConfig .ImpliedKey .Hostname
250
+ }
251
+
252
+ // GetInspectorHostname is a safe access method to the inspector hostname
253
+ func (this * MigrationContext ) GetInspectorHostname () string {
254
+ if this .InspectorConnectionConfig == nil {
255
+ return ""
256
+ }
257
+ if this .InspectorConnectionConfig .ImpliedKey == nil {
258
+ return ""
259
+ }
260
+ return this .InspectorConnectionConfig .ImpliedKey .Hostname
261
+ }
262
+
241
263
// InspectorIsAlsoApplier is `true` when the both inspector and applier are the
242
264
// same database instance. This would be true when running directly on master or when
243
265
// testing on replica.
Original file line number Diff line number Diff line change @@ -59,8 +59,8 @@ func (this *HooksExecutor) applyEnvironmentVairables(extraVariables ...string) [
59
59
env = append (env , fmt .Sprintf ("GH_OST_ESTIMATED_ROWS=%d" , estimatedRows ))
60
60
totalRowsCopied := this .migrationContext .GetTotalRowsCopied ()
61
61
env = append (env , fmt .Sprintf ("GH_OST_COPIED_ROWS=%d" , totalRowsCopied ))
62
- env = append (env , fmt .Sprintf ("GH_OST_MIGRATED_HOST=%s" , this .migrationContext .ApplierConnectionConfig . ImpliedKey . Hostname ))
63
- env = append (env , fmt .Sprintf ("GH_OST_INSPECTED_HOST=%s" , this .migrationContext .InspectorConnectionConfig . ImpliedKey . Hostname ))
62
+ env = append (env , fmt .Sprintf ("GH_OST_MIGRATED_HOST=%s" , this .migrationContext .GetApplierHostname () ))
63
+ env = append (env , fmt .Sprintf ("GH_OST_INSPECTED_HOST=%s" , this .migrationContext .GetInspectorHostname () ))
64
64
env = append (env , fmt .Sprintf ("GH_OST_EXECUTING_HOST=%s" , this .migrationContext .Hostname ))
65
65
env = append (env , fmt .Sprintf ("GH_OST_HOOKS_HINT=%s" , this .migrationContext .HooksHintMessage ))
66
66
You can’t perform that action at this time.
0 commit comments