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 @@ -236,6 +236,28 @@ func (this *MigrationContext) RequiresBinlogFormatChange() bool {
236
236
return this .OriginalBinlogFormat != "ROW"
237
237
}
238
238
239
+ // GetApplierHostname is a safe access method to the applier hostname
240
+ func (this * MigrationContext ) GetApplierHostname () string {
241
+ if this .ApplierConnectionConfig == nil {
242
+ return ""
243
+ }
244
+ if this .ApplierConnectionConfig .ImpliedKey == nil {
245
+ return ""
246
+ }
247
+ return this .ApplierConnectionConfig .ImpliedKey .Hostname
248
+ }
249
+
250
+ // GetInspectorHostname is a safe access method to the inspector hostname
251
+ func (this * MigrationContext ) GetInspectorHostname () string {
252
+ if this .InspectorConnectionConfig == nil {
253
+ return ""
254
+ }
255
+ if this .InspectorConnectionConfig .ImpliedKey == nil {
256
+ return ""
257
+ }
258
+ return this .InspectorConnectionConfig .ImpliedKey .Hostname
259
+ }
260
+
239
261
// InspectorIsAlsoApplier is `true` when the both inspector and applier are the
240
262
// same database instance. This would be true when running directly on master or when
241
263
// 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