Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add replicaName argument to ReplicaRebuildVerify #2108

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion controller/engine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,7 @@ func syncWithRestoreStatus(log logrus.FieldLogger, engine *longhorn.Engine, rsMa
replicaName := addressReplicaMap[engineapi.GetAddressFromBackendReplicaURL(url)]
if mode, exists := engine.Status.ReplicaModeMap[replicaName]; exists && mode == longhorn.ReplicaModeWO {
log.Infof("Verifying the rebuild of replica %v after restore completion", url)
if err := engineClientProxy.ReplicaRebuildVerify(engine, url); err != nil {
if err := engineClientProxy.ReplicaRebuildVerify(engine, replicaName, url); err != nil {
log.WithError(err).Errorf("Failed to verify the rebuild of replica %v after restore completion", url)
engine.Status.ReplicaModeMap[url] = longhorn.ReplicaModeERR
return false
Expand Down
12 changes: 11 additions & 1 deletion engineapi/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,21 @@ func (e *EngineBinary) VolumeUnmapMarkSnapChainRemovedSet(engine *longhorn.Engin

// ReplicaRebuildVerify calls engine binary
// TODO: Deprecated, replaced by gRPC proxy
func (e *EngineBinary) ReplicaRebuildVerify(engine *longhorn.Engine, url string) error {
func (e *EngineBinary) ReplicaRebuildVerify(engine *longhorn.Engine, replicaName, url string) error {
if err := ValidateReplicaURL(url); err != nil {
return err
}

version, err := e.VersionGet(engine, true)
if err != nil {
return err
}

cmd := []string{"verify-rebuild-replica", url}
if version.ClientVersion.CLIAPIVersion >= 9 {
PhanLe1010 marked this conversation as resolved.
Show resolved Hide resolved
cmd = append(cmd, "--replica-instance-name", replicaName)
}

if _, err := e.ExecuteEngineBinaryWithoutTimeout([]string{}, cmd...); err != nil {
return errors.Wrapf(err, "failed to verify rebuilding for the replica from address %s", url)
}
Expand Down
2 changes: 1 addition & 1 deletion engineapi/enginesim.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func (e *EngineSimulator) VolumeUnmapMarkSnapChainRemovedSet(*longhorn.Engine) e
return fmt.Errorf(ErrNotImplement)
}

func (e *EngineSimulator) ReplicaRebuildVerify(engine *longhorn.Engine, url string) error {
func (e *EngineSimulator) ReplicaRebuildVerify(engine *longhorn.Engine, replicaName, url string) error {
return fmt.Errorf(ErrNotImplement)
}

Expand Down
5 changes: 3 additions & 2 deletions engineapi/proxy_replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ func (p *Proxy) ReplicaRebuildStatus(e *longhorn.Engine) (status map[string]*lon
return status, nil
}

func (p *Proxy) ReplicaRebuildVerify(e *longhorn.Engine, url string) (err error) {
func (p *Proxy) ReplicaRebuildVerify(e *longhorn.Engine, replicaName, url string) (err error) {
if err := ValidateReplicaURL(url); err != nil {
return err
}
return p.grpcClient.ReplicaVerifyRebuild(string(e.Spec.BackendStoreDriver), e.Name, e.Spec.VolumeName, p.DirectToURL(e), url, "")
return p.grpcClient.ReplicaVerifyRebuild(string(e.Spec.BackendStoreDriver), e.Name, e.Spec.VolumeName,
p.DirectToURL(e), url, replicaName)
}

func (p *Proxy) ReplicaModeUpdate(e *longhorn.Engine, url, mode string) (err error) {
Expand Down
2 changes: 1 addition & 1 deletion engineapi/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ type EngineClient interface {
ReplicaAdd(engine *longhorn.Engine, replicaName, url string, isRestoreVolume, fastSync bool, replicaFileSyncHTTPClientTimeout int64) error
ReplicaRemove(engine *longhorn.Engine, url string) error
ReplicaRebuildStatus(*longhorn.Engine) (map[string]*longhorn.RebuildStatus, error)
ReplicaRebuildVerify(engine *longhorn.Engine, url string) error
ReplicaRebuildVerify(engine *longhorn.Engine, replicaName, url string) error
ReplicaModeUpdate(engine *longhorn.Engine, url string, mode string) error

SnapshotCreate(engine *longhorn.Engine, name string, labels map[string]string) (string, error)
Expand Down