Skip to content

Commit

Permalink
[TA325, TA329] fix the error messages in clone/sync process (#106)
Browse files Browse the repository at this point in the history
Signed-off-by: Utkarsh Mani Tripathi <[email protected]>
  • Loading branch information
utkarshmani1997 authored and payes committed Aug 27, 2018
1 parent 35b1330 commit 52e8a1d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func (t *Task) CloneReplica(url string, address string, cloneIP string, snapName
ControllerClient := client.NewControllerClient(url)
reps, err := ControllerClient.ListReplicas()
if err != nil {
logrus.Errorf("Failed to get replica list from %s, retry after 2s", url)
logrus.Errorf("Failed to get replica list from %s, retry after 2s, error: %s", url, err.Error())
time.Sleep(2 * time.Second)
continue
}
Expand All @@ -234,19 +234,19 @@ func (t *Task) CloneReplica(url string, address string, cloneIP string, snapName
}
fromClient, err := replicaClient.NewReplicaClient(fromReplica.Address)
if err != nil {
return fmt.Errorf("Failed to create fromClient %s", err)
return fmt.Errorf("Failed to create source replica client, error: %s", err.Error())
}
repl, err := fromClient.GetReplica()
if err != nil {
return fmt.Errorf("fromClient.GetReplica() failed, %s", err)
return fmt.Errorf("Failed to get replica info of the source, error: %s", err.Error())
}
chain := repl.Chain

logrus.Infof("Using replica %s as the source for rebuild ", fromReplica.Address)

toClient, err := replicaClient.NewReplicaClient(address)
if err != nil {
return fmt.Errorf("Failed to create toClient %s", err)
return fmt.Errorf("Failed to create client of the clone replica, error: %s", err.Error())
}
for i, name := range chain {
if name == "volume-snap-"+snapName+".img" {
Expand All @@ -262,18 +262,18 @@ func (t *Task) CloneReplica(url string, address string, cloneIP string, snapName
return fmt.Errorf("Failed to setRebuilding = true, %s", err)
}
if err = t.syncFiles(fromClient, toClient, chain); err != nil {
logrus.Errorf("Sync failed, retry after 2s")
logrus.Errorf("Sync failed, retry after 2s, error: %s", err.Error())
time.Sleep(2 * time.Second)
continue
}
toClient.UpdateCloneInfo(snapName)

_, err = toClient.ReloadReplica()
if err != nil {
return fmt.Errorf("Failed to reload replica %s", err)
return fmt.Errorf("Failed to reload clone replica, error: %s", err.Error())
}
if err := toClient.SetRebuilding(false); err != nil {
return fmt.Errorf("Failed to setRebuilding = false")
return fmt.Errorf("Failed to setRebuilding = false, error: %s", err.Error())
}
return err
}
Expand Down Expand Up @@ -443,7 +443,7 @@ func (t *Task) syncFile(from, to string, fromClient *replicaClient.ReplicaClient
logrus.Infof("Synchronizing %s to %s@%s:%d", from, to, host, port)
err = fromClient.SendFile(from, host, port)
if err != nil {
logrus.Infof("Failed synchronizing %s to %s@%s:%d: %v", from, to, host, port, err)
logrus.Errorf("Failed synchronizing %s to %s@%s:%d: %v", from, to, host, port, err)
} else {
logrus.Infof("Done synchronizing %s to %s@%s:%d", from, to, host, port)
}
Expand Down

0 comments on commit 52e8a1d

Please sign in to comment.