exoscale / egoscale

exoscale golang bindings
https://pkg.go.dev/github.com/exoscale/egoscale/v3
Apache License 2.0
31 stars 15 forks source link

V3 meta-data: private Instance fetch metadata from CD-ROM #634

Closed pierre-emmanuelJ closed 1 month ago

pierre-emmanuelJ commented 1 month ago

Description

This change is useful in the context of working with Exoscale private instance metadata (useful for CCM, CSI...etc).

In the CSI container are run as privileged by default to access device for block storage...etc., for CCM the manual prerequisite of the customer if he installs it on his private instance cluster is to change the container permission

Checklist

(For exoscale contributors)

Tested from private instance with a test program

ubuntu@test-private:~$ sudo ./test-meta
Response for availability-zone: ch-gva-2
Response for cloud-identifier: CloudStack-{2f8551a8-xxxx7ec69527fb}
Response for instance-id: fd1c0d3c-xxxxxb1d5dda
Response for local-hostname: test-private
Response for public-hostname: test-private
Response for service-offering: Medium 4096mb 2cpu
Response for vm-id: fd1c0d3c-xxxxxb1d5dda

if no sudo executed

ubuntu@test-private:~$ ./test-meta
2024/06/12 07:56:14 disk open: could not open device /dev/disk/by-label/cidata with mode 0: open /dev/disk/by-label/cidata: permission denied
....etc

if not, a private instance

ubuntu@bastion:~$ ./test-meta
2024/06/12 07:57:00 disk open: provided device /dev/disk/by-label/cidata does not exist
Response for availability-zone:
pierre-emmanuelJ commented 1 month ago

It feels weird to mount & unmount the disk each time you need to access some metadata. And since you're using a hardcoded target, two processes could mount it at the same time and cause some issues

Did you consider the possibility of reading straight from the disk instead of mounting it on the system? I didn't looked too much into it, but it looks like https://github.com/diskfs/go-diskfs might do the trick

@Fumesover

Here is in my new commit a better solution as you proposed, what do you think about?

I updated the description above according to the update