(containerID string)
| 1242 | } |
| 1243 | |
| 1244 | func (c *LocalCluster) checkDgraphVersion(containerID string) error { |
| 1245 | if c.GetVersion() == localVersion { |
| 1246 | return nil |
| 1247 | } |
| 1248 | |
| 1249 | contLogs, err := c.getLogs(containerID) |
| 1250 | if err != nil { |
| 1251 | return errors.Wrapf(err, "error during checkDgraphVersion for container [%v]", containerID) |
| 1252 | } |
| 1253 | |
| 1254 | // During in-place upgrade, container remains same but logs have version string twice |
| 1255 | // once for old version, once for new. Want new version string. Look bottom-up using |
| 1256 | // LastIndex to get latest version's string. |
| 1257 | index := strings.LastIndex(contLogs, "Commit SHA-1 : ") |
| 1258 | running := strings.Fields(contLogs[index : index+70])[3] // 70 is arbitrary |
| 1259 | chash, err := getHash(c.GetVersion()) |
| 1260 | if err != nil { |
| 1261 | return errors.Wrapf(err, "error while getting hash for %v", c.GetVersion()) |
| 1262 | } |
| 1263 | rhash, err := getHash(running) |
| 1264 | if err != nil { |
| 1265 | return errors.Wrapf(err, "error while getting hash for %v", running) |
| 1266 | } |
| 1267 | if chash != rhash { |
| 1268 | return errors.Errorf("found different dgraph version [%v] than expected [%v]", rhash, chash) |
| 1269 | } |
| 1270 | return nil |
| 1271 | } |
| 1272 | |
| 1273 | func (c *LocalCluster) getLogs(containerID string) (string, error) { |
| 1274 | ctx, cancel := context.WithTimeout(context.Background(), requestTimeout) |
no test coverage detected