Skip to content

Commit

Permalink
feat: remove proto
Browse files Browse the repository at this point in the history
Signed-off-by: PoAn Yang <poan.yang@suse.com>
  • Loading branch information
FrankYang0529 committed Feb 20, 2024
1 parent f216e45 commit 081ccbc
Show file tree
Hide file tree
Showing 25 changed files with 295 additions and 10,644 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
with:
check_filenames: true
ignore_words_file: .codespellignore
skip: "./proto,*/**.yaml,*/**.yml,./scripts,./vendor,MAINTAINERS,LICENSE,go.mod,go.sum"
skip: "*/**.yaml,*/**.yml,./scripts,./vendor,MAINTAINERS,LICENSE,go.mod,go.sum"
21 changes: 0 additions & 21 deletions Dockerfile.dapper
Original file line number Diff line number Diff line change
Expand Up @@ -73,27 +73,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

# TODO: use default python3 if SLE upgrade system python version to python3.11
RUN ln -sf /usr/bin/python3.11 /usr/bin/python3 & \
ln -sf /usr/bin/pip3.11 /usr/bin/pip3
Expand Down
4 changes: 2 additions & 2 deletions app/cmd/profiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/urfave/cli"
"google.golang.org/grpc"

"github.com/longhorn/longhorn-engine/proto/ptypes"
"github.com/longhorn/longhorn-engine/pkg/interceptor"
)

const (
Expand Down Expand Up @@ -39,7 +39,7 @@ func getProfilerClient(c *cli.Context) (*profiler.Client, error) {
url := c.GlobalString("url")
volumeName := c.GlobalString("volume-name")
engineInstanceName := c.GlobalString("engine-instance-name")
dialOpts := []grpc.DialOption{ptypes.WithIdentityValidationClientInterceptor(volumeName, engineInstanceName)}
dialOpts := []grpc.DialOption{interceptor.WithIdentityValidationClientInterceptor(volumeName, engineInstanceName)}
return profiler.NewClient(url, volumeName, dialOpts...)
}

Expand Down
36 changes: 0 additions & 36 deletions generate_grpc.sh

This file was deleted.

57 changes: 29 additions & 28 deletions pkg/backend/remote/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strconv"
"time"

"github.com/longhorn/longhorn-interface/pkg/enginerpc"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"golang.org/x/net/context"
Expand All @@ -14,10 +15,10 @@ import (
"google.golang.org/protobuf/types/known/emptypb"

"github.com/longhorn/longhorn-engine/pkg/dataconn"
"github.com/longhorn/longhorn-engine/pkg/interceptor"
replicaClient "github.com/longhorn/longhorn-engine/pkg/replica/client"
"github.com/longhorn/longhorn-engine/pkg/types"
"github.com/longhorn/longhorn-engine/pkg/util"
"github.com/longhorn/longhorn-engine/proto/ptypes"
)

const (
Expand Down Expand Up @@ -47,12 +48,12 @@ type Remote struct {
func (r *Remote) Close() error {
logrus.Infof("Closing: %s", r.name)
conn, err := grpc.Dial(r.replicaServiceURL, grpc.WithTransportCredentials(insecure.NewCredentials()),
ptypes.WithIdentityValidationClientInterceptor(r.volumeName, ""))
interceptor.WithIdentityValidationClientInterceptor(r.volumeName, ""))
if err != nil {
return errors.Wrapf(err, "cannot connect to ReplicaService %v", r.replicaServiceURL)
}
defer conn.Close()
replicaServiceClient := ptypes.NewReplicaServiceClient(conn)
replicaServiceClient := enginerpc.NewReplicaServiceClient(conn)

ctx, cancel := context.WithTimeout(context.Background(), replicaClient.GRPCServiceCommonTimeout)
defer cancel()
Expand All @@ -67,12 +68,12 @@ func (r *Remote) Close() error {
func (r *Remote) open() error {
logrus.Infof("Opening remote: %s", r.name)
conn, err := grpc.Dial(r.replicaServiceURL, grpc.WithTransportCredentials(insecure.NewCredentials()),
ptypes.WithIdentityValidationClientInterceptor(r.volumeName, ""))
interceptor.WithIdentityValidationClientInterceptor(r.volumeName, ""))
if err != nil {
return errors.Wrapf(err, "cannot connect to ReplicaService %v", r.replicaServiceURL)
}
defer conn.Close()
replicaServiceClient := ptypes.NewReplicaServiceClient(conn)
replicaServiceClient := enginerpc.NewReplicaServiceClient(conn)

ctx, cancel := context.WithTimeout(context.Background(), replicaClient.GRPCServiceCommonTimeout)
defer cancel()
Expand All @@ -88,17 +89,17 @@ func (r *Remote) Snapshot(name string, userCreated bool, created string, labels
logrus.Infof("Starting to snapshot: %s %s UserCreated %v Created at %v, Labels %v",
r.name, name, userCreated, created, labels)
conn, err := grpc.Dial(r.replicaServiceURL, grpc.WithTransportCredentials(insecure.NewCredentials()),
ptypes.WithIdentityValidationClientInterceptor(r.volumeName, ""))
interceptor.WithIdentityValidationClientInterceptor(r.volumeName, ""))
if err != nil {
return errors.Wrapf(err, "cannot connect to ReplicaService %v", r.replicaServiceURL)
}
defer conn.Close()
replicaServiceClient := ptypes.NewReplicaServiceClient(conn)
replicaServiceClient := enginerpc.NewReplicaServiceClient(conn)

ctx, cancel := context.WithTimeout(context.Background(), replicaClient.GRPCServiceCommonTimeout)
defer cancel()

if _, err := replicaServiceClient.ReplicaSnapshot(ctx, &ptypes.ReplicaSnapshotRequest{
if _, err := replicaServiceClient.ReplicaSnapshot(ctx, &enginerpc.ReplicaSnapshotRequest{
Name: name,
UserCreated: userCreated,
Created: created,
Expand All @@ -118,17 +119,17 @@ func (r *Remote) Expand(size int64) (err error) {
}()

conn, err := grpc.Dial(r.replicaServiceURL, grpc.WithTransportCredentials(insecure.NewCredentials()),
ptypes.WithIdentityValidationClientInterceptor(r.volumeName, ""))
interceptor.WithIdentityValidationClientInterceptor(r.volumeName, ""))
if err != nil {
return errors.Wrapf(err, "cannot connect to ReplicaService %v", r.replicaServiceURL)
}
defer conn.Close()
replicaServiceClient := ptypes.NewReplicaServiceClient(conn)
replicaServiceClient := enginerpc.NewReplicaServiceClient(conn)

ctx, cancel := context.WithTimeout(context.Background(), replicaClient.GRPCServiceCommonTimeout)
defer cancel()

if _, err := replicaServiceClient.ReplicaExpand(ctx, &ptypes.ReplicaExpandRequest{
if _, err := replicaServiceClient.ReplicaExpand(ctx, &enginerpc.ReplicaExpandRequest{
Size: size,
}); err != nil {
return types.UnmarshalGRPCError(err)
Expand All @@ -141,17 +142,17 @@ func (r *Remote) SetRevisionCounter(counter int64) error {
logrus.Infof("Set revision counter of %s to : %v", r.name, counter)

conn, err := grpc.Dial(r.replicaServiceURL, grpc.WithTransportCredentials(insecure.NewCredentials()),
ptypes.WithIdentityValidationClientInterceptor(r.volumeName, ""))
interceptor.WithIdentityValidationClientInterceptor(r.volumeName, ""))
if err != nil {
return errors.Wrapf(err, "cannot connect to ReplicaService %v", r.replicaServiceURL)
}
defer conn.Close()
replicaServiceClient := ptypes.NewReplicaServiceClient(conn)
replicaServiceClient := enginerpc.NewReplicaServiceClient(conn)

ctx, cancel := context.WithTimeout(context.Background(), replicaClient.GRPCServiceCommonTimeout)
defer cancel()

if _, err := replicaServiceClient.RevisionCounterSet(ctx, &ptypes.RevisionCounterSetRequest{
if _, err := replicaServiceClient.RevisionCounterSet(ctx, &enginerpc.RevisionCounterSetRequest{
Counter: counter,
}); err != nil {
return errors.Wrapf(err, "failed to set revision counter to %d for replica %v from remote", counter, r.replicaServiceURL)
Expand Down Expand Up @@ -257,17 +258,17 @@ func (r *Remote) SetUnmapMarkSnapChainRemoved(enabled bool) error {
logrus.Infof("Setting UnmapMarkSnapChainRemoved of %s to : %v", r.name, enabled)

conn, err := grpc.Dial(r.replicaServiceURL, grpc.WithTransportCredentials(insecure.NewCredentials()),
ptypes.WithIdentityValidationClientInterceptor(r.volumeName, ""))
interceptor.WithIdentityValidationClientInterceptor(r.volumeName, ""))
if err != nil {
return errors.Wrapf(err, "failed connecting to ReplicaService %v", r.replicaServiceURL)
}
defer conn.Close()
replicaServiceClient := ptypes.NewReplicaServiceClient(conn)
replicaServiceClient := enginerpc.NewReplicaServiceClient(conn)

ctx, cancel := context.WithTimeout(context.Background(), replicaClient.GRPCServiceCommonTimeout)
defer cancel()

if _, err := replicaServiceClient.UnmapMarkDiskChainRemovedSet(ctx, &ptypes.UnmapMarkDiskChainRemovedSetRequest{
if _, err := replicaServiceClient.UnmapMarkDiskChainRemovedSet(ctx, &enginerpc.UnmapMarkDiskChainRemovedSetRequest{
Enabled: enabled,
}); err != nil {
return errors.Wrapf(err, "failed to set UnmapMarkDiskChainRemoved to %v for replica %v from remote", enabled, r.replicaServiceURL)
Expand All @@ -289,18 +290,18 @@ func (r *Remote) ResetRebuild() error {
logrus.Warnf("Resetting %v rebuild", r.name)

conn, err := grpc.Dial(r.replicaServiceURL, grpc.WithTransportCredentials(insecure.NewCredentials()),
ptypes.WithIdentityValidationClientInterceptor(r.volumeName, ""))
interceptor.WithIdentityValidationClientInterceptor(r.volumeName, ""))
if err != nil {
return errors.Wrapf(err, "failed connecting to ReplicaService %v", r.replicaServiceURL)
}
defer conn.Close()

replicaServiceClient := ptypes.NewReplicaServiceClient(conn)
replicaServiceClient := enginerpc.NewReplicaServiceClient(conn)

ctx, cancel := context.WithTimeout(context.Background(), replicaClient.GRPCServiceCommonTimeout)
defer cancel()

_, err = replicaServiceClient.RebuildingSet(ctx, &ptypes.RebuildingSetRequest{
_, err = replicaServiceClient.RebuildingSet(ctx, &enginerpc.RebuildingSetRequest{
Rebuilding: false,
})
if err != nil {
Expand All @@ -315,17 +316,17 @@ func (r *Remote) SetSnapshotMaxCount(count int) error {

conn, err := grpc.Dial(r.replicaServiceURL,
grpc.WithTransportCredentials(insecure.NewCredentials()),
ptypes.WithIdentityValidationClientInterceptor(r.volumeName, ""))
interceptor.WithIdentityValidationClientInterceptor(r.volumeName, ""))
if err != nil {
return errors.Wrapf(err, "cannot connect to ReplicaService %s", r.replicaServiceURL)
}
defer conn.Close()
replicaServiceClient := ptypes.NewReplicaServiceClient(conn)
replicaServiceClient := enginerpc.NewReplicaServiceClient(conn)

ctx, cancel := context.WithTimeout(context.Background(), replicaClient.GRPCServiceCommonTimeout)
defer cancel()

if _, err := replicaServiceClient.SnapshotMaxCountSet(ctx, &ptypes.SnapshotMaxCountSetRequest{
if _, err := replicaServiceClient.SnapshotMaxCountSet(ctx, &enginerpc.SnapshotMaxCountSetRequest{
Count: int32(count),
}); err != nil {
return errors.Wrapf(err, "failed to set SnapshotMaxCount to %d for replica %s from remote", count, r.replicaServiceURL)
Expand All @@ -339,17 +340,17 @@ func (r *Remote) SetSnapshotMaxSize(size int64) error {

conn, err := grpc.Dial(r.replicaServiceURL,
grpc.WithTransportCredentials(insecure.NewCredentials()),
ptypes.WithIdentityValidationClientInterceptor(r.volumeName, ""))
interceptor.WithIdentityValidationClientInterceptor(r.volumeName, ""))
if err != nil {
return errors.Wrapf(err, "cannot connect to ReplicaService %s", r.replicaServiceURL)
}
defer conn.Close()
replicaServiceClient := ptypes.NewReplicaServiceClient(conn)
replicaServiceClient := enginerpc.NewReplicaServiceClient(conn)

ctx, cancel := context.WithTimeout(context.Background(), replicaClient.GRPCServiceCommonTimeout)
defer cancel()

if _, err := replicaServiceClient.SnapshotMaxSizeSet(ctx, &ptypes.SnapshotMaxSizeSetRequest{
if _, err := replicaServiceClient.SnapshotMaxSizeSet(ctx, &enginerpc.SnapshotMaxSizeSetRequest{
Size: size,
}); err != nil {
return errors.Wrapf(err, "failed to set SnapshotMaxSize to %d for replica %s from remote", size, r.replicaServiceURL)
Expand All @@ -360,12 +361,12 @@ func (r *Remote) SetSnapshotMaxSize(size int64) error {

func (r *Remote) info() (*types.ReplicaInfo, error) {
conn, err := grpc.Dial(r.replicaServiceURL, grpc.WithTransportCredentials(insecure.NewCredentials()),
ptypes.WithIdentityValidationClientInterceptor(r.volumeName, ""))
interceptor.WithIdentityValidationClientInterceptor(r.volumeName, ""))
if err != nil {
return nil, errors.Wrapf(err, "cannot connect to ReplicaService %v", r.replicaServiceURL)
}
defer conn.Close()
replicaServiceClient := ptypes.NewReplicaServiceClient(conn)
replicaServiceClient := enginerpc.NewReplicaServiceClient(conn)

ctx, cancel := context.WithTimeout(context.Background(), replicaClient.GRPCServiceCommonTimeout)
defer cancel()
Expand Down
Loading

0 comments on commit 081ccbc

Please sign in to comment.