From 413cf47a9eaed5bd44a722ef89260525982d44cf Mon Sep 17 00:00:00 2001 From: Derek Su Date: Tue, 19 Nov 2024 08:06:23 +0000 Subject: [PATCH] feat(v2 upgrade): support engine live upgrade Longhorn 9104 Signed-off-by: Derek Su --- pkg/api/instance.go | 32 ++++++++++++++++++-------------- pkg/instance/instance.go | 21 ++++++++++++--------- 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/pkg/api/instance.go b/pkg/api/instance.go index 74752823a..2f5b7042a 100644 --- a/pkg/api/instance.go +++ b/pkg/api/instance.go @@ -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, } } diff --git a/pkg/instance/instance.go b/pkg/instance/instance.go index a534ed39c..809557943 100644 --- a/pkg/instance/instance.go +++ b/pkg/instance/instance.go @@ -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" @@ -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 } @@ -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), }, } }