Skip to content

Commit

Permalink
feat(v2 upgrade): support engine live upgrade
Browse files Browse the repository at this point in the history
Longhorn 9104

Signed-off-by: Derek Su <[email protected]>
  • Loading branch information
derekbit committed Nov 19, 2024
1 parent 58de1f7 commit fc70fdf
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 23 deletions.
32 changes: 18 additions & 14 deletions pkg/api/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,28 @@ func RPCToInstanceList(obj *rpc.InstanceListResponse) map[string]*Instance {
}

type InstanceStatus struct {
State string `json:"state"`
ErrorMsg string `json:"errorMsg"`
Conditions map[string]bool `json:"conditions"`
PortStart int32 `json:"portStart"`
PortEnd int32 `json:"portEnd"`
TargetPortStart int32 `json:"targetPortStart"`
TargetPortEnd int32 `json:"targetPortEnd"`
State string `json:"state"`
ErrorMsg string `json:"errorMsg"`
Conditions map[string]bool `json:"conditions"`
PortStart int32 `json:"portStart"`
PortEnd int32 `json:"portEnd"`
TargetPortStart int32 `json:"targetPortStart"`
TargetPortEnd int32 `json:"targetPortEnd"`
StandbyTargetPortStart int32 `json:"standbyTargetPortStart"`
StandbyTargetPortEnd int32 `json:"standbyTargetPortEnd"`
}

func RPCToInstanceStatus(obj *rpc.InstanceStatus) InstanceStatus {
return InstanceStatus{
State: obj.State,
ErrorMsg: obj.ErrorMsg,
Conditions: obj.Conditions,
PortStart: obj.PortStart,
PortEnd: obj.PortEnd,
TargetPortStart: obj.TargetPortStart,
TargetPortEnd: obj.TargetPortEnd,
State: obj.State,
ErrorMsg: obj.ErrorMsg,
Conditions: obj.Conditions,
PortStart: obj.PortStart,
PortEnd: obj.PortEnd,
TargetPortStart: obj.TargetPortStart,
TargetPortEnd: obj.TargetPortEnd,
StandbyTargetPortStart: obj.StandbyTargetPortStart,
StandbyTargetPortEnd: obj.StandbyTargetPortEnd,
}
}

Expand Down
21 changes: 12 additions & 9 deletions pkg/instance/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import (
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"golang.org/x/sync/errgroup"
"google.golang.org/protobuf/types/known/emptypb"

grpccodes "google.golang.org/grpc/codes"
grpcstatus "google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/emptypb"

lhLonghorn "github.com/longhorn/go-common-libs/longhorn"
spdkapi "github.com/longhorn/longhorn-spdk-engine/pkg/api"
Expand Down Expand Up @@ -151,7 +152,7 @@ func (ops V2DataEngineInstanceOps) InstanceCreate(req *rpc.InstanceCreateRequest
switch req.Spec.Type {
case types.InstanceTypeEngine:
engine, err := c.EngineCreate(req.Spec.Name, req.Spec.VolumeName, req.Spec.SpdkInstanceSpec.Frontend, req.Spec.SpdkInstanceSpec.Size, req.Spec.SpdkInstanceSpec.ReplicaAddressMap,
req.Spec.PortCount, req.Spec.InitiatorAddress, req.Spec.TargetAddress, req.Spec.UpgradeRequired, req.Spec.SpdkInstanceSpec.SalvageRequested)
req.Spec.PortCount, req.Spec.InitiatorAddress, req.Spec.TargetAddress, req.Spec.SpdkInstanceSpec.SalvageRequested)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -719,13 +720,15 @@ func engineResponseToInstanceResponse(e *spdkapi.Engine) *rpc.InstanceResponse {
DataEngine: rpc.DataEngine_DATA_ENGINE_V2,
},
Status: &rpc.InstanceStatus{
State: e.State,
ErrorMsg: e.ErrorMsg,
PortStart: e.Port,
PortEnd: e.Port,
TargetPortStart: e.TargetPort,
TargetPortEnd: e.TargetPort,
Conditions: make(map[string]bool),
State: e.State,
ErrorMsg: e.ErrorMsg,
PortStart: e.Port,
PortEnd: e.Port,
TargetPortStart: e.TargetPort,
TargetPortEnd: e.TargetPort,
StandbyTargetPortStart: e.StandbyTargetPort,
StandbyTargetPortEnd: e.StandbyTargetPort,
Conditions: make(map[string]bool),
},
}
}
Expand Down

0 comments on commit fc70fdf

Please sign in to comment.