-
Notifications
You must be signed in to change notification settings - Fork 682
Add support for collecting instance IP address #3696
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
base: master
Are you sure you want to change the base?
Conversation
ce812d0
to
7e5a9ee
Compare
pkg/guestagent/guestagent_linux.go
Outdated
@@ -186,6 +188,24 @@ func (a *agent) collectEvent(ctx context.Context, st eventState) (*api.Event, ev | |||
} | |||
ev.LocalPortsAdded, ev.LocalPortsRemoved = comparePorts(st.ports, newSt.ports) | |||
ev.Time = timestamppb.Now() | |||
|
|||
// Get network interfaces info | |||
cmd := exec.Command("ip", "-j", "a") |
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.
Does this really work with busybox?
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.
It works with the Alpine cloud image from template://alpine
. It does not work with alpine-lima from template://alpine-iso
, but can easily be made to work by adding the iproute2
package to the image.
PS: I assume this question was about Alpine, and not busybox
because the ip -j a
would be executed in the guest and not in a container.
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.
I just used a shell script for apple container, since it "forgot" to update the /etc/hosts file.
echo "127.0.0.1 localhost" >/etc/hosts
echo "$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) $(hostname)" >>/etc/hosts
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.
I thought that Alpine used ip
from busybox by default, but maybe that is what you are saying above
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.
A minimal Alpine uses just busybox
, but you can apk add iproute2
to install the real one. Our alpine-lima
ISO image is the only one that is using busybox ip
by default.
Added unconditionally to all editions because in the future Lima will depend on it (it is also part of the default Alpine cloud image). Ref lima-vm/lima#3696 Signed-off-by: Jan Dubois <[email protected]>
7e5a9ee
to
eb07981
Compare
Changes – Draft 2 (edited)gRPC
Hostagent
CLI
Note;
P.S. I'm trying my best to follow the design patterns found in the existing code. If there are any points that need refactoring, please let me know. |
df9c498
to
3ba87dc
Compare
Signed-off-by: Songpon Srisawai <[email protected]>
3ba87dc
to
438de9f
Compare
What does this PR do?
instance_info.json
file.Implementation details
With GuestAgent:
ip -j a
is embedded asjson_bytes
in the gRPC Events message.instance_info.json
file.Without GuestAgent (Plain mode):
executeSSH()
function signature to return both the command output and error (instead of just error).executeSSH()
to runip -j a
, processes the output, and writes the instance info locally.Testing
limactl start INSTNAME --network lima:user-v2