Skip to content

guestagent: Fix isEmptyEvent check #3697

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

Merged
merged 1 commit into from
Jul 7, 2025
Merged

Conversation

nirs
Copy link
Member

@nirs nirs commented Jul 6, 2025

The intention seems to be checking if an event is equal to empty event, ignoring the event time, by copying the event and setting its time to nil. However instead of copying the event, we use the same object and set the event time to nil.

I don't know if this caused a user visible problem, but it likely log wrong event time if we log the event.

We can see the time in ha.stderr.log:

Before:

{
  "level": "debug",
  "msg": "guest agent event: local_ports_added:{protocol:\"tcp\"  ip:\"127.0.0.54\"  port:53}  local_ports_added:{protocol:\"tcp\"  ip:\"127.0.0.53\"  port:53}  local_ports_added:{protocol:\"tcp\"  ip:\"0.0.0.0\"  port:22}  local_ports_added:{protocol:\"tcp\"  ip:\"0.0.0.0\"  port:5355}  local_ports_added:{protocol:\"tcp\"  ip:\"::\"  port:22}  local_ports_added:{protocol:\"tcp\"  ip:\"::\"  port:5355}  local_ports_added:{protocol:\"udp\"  ip:\"127.0.0.54\"  port:53}  local_ports_added:{protocol:\"udp\"  ip:\"127.0.0.53\"  port:53}  local_ports_added:{protocol:\"udp\"  ip:\"127.0.0.1\"  port:323}  local_ports_added:{protocol:\"udp\"  ip:\"0.0.0.0\"  port:5355}  local_ports_added:{protocol:\"udp\"  ip:\"::1\"  port:323}  local_ports_added:{protocol:\"udp\"  ip:\"::\"  port:5355}",
  "time": "2025-07-06T15:16:53+03:00"
}

After:

{
  "level": "debug",
  "msg": "guest agent event: time:{seconds:1751804380  nanos:651834360}  local_ports_added:{protocol:\"tcp\"  ip:\"0.0.0.0\"  port:5355}  local_ports_added:{protocol:\"tcp\"  ip:\"127.0.0.53\"  port:53}  local_ports_added:{protocol:\"tcp\"  ip:\"127.0.0.54\"  port:53}  local_ports_added:{protocol:\"tcp\"  ip:\"0.0.0.0\"  port:22}  local_ports_added:{protocol:\"tcp\"  ip:\"::\"  port:5355}  local_ports_added:{protocol:\"tcp\"  ip:\"::\"  port:22}  local_ports_added:{protocol:\"udp\"  ip:\"127.0.0.54\"  port:53}  local_ports_added:{protocol:\"udp\"  ip:\"127.0.0.53\"  port:53}  local_ports_added:{protocol:\"udp\"  ip:\"127.0.0.1\"  port:323}  local_ports_added:{protocol:\"udp\"  ip:\"0.0.0.0\"  port:5355}  local_ports_added:{protocol:\"udp\"  ip:\"::1\"  port:323}  local_ports_added:{protocol:\"udp\"  ip:\"::\"  port:5355}",
  "time": "2025-07-06T15:19:40+03:00"
}

The intention seems to be checking if an event is equal to empty event,
ignoring the event time, by copying the event and setting its time to
nil. However instead of copying the event, we use the same object and
set the event time to nil.

I don't know if this caused a user visible problem, but it likely log
wrong event time if we log the event.

Signed-off-by: Nir Soffer <[email protected]>
@AkihiroSuda AkihiroSuda added this to the v1.2.0 milestone Jul 7, 2025
@@ -191,9 +191,8 @@ func (a *agent) collectEvent(ctx context.Context, st eventState) (*api.Event, ev

func isEventEmpty(ev *api.Event) bool {
empty := &api.Event{}
copied := ev
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@AkihiroSuda AkihiroSuda merged commit 910e286 into lima-vm:master Jul 7, 2025
36 checks passed
@nirs nirs deleted the guestagent-fix branch July 7, 2025 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants