Skip to content

Commit

Permalink
Merge pull request #84 from humblec/rel
Browse files Browse the repository at this point in the history
iscsi: correct error message format
  • Loading branch information
k8s-ci-robot authored Jan 6, 2022
2 parents 833e5b8 + 17d45fb commit 79a34dc
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 19 deletions.
6 changes: 3 additions & 3 deletions pkg/iscsi/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const (
var version = "0.1.0"

func NewDriver(nodeID, endpoint string) *driver {
klog.Infof("Driver: %v version: %v", driverName, version)
klog.Infof("driver: %v version: %v", driverName, version)

d := &driver{
name: driverName,
Expand Down Expand Up @@ -82,7 +82,7 @@ func (d *driver) Run() {
func (d *driver) AddVolumeCapabilityAccessModes(vc []csi.VolumeCapability_AccessMode_Mode) []*csi.VolumeCapability_AccessMode {
var vca []*csi.VolumeCapability_AccessMode
for _, c := range vc {
klog.Infof("Enabling volume access mode: %v", c.String())
klog.Infof("enabling volume access mode: %v", c.String())
vca = append(vca, &csi.VolumeCapability_AccessMode{Mode: c})
}
d.cap = vca
Expand All @@ -93,7 +93,7 @@ func (d *driver) AddControllerServiceCapabilities(cl []csi.ControllerServiceCapa
var csc []*csi.ControllerServiceCapability

for _, c := range cl {
klog.Infof("Enabling controller service capability: %v", c.String())
klog.Infof("enabling controller service capability: %v", c.String())
csc = append(csc, NewControllerServiceCapability(c))
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/iscsi/identityserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type IdentityServer struct {
}

func (ids *IdentityServer) GetPluginInfo(ctx context.Context, req *csi.GetPluginInfoRequest) (*csi.GetPluginInfoResponse, error) {
klog.V(5).Infof("Using default GetPluginInfo")
klog.V(5).Infof("using default GetPluginInfo")

if ids.Driver.name == "" {
return nil, status.Error(codes.Unavailable, "Driver name not configured")
Expand All @@ -50,7 +50,7 @@ func (ids *IdentityServer) Probe(ctx context.Context, req *csi.ProbeRequest) (*c
}

func (ids *IdentityServer) GetPluginCapabilities(ctx context.Context, req *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error) {
klog.V(5).Infof("Using default capabilities")
klog.V(5).Infof("using default capabilities")

return &csi.GetPluginCapabilitiesResponse{
Capabilities: []*csi.PluginCapability{
Expand Down
2 changes: 1 addition & 1 deletion pkg/iscsi/iscsi.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func getISCSIInfo(req *csi.NodePublishVolumeRequest) (*iscsiDisk, error) {
iqn := req.GetVolumeContext()["iqn"]
lun := req.GetVolumeContext()["lun"]
if tp == "" || iqn == "" || lun == "" {
return nil, fmt.Errorf("iSCSI target information is missing")
return nil, fmt.Errorf("ISCSI target information is missing")
}

portalList := req.GetVolumeContext()["portals"]
Expand Down
5 changes: 2 additions & 3 deletions pkg/iscsi/iscsi_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ func (util *ISCSIUtil) AttachDisk(b iscsiDiskMounter) (string, error) {
iscsiInfoPath := getIscsiInfoPath(b.VolName)
err = iscsiLib.PersistConnector(b.connector, iscsiInfoPath)
if err != nil {
klog.Errorf("failed to persist connection info: %v", err)
klog.Errorf("disconnecting volume and failing the publish request because persistence files are required for reliable Unpublish")
klog.Errorf("failed to persist connection info: %v, disconnecting volume and failing the publish request because persistence files are required for reliable Unpublish", err)
return "", fmt.Errorf("unable to create persistence file for connection")
}

Expand Down Expand Up @@ -89,7 +88,7 @@ func (util *ISCSIUtil) DetachDisk(c iscsiDiskUnmounter, targetPath string) error
if pathExists, pathErr := mount.PathExists(targetPath); pathErr != nil {
return fmt.Errorf("error checking if path exists: %v", pathErr)
} else if !pathExists {
klog.Warningf("Warning: Unmount skipped because path does not exist: %v", targetPath)
klog.Warningf("warning: Unmount skipped because path does not exist: %v", targetPath)
return nil
}
iscsiInfoPath := getIscsiInfoPath(c.VolName)
Expand Down
6 changes: 3 additions & 3 deletions pkg/iscsi/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ type nodeServer struct {

func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) {
if req.GetVolumeCapability() == nil {
return nil, status.Error(codes.InvalidArgument, "Volume capability missing in request")
return nil, status.Error(codes.InvalidArgument, "volume capability missing in request")
}
if len(req.GetVolumeId()) == 0 {
return nil, status.Error(codes.InvalidArgument, "Volume ID missing in request")
return nil, status.Error(codes.InvalidArgument, "volumeID missing in request")
}
if len(req.GetTargetPath()) == 0 {
return nil, status.Error(codes.InvalidArgument, "Target path not provided")
return nil, status.Error(codes.InvalidArgument, "targetPath not provided")
}

iscsiInfo, err := getISCSIInfo(req)
Expand Down
11 changes: 4 additions & 7 deletions pkg/iscsi/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ type nonBlockingGRPCServer struct {
}

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)
Expand All @@ -71,7 +70,6 @@ func (s *nonBlockingGRPCServer) ForceStop() {
}

func (s *nonBlockingGRPCServer) serve(endpoint string, ids csi.IdentityServer, cs csi.ControllerServer, ns csi.NodeServer) {

proto, addr, err := ParseEndpoint(endpoint)
if err != nil {
klog.Fatal(err.Error())
Expand All @@ -80,13 +78,13 @@ func (s *nonBlockingGRPCServer) serve(endpoint string, ids csi.IdentityServer, c
if proto == "unix" {
addr = "/" + addr
if err := os.Remove(addr); err != nil && !os.IsNotExist(err) {
klog.Fatalf("Failed to remove %s, error: %s", addr, err.Error())
klog.Fatalf("failed to remove %s, error: %s", addr, err.Error())
}
}

listener, err := net.Listen(proto, addr)
if err != nil {
klog.Fatalf("Failed to listen: %v", err)
klog.Fatalf("failed to listen: %v", err)
}

opts := []grpc.ServerOption{
Expand All @@ -104,10 +102,9 @@ func (s *nonBlockingGRPCServer) serve(endpoint string, ids csi.IdentityServer, c
if ns != nil {
csi.RegisterNodeServer(server, ns)
}
klog.Infof("Listening for connections on address: %#v", listener.Addr())
klog.Infof("listening for connections on address: %#v", listener.Addr())
err = server.Serve(listener)
if err != nil {
klog.Fatalf("Failed to serve requests: %v", err)
klog.Fatalf("failed to serve requests: %v", err)
}

}

0 comments on commit 79a34dc

Please sign in to comment.