-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove csi-common dependencies #14
Changes from 1 commit
6b90615
aeacde0
4b11870
281800d
8d49678
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
Copyright 2019 The Kubernetes Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package iscsi | ||
|
||
import ( | ||
"github.com/container-storage-interface/spec/lib/go/csi" | ||
"github.com/golang/glog" | ||
"golang.org/x/net/context" | ||
"google.golang.org/grpc/codes" | ||
"google.golang.org/grpc/status" | ||
) | ||
|
||
type ControllerServer struct { | ||
Driver *driver | ||
} | ||
|
||
func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error) { | ||
return nil, status.Error(codes.Unimplemented, "") | ||
} | ||
|
||
func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest) (*csi.DeleteVolumeResponse, error) { | ||
return nil, status.Error(codes.Unimplemented, "") | ||
} | ||
|
||
func (cs *ControllerServer) ControllerPublishVolume(ctx context.Context, req *csi.ControllerPublishVolumeRequest) (*csi.ControllerPublishVolumeResponse, error) { | ||
return nil, status.Error(codes.Unimplemented, "") | ||
} | ||
|
||
func (cs *ControllerServer) ControllerUnpublishVolume(ctx context.Context, req *csi.ControllerUnpublishVolumeRequest) (*csi.ControllerUnpublishVolumeResponse, error) { | ||
return nil, status.Error(codes.Unimplemented, "") | ||
} | ||
|
||
func (cs *ControllerServer) ValidateVolumeCapabilities(ctx context.Context, req *csi.ValidateVolumeCapabilitiesRequest) (*csi.ValidateVolumeCapabilitiesResponse, error) { | ||
return nil, status.Error(codes.Unimplemented, "") | ||
} | ||
|
||
func (cs *ControllerServer) ListVolumes(ctx context.Context, req *csi.ListVolumesRequest) (*csi.ListVolumesResponse, error) { | ||
return nil, status.Error(codes.Unimplemented, "") | ||
} | ||
|
||
func (cs *ControllerServer) GetCapacity(ctx context.Context, req *csi.GetCapacityRequest) (*csi.GetCapacityResponse, error) { | ||
return nil, status.Error(codes.Unimplemented, "") | ||
} | ||
|
||
// ControllerGetCapabilities implements the default GRPC callout. | ||
// Default supports all capabilities | ||
func (cs *ControllerServer) ControllerGetCapabilities(ctx context.Context, req *csi.ControllerGetCapabilitiesRequest) (*csi.ControllerGetCapabilitiesResponse, error) { | ||
glog.V(5).Infof("Using default ControllerGetCapabilities") | ||
|
||
return &csi.ControllerGetCapabilitiesResponse{ | ||
Capabilities: cs.Driver.cscap, | ||
}, nil | ||
} | ||
|
||
func (cs *ControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequest) (*csi.CreateSnapshotResponse, error) { | ||
return nil, status.Error(codes.Unimplemented, "") | ||
} | ||
|
||
func (cs *ControllerServer) DeleteSnapshot(ctx context.Context, req *csi.DeleteSnapshotRequest) (*csi.DeleteSnapshotResponse, error) { | ||
return nil, status.Error(codes.Unimplemented, "") | ||
} | ||
|
||
func (cs *ControllerServer) ListSnapshots(ctx context.Context, req *csi.ListSnapshotsRequest) (*csi.ListSnapshotsResponse, error) { | ||
return nil, status.Error(codes.Unimplemented, "") | ||
} | ||
|
||
func (cs *ControllerServer) ControllerExpandVolume(ctx context.Context, req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) { | ||
return nil, status.Error(codes.Unimplemented, "") | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package iscsi | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. replace "indentifyserver.go" with "identityserver.go" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
|
||
import ( | ||
"github.com/container-storage-interface/spec/lib/go/csi" | ||
"github.com/golang/glog" | ||
"golang.org/x/net/context" | ||
"google.golang.org/grpc/codes" | ||
"google.golang.org/grpc/status" | ||
) | ||
|
||
type IdentityServer struct { | ||
Driver *driver | ||
} | ||
|
||
func (ids *IdentityServer) GetPluginInfo(ctx context.Context, req *csi.GetPluginInfoRequest) (*csi.GetPluginInfoResponse, error) { | ||
glog.V(5).Infof("Using default GetPluginInfo") | ||
|
||
if ids.Driver.name == "" { | ||
return nil, status.Error(codes.Unavailable, "Driver name not configured") | ||
} | ||
|
||
if ids.Driver.version == "" { | ||
return nil, status.Error(codes.Unavailable, "Driver is missing version") | ||
} | ||
|
||
return &csi.GetPluginInfoResponse{ | ||
Name: ids.Driver.name, | ||
VendorVersion: ids.Driver.version, | ||
}, nil | ||
} | ||
|
||
func (ids *IdentityServer) Probe(ctx context.Context, req *csi.ProbeRequest) (*csi.ProbeResponse, error) { | ||
return &csi.ProbeResponse{}, nil | ||
} | ||
|
||
func (ids *IdentityServer) GetPluginCapabilities(ctx context.Context, req *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error) { | ||
glog.V(5).Infof("Using default capabilities") | ||
return &csi.GetPluginCapabilitiesResponse{ | ||
Capabilities: []*csi.PluginCapability{ | ||
{ | ||
Type: &csi.PluginCapability_Service_{ | ||
Service: &csi.PluginCapability_Service{ | ||
Type: csi.PluginCapability_Service_CONTROLLER_SERVICE, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, nil | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,15 +18,14 @@ package iscsi | |
|
||
import ( | ||
"github.com/container-storage-interface/spec/lib/go/csi" | ||
"github.com/golang/glog" | ||
"golang.org/x/net/context" | ||
"google.golang.org/grpc/codes" | ||
"google.golang.org/grpc/status" | ||
|
||
"github.com/kubernetes-csi/drivers/pkg/csi-common" | ||
) | ||
|
||
type nodeServer struct { | ||
*csicommon.DefaultNodeServer | ||
Driver *driver | ||
} | ||
|
||
func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) { | ||
|
@@ -65,3 +64,35 @@ func (ns *nodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstag | |
func (ns *nodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRequest) (*csi.NodeStageVolumeResponse, error) { | ||
return &csi.NodeStageVolumeResponse{}, nil | ||
} | ||
|
||
func (ns *nodeServer) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRequest) (*csi.NodeGetInfoResponse, error) { | ||
glog.V(5).Infof("Using default NodeGetInfo") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we don't need these default logs anymore? Since its not coming from csi-common? I also copied over the same thing for the NFS driver, so I would need to change that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I think that gets handled in the default impl anyway There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. Also, did the same to NodeGetCapabilities. |
||
|
||
return &csi.NodeGetInfoResponse{ | ||
NodeId: ns.Driver.nodeID, | ||
}, nil | ||
} | ||
|
||
func (ns *nodeServer) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error) { | ||
glog.V(5).Infof("Using default NodeGetCapabilities") | ||
|
||
return &csi.NodeGetCapabilitiesResponse{ | ||
Capabilities: []*csi.NodeServiceCapability{ | ||
{ | ||
Type: &csi.NodeServiceCapability_Rpc{ | ||
Rpc: &csi.NodeServiceCapability_RPC{ | ||
Type: csi.NodeServiceCapability_RPC_UNKNOWN, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, nil | ||
} | ||
|
||
func (ns *nodeServer) NodeGetVolumeStats(ctx context.Context, in *csi.NodeGetVolumeStatsRequest) (*csi.NodeGetVolumeStatsResponse, error) { | ||
return nil, status.Error(codes.Unimplemented, "") | ||
} | ||
|
||
func (ns *nodeServer) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandVolumeRequest) (*csi.NodeExpandVolumeResponse, error) { | ||
return nil, status.Error(codes.Unimplemented, "") | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package iscsi | ||
|
||
import ( | ||
"net" | ||
"os" | ||
"sync" | ||
|
||
"github.com/golang/glog" | ||
"google.golang.org/grpc" | ||
|
||
"github.com/container-storage-interface/spec/lib/go/csi" | ||
) | ||
|
||
// Defines Non blocking GRPC server interfaces | ||
type NonBlockingGRPCServer interface { | ||
// Start services at the endpoint | ||
Start(endpoint string, ids csi.IdentityServer, cs csi.ControllerServer, ns csi.NodeServer) | ||
// Waits for the service to stop | ||
Wait() | ||
// Stops the service gracefully | ||
Stop() | ||
// Stops the service forcefully | ||
ForceStop() | ||
} | ||
|
||
func NewNonBlockingGRPCServer() NonBlockingGRPCServer { | ||
return &nonBlockingGRPCServer{} | ||
} | ||
|
||
// NonBlocking server | ||
type nonBlockingGRPCServer struct { | ||
wg sync.WaitGroup | ||
server *grpc.Server | ||
} | ||
|
||
func (s *nonBlockingGRPCServer) Start(endpoint string, ids csi.IdentityServer, cs csi.ControllerServer, ns csi.NodeServer) { | ||
|
||
s.wg.Add(1) | ||
|
||
go s.serve(endpoint, ids, cs, ns) | ||
|
||
return | ||
} | ||
|
||
func (s *nonBlockingGRPCServer) Wait() { | ||
s.wg.Wait() | ||
} | ||
|
||
func (s *nonBlockingGRPCServer) Stop() { | ||
s.server.GracefulStop() | ||
} | ||
|
||
func (s *nonBlockingGRPCServer) ForceStop() { | ||
s.server.Stop() | ||
} | ||
|
||
func (s *nonBlockingGRPCServer) serve(endpoint string, ids csi.IdentityServer, cs csi.ControllerServer, ns csi.NodeServer) { | ||
|
||
proto, addr, err := ParseEndpoint(endpoint) | ||
if err != nil { | ||
glog.Fatal(err.Error()) | ||
} | ||
|
||
if proto == "unix" { | ||
addr = "/" + addr | ||
if err := os.Remove(addr); err != nil && !os.IsNotExist(err) { | ||
glog.Fatalf("Failed to remove %s, error: %s", addr, err.Error()) | ||
} | ||
} | ||
|
||
listener, err := net.Listen(proto, addr) | ||
if err != nil { | ||
glog.Fatalf("Failed to listen: %v", err) | ||
} | ||
|
||
opts := []grpc.ServerOption{ | ||
grpc.UnaryInterceptor(logGRPC), | ||
} | ||
server := grpc.NewServer(opts...) | ||
s.server = server | ||
|
||
if ids != nil { | ||
csi.RegisterIdentityServer(server, ids) | ||
} | ||
if cs != nil { | ||
csi.RegisterControllerServer(server, cs) | ||
} | ||
if ns != nil { | ||
csi.RegisterNodeServer(server, ns) | ||
} | ||
|
||
glog.Infof("Listening for connections on address: %#v", listener.Addr()) | ||
|
||
server.Serve(listener) | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this just be deleted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleted.