Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Su <[email protected]>
  • Loading branch information
derekbit committed Nov 26, 2024
1 parent 293e308 commit a8e9e60
Show file tree
Hide file tree
Showing 10 changed files with 2,218 additions and 1,742 deletions.
6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ require (
sigs.k8s.io/yaml v1.4.0 // indirect
)

replace github.com/longhorn/longhorn-spdk-engine v0.0.0-20241124131155-114edffb76fa => github.com/derekbit/longhorn-spdk-engine v0.0.0-20241126034419-423159932e28
replace github.com/longhorn/longhorn-spdk-engine v0.0.0-20241124131155-114edffb76fa => github.com/derekbit/longhorn-spdk-engine v0.0.0-20241126133252-59d33f405716

replace github.com/longhorn/types v0.0.0-20241123075624-48c550af4eab => github.com/derekbit/longhorn-types v0.0.0-20241117074921-a5e533aa1bf3
replace github.com/longhorn/types v0.0.0-20241123075624-48c550af4eab => github.com/derekbit/longhorn-types v0.0.0-20241126114320-36b8b01a8cb5

replace github.com/longhorn/go-spdk-helper v0.0.0-20241124090314-c396ae715a7f => github.com/derekbit/go-spdk-helper v0.0.0-20241126133109-a064d2aacb00
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/derekbit/longhorn-spdk-engine v0.0.0-20241126034419-423159932e28 h1:OEURyytdZw1tyTlkQdR/b/8m0YPLEeLgfA31dk7ZUr8=
github.com/derekbit/longhorn-spdk-engine v0.0.0-20241126034419-423159932e28/go.mod h1:9GC7IAZYNuaiRAjDrg/Jal/1noTAUFEKOYIzpVrS+Rc=
github.com/derekbit/longhorn-types v0.0.0-20241117074921-a5e533aa1bf3 h1:Y4C06qbAuFS3zVyIv5YtC1vojud1ayaSgGEXsMMcfFs=
github.com/derekbit/longhorn-types v0.0.0-20241117074921-a5e533aa1bf3/go.mod h1:dIPa2yMBPOa514bn3pohT7kbVAQcZbZSWItpgxunuPs=
github.com/derekbit/go-spdk-helper v0.0.0-20241126133109-a064d2aacb00 h1:y4hBPdgnj0bZbkN1NnjHVpIwdJ437og3ZLT0SZ4IOm8=
github.com/derekbit/go-spdk-helper v0.0.0-20241126133109-a064d2aacb00/go.mod h1:F4KxpqJXmghH0E3GH0XRSr7M0v5DROFEwaecPbhnGY4=
github.com/derekbit/longhorn-spdk-engine v0.0.0-20241126133252-59d33f405716 h1:bBjnVWizzR2kSLRo+us1VSVyCu4fyZWuT93A/4KJ6o4=
github.com/derekbit/longhorn-spdk-engine v0.0.0-20241126133252-59d33f405716/go.mod h1:AfeMEWiWn86rKI/f122fp5pIID//LSdyfo2lIvvZHrc=
github.com/derekbit/longhorn-types v0.0.0-20241126114320-36b8b01a8cb5 h1:r7oV/k86j2XNfNOXvGrkUwjoZNT4EpeL67kUf46JgGc=
github.com/derekbit/longhorn-types v0.0.0-20241126114320-36b8b01a8cb5/go.mod h1:dIPa2yMBPOa514bn3pohT7kbVAQcZbZSWItpgxunuPs=
github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g=
github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
Expand Down Expand Up @@ -115,8 +117,6 @@ github.com/longhorn/go-common-libs v0.0.0-20241124035508-d6221574e626 h1:6RHxLM2
github.com/longhorn/go-common-libs v0.0.0-20241124035508-d6221574e626/go.mod h1:gSa+qB058kcNlCaOOwIFPHb3tvqMTmKcxtL7HPTS4o4=
github.com/longhorn/go-iscsi-helper v0.0.0-20241110033836-dd4b01aa15b8 h1:vM7FiS3/EVzJGW7AXp0Kcz+15MOHF+VTHz0mlsP+Ngo=
github.com/longhorn/go-iscsi-helper v0.0.0-20241110033836-dd4b01aa15b8/go.mod h1:UvAltu/RQZV5i18GcUcGGWA91dzfFR/ylIgKcItsnjk=
github.com/longhorn/go-spdk-helper v0.0.0-20241124090314-c396ae715a7f h1:P/XoCIN6+4q05tCTRAsSsVLMC8c0NV31HCkn+6xKrsc=
github.com/longhorn/go-spdk-helper v0.0.0-20241124090314-c396ae715a7f/go.mod h1:F4KxpqJXmghH0E3GH0XRSr7M0v5DROFEwaecPbhnGY4=
github.com/longhorn/longhorn-engine v1.8.0-dev-20241117 h1:2sW/dPj69/XrMDjsh2LBZ2cyOXb5MQBI7HJCuDc2vjs=
github.com/longhorn/longhorn-engine v1.8.0-dev-20241117/go.mod h1:3VnMqI8YqJ76XdRvnMWJNp1U1ITAyOwOjKtbYPqLqQw=
github.com/longhorn/sparse-tools v0.0.0-20241023025917-7951cd783270 h1:F13lddDaeUX8dBwRqOT/aXtb2C1szwqIFgW4KpZgCGw=
Expand Down
27 changes: 27 additions & 0 deletions pkg/api/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ func RPCToInstanceList(obj *rpc.InstanceListResponse) map[string]*Instance {
return ret
}

type NvmeDevicePath struct {
Trtype string `json:"trtype"`
Traddr string `json:"traddr"`
Trsvcid string `json:"trsvcid"`
SrcAddr string `json:"src_addr"`
State string `json:"state"`
}

type NvmeSubsystem struct {
Paths map[string]NvmeDevicePath `json:"paths"`
}

type InstanceStatus struct {
State string `json:"state"`
ErrorMsg string `json:"errorMsg"`
Expand All @@ -73,9 +85,23 @@ type InstanceStatus struct {
TargetPortEnd int32 `json:"targetPortEnd"`
StandbyTargetPortStart int32 `json:"standbyTargetPortStart"`
StandbyTargetPortEnd int32 `json:"standbyTargetPortEnd"`
NvmeSubsystem NvmeSubsystem `json:"nvmeSubsystem"`
}

func RPCToInstanceStatus(obj *rpc.InstanceStatus) InstanceStatus {
nvmeSubstem := NvmeSubsystem{
Paths: map[string]NvmeDevicePath{},
}
for pathName, path := range obj.NvmeSubsystem.Paths {
nvmeSubstem.Paths[pathName] = NvmeDevicePath{
Trtype: path.Trtype,
Traddr: path.Traddr,
Trsvcid: path.Trsvcid,
SrcAddr: path.SrcAddr,
State: path.State,
}
}

return InstanceStatus{
State: obj.State,
ErrorMsg: obj.ErrorMsg,
Expand All @@ -86,6 +112,7 @@ func RPCToInstanceStatus(obj *rpc.InstanceStatus) InstanceStatus {
TargetPortEnd: obj.TargetPortEnd,
StandbyTargetPortStart: obj.StandbyTargetPortStart,
StandbyTargetPortEnd: obj.StandbyTargetPortEnd,
NvmeSubsystem: nvmeSubstem,
}
}

Expand Down
16 changes: 16 additions & 0 deletions pkg/instance/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,21 @@ func replicaResponseToInstanceResponse(r *spdkapi.Replica) *rpc.InstanceResponse
}

func engineResponseToInstanceResponse(e *spdkapi.Engine) *rpc.InstanceResponse {
nvmeSubsystem := &rpc.NvmeSubsystem{
Paths: make(map[string]*rpc.NvmeDevicePath),
}
for pathName, path := range e.NvmeSubsystem.Paths {
nvmeSubsystem.Paths[pathName] = &rpc.NvmeDevicePath{
Trtype: path.Trtype,
Traddr: path.Traddr,
Trsvcid: path.Trsvcid,
SrcAddr: path.SrcAddr,
State: path.State,
}

logrus.Infof("Debug =====> pathName: %v, path: %v", pathName, path)
}

return &rpc.InstanceResponse{
Spec: &rpc.InstanceSpec{
Name: e.Name,
Expand All @@ -729,6 +744,7 @@ func engineResponseToInstanceResponse(e *spdkapi.Engine) *rpc.InstanceResponse {
StandbyTargetPortStart: e.StandbyTargetPort,
StandbyTargetPortEnd: e.StandbyTargetPort,
Conditions: make(map[string]bool),
NvmeSubsystem: nvmeSubsystem,
},
}
}
Expand Down
15 changes: 9 additions & 6 deletions vendor/github.com/longhorn/go-spdk-helper/pkg/nvme/initiator.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions vendor/github.com/longhorn/longhorn-spdk-engine/pkg/api/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions vendor/github.com/longhorn/longhorn-spdk-engine/pkg/spdk/engine.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a8e9e60

Please sign in to comment.