Skip to content

Commit

Permalink
feat: remove proto
Browse files Browse the repository at this point in the history
Signed-off-by: PoAn Yang <[email protected]>
  • Loading branch information
FrankYang0529 committed Feb 20, 2024
1 parent ef81964 commit bd103d6
Show file tree
Hide file tree
Showing 16 changed files with 45 additions and 7,007 deletions.
43 changes: 8 additions & 35 deletions Dockerfile.dapper
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ ARG DAPPER_HOST_ARCH=amd64
ARG http_proxy
ARG https_proxy
ENV HOST_ARCH=${DAPPER_HOST_ARCH} ARCH=${DAPPER_HOST_ARCH}
ENV PROTOBUF_VER=24.3
ENV PROTOBUF_VER_PY=4.24.3

# Setup environment
ENV PATH /go/bin:$PATH
Expand Down Expand Up @@ -43,16 +41,16 @@ RUN git clone https://github.com/longhorn/spdk.git ${SPDK_DIR} --recursive && \
git submodule update --init && \
./scripts/pkgdep.sh && \
if [ ${ARCH} = "amd64" ]; then \
./configure --target-arch=nehalem --disable-tests --disable-unit-tests --disable-examples && \
make -j$(nproc) && \
make install; \
./configure --target-arch=nehalem --disable-tests --disable-unit-tests --disable-examples && \
make -j$(nproc) && \
make install; \
elif [ ${ARCH} = "arm64" ]; then \
./configure --target-arch=native --disable-tests --disable-unit-tests --disable-examples && \
DPDKBUILD_FLAGS="-Dplatform=generic" make -j$(nproc) && \
make install; \
./configure --target-arch=native --disable-tests --disable-unit-tests --disable-examples && \
DPDKBUILD_FLAGS="-Dplatform=generic" make -j$(nproc) && \
make install; \
else \
echo "Unsupported architecture: ${ARCH}"; \
exit 1; \
echo "Unsupported architecture: ${ARCH}"; \
exit 1; \
fi

# Build libjson-c-devel
Expand Down Expand Up @@ -87,31 +85,6 @@ ENV GRPC_HEALTH_PROBE_amd64=https://github.com/grpc-ecosystem/grpc-health-probe/
RUN wget ${!GRPC_HEALTH_PROBE} -O /usr/local/bin/grpc_health_probe && \
chmod +x /usr/local/bin/grpc_health_probe

# protoc
ENV PROTOC_amd64=https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VER}/protoc-${PROTOBUF_VER}-linux-x86_64.zip \
PROTOC_arm64=https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VER}/protoc-${PROTOBUF_VER}-linux-aarch_64.zip \
PROTOC_s390x=https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VER}/protoc-${PROTOBUF_VER}-linux-s390_64.zip \
PROTOC=PROTOC_${ARCH}

RUN cd /usr/src && \
wget ${!PROTOC} -O protoc_${ARCH}.zip && \
unzip protoc_${ARCH}.zip -d /usr/local/

# protoc-gen-go
RUN cd /go/src/github.com/ && \
mkdir golang/ && \
cd golang && \
git clone https://github.com/golang/protobuf.git && \
cd protobuf && \
git checkout v1.5.3 && \
cd protoc-gen-go && \
go build && \
cp protoc-gen-go /usr/local/bin

# buf
ENV GO111MODULE=on
RUN go install github.com/bufbuild/buf/cmd/[email protected]

# longhorn/go-spdk-helper binary for debugging
ENV GO_SPDK_HELPER_DIR /usr/src/go-spdk-helper
RUN git clone https://github.com/longhorn/go-spdk-helper.git ${GO_SPDK_HELPER_DIR} && \
Expand Down
23 changes: 0 additions & 23 deletions generate_grpc.sh

This file was deleted.

4 changes: 2 additions & 2 deletions pkg/api/types.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package api

import (
"github.com/longhorn/types/pkg/spdkrpc"
"google.golang.org/protobuf/types/known/emptypb"

"github.com/longhorn/longhorn-spdk-engine/pkg/types"
"github.com/longhorn/longhorn-spdk-engine/proto/spdkrpc"
)

type Replica struct {
Expand Down Expand Up @@ -144,7 +144,7 @@ func ProtoEngineToEngine(e *spdkrpc.Engine) *Engine {
ErrorMsg: e.ErrorMsg,
}
for rName, mode := range e.ReplicaModeMap {
res.ReplicaModeMap[rName] = spdkrpc.GRPCReplicaModeToReplicaMode(mode)
res.ReplicaModeMap[rName] = types.GRPCReplicaModeToReplicaMode(mode)
}
for snapshotName, snapProtoLvol := range e.Snapshots {
res.Snapshots[snapshotName] = ProtoLvolToLvol(snapProtoLvol)
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (
"github.com/pkg/errors"
"google.golang.org/grpc"

"github.com/longhorn/types/pkg/spdkrpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/protobuf/types/known/emptypb"

"github.com/longhorn/longhorn-spdk-engine/pkg/api"
"github.com/longhorn/longhorn-spdk-engine/pkg/util"
"github.com/longhorn/longhorn-spdk-engine/proto/spdkrpc"
)

func (c *SPDKServiceContext) Close() error {
Expand Down
3 changes: 1 addition & 2 deletions pkg/client/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package client
import (
"time"

"github.com/longhorn/types/pkg/spdkrpc"
"google.golang.org/grpc"

"github.com/longhorn/longhorn-spdk-engine/proto/spdkrpc"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion pkg/spdk/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import (
spdkclient "github.com/longhorn/go-spdk-helper/pkg/spdk/client"
spdktypes "github.com/longhorn/go-spdk-helper/pkg/spdk/types"
spdkutil "github.com/longhorn/go-spdk-helper/pkg/util"
"github.com/longhorn/types/pkg/spdkrpc"

"github.com/longhorn/longhorn-spdk-engine/pkg/util"
"github.com/longhorn/longhorn-spdk-engine/proto/spdkrpc"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions pkg/spdk/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import (
spdktypes "github.com/longhorn/go-spdk-helper/pkg/spdk/types"
helpertypes "github.com/longhorn/go-spdk-helper/pkg/types"
helperutil "github.com/longhorn/go-spdk-helper/pkg/util"
"github.com/longhorn/types/pkg/spdkrpc"

"github.com/longhorn/longhorn-spdk-engine/pkg/api"
"github.com/longhorn/longhorn-spdk-engine/pkg/client"
"github.com/longhorn/longhorn-spdk-engine/pkg/types"
"github.com/longhorn/longhorn-spdk-engine/pkg/util"
"github.com/longhorn/longhorn-spdk-engine/proto/spdkrpc"
)

type Engine struct {
Expand Down Expand Up @@ -380,7 +380,7 @@ func (e *Engine) getWithoutLock() (res *spdkrpc.Engine) {
}

for replicaName, replicaMode := range e.ReplicaModeMap {
res.ReplicaModeMap[replicaName] = spdkrpc.ReplicaModeToGRPCReplicaMode(replicaMode)
res.ReplicaModeMap[replicaName] = types.ReplicaModeToGRPCReplicaMode(replicaMode)
}
res.Head = api.LvolToProtoLvol(e.Head)
for snapshotName, snapApiLvol := range e.SnapshotMap {
Expand Down
2 changes: 1 addition & 1 deletion pkg/spdk/replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import (
spdktypes "github.com/longhorn/go-spdk-helper/pkg/spdk/types"
helpertypes "github.com/longhorn/go-spdk-helper/pkg/types"
helperutil "github.com/longhorn/go-spdk-helper/pkg/util"
"github.com/longhorn/types/pkg/spdkrpc"

"github.com/longhorn/longhorn-spdk-engine/pkg/types"
"github.com/longhorn/longhorn-spdk-engine/pkg/util"
"github.com/longhorn/longhorn-spdk-engine/proto/spdkrpc"
)

const (
Expand Down
3 changes: 2 additions & 1 deletion pkg/spdk/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,20 @@ import (
spdkclient "github.com/longhorn/go-spdk-helper/pkg/spdk/client"
spdktypes "github.com/longhorn/go-spdk-helper/pkg/spdk/types"
helpertypes "github.com/longhorn/go-spdk-helper/pkg/types"
"github.com/longhorn/types/pkg/spdkrpc"

"github.com/longhorn/longhorn-spdk-engine/pkg/api"
"github.com/longhorn/longhorn-spdk-engine/pkg/types"
"github.com/longhorn/longhorn-spdk-engine/pkg/util"
"github.com/longhorn/longhorn-spdk-engine/pkg/util/broadcaster"
"github.com/longhorn/longhorn-spdk-engine/proto/spdkrpc"
)

const (
MonitorInterval = 3 * time.Second
)

type Server struct {
spdkrpc.UnimplementedSPDKServiceServer
sync.RWMutex

ctx context.Context
Expand Down
2 changes: 1 addition & 1 deletion pkg/spdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ import (
"github.com/longhorn/go-spdk-helper/pkg/spdk/target"
helpertypes "github.com/longhorn/go-spdk-helper/pkg/types"
helperutil "github.com/longhorn/go-spdk-helper/pkg/util"
"github.com/longhorn/types/pkg/spdkrpc"

"github.com/longhorn/longhorn-spdk-engine/pkg/client"
server "github.com/longhorn/longhorn-spdk-engine/pkg/spdk"
"github.com/longhorn/longhorn-spdk-engine/pkg/types"
"github.com/longhorn/longhorn-spdk-engine/pkg/util"
"github.com/longhorn/longhorn-spdk-engine/proto/spdkrpc"

. "gopkg.in/check.v1"
)
Expand Down
26 changes: 26 additions & 0 deletions pkg/types/types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package types

import "github.com/longhorn/types/pkg/spdkrpc"

type Mode string

const (
Expand Down Expand Up @@ -34,3 +36,27 @@ const (
const VolumeHead = "volume-head"

const SPDKServicePort = 8504

func ReplicaModeToGRPCReplicaMode(mode Mode) spdkrpc.ReplicaMode {
switch mode {
case ModeWO:
return spdkrpc.ReplicaMode_WO
case ModeRW:
return spdkrpc.ReplicaMode_RW
case ModeERR:
return spdkrpc.ReplicaMode_ERR
}
return spdkrpc.ReplicaMode_ERR
}

func GRPCReplicaModeToReplicaMode(replicaMode spdkrpc.ReplicaMode) Mode {
switch replicaMode {
case spdkrpc.ReplicaMode_WO:
return ModeWO
case spdkrpc.ReplicaMode_RW:
return ModeRW
case spdkrpc.ReplicaMode_ERR:
return ModeERR
}
return ModeERR
}
Loading

0 comments on commit bd103d6

Please sign in to comment.