@@ -47,6 +47,11 @@ func setupConfigServer(configSVRDSN, secondaryHost string) error {
47
47
return err
48
48
}
49
49
50
+ output , err = extractJSON (string (output ))
51
+ if err != nil {
52
+ return err
53
+ }
54
+
50
55
err = json .Unmarshal (output , & v )
51
56
if err != nil {
52
57
klog .Errorf ("Unmarshal error while running findAndModify to setup configServer : %s \n " , err .Error ())
@@ -68,7 +73,18 @@ func setupConfigServer(configSVRDSN, secondaryHost string) error {
68
73
"--eval" , "rs.secondaryOk(); db.BackupControl.find({ '_id' : 'BackupControlDocument' }).readConcern('majority');" ,
69
74
}, mongoCreds ... )
70
75
71
- if err := sh .Command (MongoCMD , args ... ).UnmarshalJSON (& v ); err != nil {
76
+ output , err := sh .Command (MongoCMD , args ... ).Command ("/usr/bin/tail" , "-1" ).Output ()
77
+ if err != nil {
78
+ return err
79
+ }
80
+
81
+ output , err = extractJSON (string (output ))
82
+ if err != nil {
83
+ return err
84
+ }
85
+
86
+ err = json .Unmarshal (output , & v )
87
+ if err != nil {
72
88
return err
73
89
}
74
90
@@ -111,6 +127,11 @@ func lockSecondaryMember(mongohost string) error {
111
127
return err
112
128
}
113
129
130
+ output , err = extractJSON (string (output ))
131
+ if err != nil {
132
+ return err
133
+ }
134
+
114
135
err = json .Unmarshal (output , & v )
115
136
if err != nil {
116
137
klog .Errorf ("Unmarshal error while running fsyncLock on secondary : %s \n " , err .Error ())
@@ -139,6 +160,12 @@ func checkIfSecondaryLockedAndSync(mongohost string) error {
139
160
klog .Errorf ("Error while running currentOp on secondary : %s ; output : %s \n " , err .Error (), output )
140
161
return err
141
162
}
163
+
164
+ output , err = extractJSON (string (output ))
165
+ if err != nil {
166
+ return err
167
+ }
168
+
142
169
err = json .Unmarshal (output , & x )
143
170
if err != nil {
144
171
klog .Errorf ("Unmarshal error while running currentOp on secondary : %s \n " , err .Error ())
@@ -171,8 +198,18 @@ func waitForSecondarySync(mongohost string) error {
171
198
"--eval" , "JSON.stringify(rs.status())" ,
172
199
}, mongoCreds ... )
173
200
174
- if err := sh .Command (MongoCMD , args ... ).Command ("/usr/bin/tail" , "-1" ).UnmarshalJSON (& status ); err != nil {
175
- klog .Errorf ("Error while running status on secondary : %s ; output : %s \n " , mongohost , err .Error ())
201
+ output , err := sh .Command (MongoCMD , args ... ).Command ("/usr/bin/tail" , "-1" ).Output ()
202
+ if err != nil {
203
+ return err
204
+ }
205
+
206
+ output , err = extractJSON (string (output ))
207
+ if err != nil {
208
+ return err
209
+ }
210
+
211
+ err = json .Unmarshal (output , & status )
212
+ if err != nil {
176
213
return err
177
214
}
178
215
@@ -261,6 +298,12 @@ func unlockSecondaryMember(mongohost string) error {
261
298
klog .Errorf ("Error while running fsyncUnlock on secondary : %s ; output : %s \n " , err .Error (), output )
262
299
return err
263
300
}
301
+
302
+ output , err = extractJSON (string (output ))
303
+ if err != nil {
304
+ return err
305
+ }
306
+
264
307
err = json .Unmarshal (output , & v )
265
308
if err != nil {
266
309
klog .Errorf ("Unmarshal error while running fsyncUnlock on secondary : %s \n " , err .Error ())
0 commit comments