-
Notifications
You must be signed in to change notification settings - Fork 62
[WIP] Remove linode api token requirement from node-server #414
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
Changes from all commits
0658c2d
46cf418
83c8f8a
8844f31
33ceca0
e97a77f
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 |
---|---|---|
|
@@ -8,6 +8,7 @@ WORKDIR /linode | |
|
||
RUN apk add \ | ||
blkid \ | ||
lsblk \ | ||
cryptsetup \ | ||
cryptsetup-libs \ | ||
cryptsetup-dev \ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,10 @@ | |
*/ | ||
|
||
import ( | ||
"encoding/json" | ||
"errors" | ||
"fmt" | ||
"os/exec" | ||
"strconv" | ||
"sync" | ||
"time" | ||
|
@@ -50,6 +52,14 @@ | |
csi.UnimplementedNodeServer | ||
} | ||
|
||
type BlockDevice struct { | ||
Name string `json:"name"` | ||
} | ||
|
||
type LsblkOutput struct { | ||
BlockDevices []BlockDevice `json:"blockdevices"` | ||
} | ||
|
||
var _ csi.NodeServer = &NodeServer{} | ||
|
||
func NewNodeServer(ctx context.Context, linodeDriver *LinodeDriver, mounter *mountmanager.SafeFormatAndMount, deviceUtils devicemanager.DeviceUtils, client linodeclient.LinodeClient, metadata Metadata, encrypt Encryption, resize mountmanager.ResizeFSer) (*NodeServer, error) { | ||
|
@@ -469,8 +479,12 @@ | |
}, nil | ||
} | ||
|
||
func execRunner(name string, arg ...string) ([]byte, error) { | ||
return exec.Command(name, arg...).CombinedOutput() | ||
} | ||
|
||
Comment on lines
+482
to
+485
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. Could we use the interfaces defined for exec calls here: https://github.com/linode/linode-blockstorage-csi-driver/blob/d43f82da3e16f6294f1b1cf32eaa3d621c53d044/pkg/mount-manager/safe_mounter.go This would be helpful during mocking for unit testing Could you also move the structs and execRunner() to either helper file OR somewhere in the pkg directory? |
||
func (ns *NodeServer) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRequest) (*csi.NodeGetInfoResponse, error) { | ||
log, ctx := logger.GetLogger(ctx) | ||
Check failure on line 487 in internal/driver/nodeserver.go
|
||
log, done := logger.WithMethod(log, "NodeGetInfo") | ||
defer done() | ||
|
||
|
@@ -484,13 +498,18 @@ | |
// This is what the spec wants us to report: the actual number of volumes | ||
// that can be attached, and not the theoretical maximum number of | ||
// devices that can be attached. | ||
log.V(4).Info("Listing instance disks", "nodeID", ns.metadata.ID) | ||
disks, err := ns.client.ListInstanceDisks(ctx, ns.metadata.ID, nil) | ||
log.V(4).Info("Listing attached block devices", "nodeID", ns.metadata.ID) | ||
|
||
lsblkOutput, err := execRunner("lsblk", "-J", "--nodeps", "-e7") | ||
if err != nil { | ||
return &csi.NodeGetInfoResponse{}, errInternal("list instance disks: %v", err) | ||
return &csi.NodeGetInfoResponse{}, errInternal("lsblk: %v", err) | ||
} | ||
var lsblkData LsblkOutput | ||
if err := json.Unmarshal(lsblkOutput, &lsblkData); err != nil { | ||
return &csi.NodeGetInfoResponse{}, errInternal("error unmarshaling lsblk json output: %s", err) | ||
} | ||
maxVolumes := maxVolumeAttachments(ns.metadata.Memory) - len(disks) | ||
|
||
maxVolumes := maxVolumeAttachments(ns.metadata.Memory) - len(lsblkData.BlockDevices) | ||
log.V(2).Info("functionStatusfully completed") | ||
return &csi.NodeGetInfoResponse{ | ||
NodeId: strconv.Itoa(ns.metadata.ID), | ||
|
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.
What are your thoughts on using this library instead of exec command?
https://github.com/jaypipes/ghw?tab=readme-ov-file#block-storage