Skip to content
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

virt-handler, Add infoSource field to vmi status #6793

Merged
merged 2 commits into from
Jan 5, 2022

Conversation

oshoval
Copy link
Contributor

@oshoval oshoval commented Nov 14, 2021

What this PR does / why we need it:

In case of MAC change in the guest,
the vmi status will present two interfaces,
one based on the domain spec, and one based on the
guest agent (if it exists).

The reason is that the MAC address is used in order
to match the interface of the domain spec with the
interfaces reported by the guest agent.
Once the MAC is changed, this matching can't be performed.

In order to make the info easier to understand,
add a new field to each interface in vmi.status.
infoSource field has 3 possible values:

  1. domain - info is based on the domain spec
  2. guest-agent - info is based on guest agent report
  3. domain, guest-agent - info is based on both domain spec
    and guest agent report.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=2013455

Special notes for your reviewer:
User Guide PR: kubevirt/user-guide#504

Release note:

Add infoSource field to vmi.status.interfaces.
The field specifies the origin of the interface data collected. values: domain, guest-agent, or both.

@kubevirt-bot kubevirt-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. labels Nov 14, 2021
@oshoval
Copy link
Contributor Author

oshoval commented Nov 14, 2021

/uncc @jean-edouard @yuhaohaoyu

@oshoval
Copy link
Contributor Author

oshoval commented Nov 15, 2021

/test pull-kubevirt-check-unassigned-tests

@oshoval
Copy link
Contributor Author

oshoval commented Nov 15, 2021

/test pull-kubevirt-unit-test

@oshoval oshoval marked this pull request as draft November 15, 2021 12:46
@oshoval oshoval marked this pull request as ready for review November 15, 2021 16:11
@oshoval oshoval changed the title WIP vmi scheme, Add infoSource field to vmi status virt-handler, Add infoSource field to vmi status Nov 16, 2021
@kubevirt-bot kubevirt-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 16, 2021
@oshoval
Copy link
Contributor Author

oshoval commented Nov 16, 2021

/cc @EdDev

@maiqueb
Copy link
Contributor

maiqueb commented Nov 16, 2021

In case of MAC change in the guest,
the vmi status will present two interfaces,
one based on the domain spec, and one based on the
guest agent (if it exists).

Could you paste some examples of what the status representation will look like, so its easier to visualize ? As is, I am unsure I understand what you're proposing.

@oshoval
Copy link
Contributor Author

oshoval commented Nov 16, 2021

Could you paste some examples of what the status representation will look like, so its easier to visualize ? As is, I am unsure I understand what you're proposing.

An interface where the domain and guest-agent both know to interface (usually the case)

  - infoSource: domain, guest-agent # new field of this PR
    interfaceName: eth1
    ipAddress: 10.200.0.1
    ipAddresses:
    - 10.200.0.1
    - fe80::1e:d6ff:fe00:6b
    mac: 02:1e:d6:00:00:6b
    name: br10-vlan100-network

Now if you change the mac of the interface in the guest itself, the situation will be (before this PR)

  - mac: 02:1e:d6:00:00:6b
    name: br10-vlan100-network
  - interfaceName: eth1
    ipAddress: 10.200.0.1
    ipAddresses:
    - 10.200.0.1
    - fe80::1e:d6ff:fe00:6b
    mac: 02:00:b5:b5:b5:c9

This PR suggest to add the infoSource field as follows

  - infoSource: domain
    mac: 02:1e:d6:00:00:6b
    name: br10-vlan100-network
  - infoSource: guest-agent
    interfaceName: eth1
    ipAddress: 10.200.0.1
    ipAddresses:
    - 10.200.0.1
    - fe80::1e:d6ff:fe00:6b
    mac: 02:00:b5:b5:b5:c9

You can see here the 3 possible values of the new field.

@maiqueb
Copy link
Contributor

maiqueb commented Nov 16, 2021

  - infoSource: domain
    mac: 02:1e:d6:00:00:6b
    name: br10-vlan100-network
  - infoSource: guest-agent
    interfaceName: eth1
    ipAddress: 10.200.0.1
    ipAddresses:
    - 10.200.0.1
    - fe80::1e:d6ff:fe00:6b
    mac: 02:00:b5:b5:b5:c9

But do the above 2 entries refer to the same entity ? From your PR's description, I think so.

How can I - or anything that reads the interface status - infer that @oshoval ?

AFAIU, there isn't any attribute there to map them together. Probably if you add a more complete example I'll understand.

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Dec 28, 2021
@@ -249,11 +250,13 @@ func MergeAgentStatusesWithDomainData(domInterfaces []api.Interface, interfaceSt
}

aliasesCoveredByAgent := []string{}
// Add alias from domain to interfaceStatus
Copy link
Member

Choose a reason for hiding this comment

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

why was this comment removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because now it adds also the InfoSource not just the alias,so it is outdated (and code is self explanatory about those 2)

@@ -158,14 +159,18 @@ func (c *NetStat) UpdateStatus(vmi *v1.VirtualMachineInstance, domain *api.Domai
// Remove the interface from domainInterfaceStatusByMac to mark it as handled
if interfaceStatus, exists := domainInterfaceStatusByMac[interfaceMAC]; exists {
newInterface.InterfaceName = interfaceStatus.InterfaceName
newInterface.InfoSource = interfaceStatus.InfoSource
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need the InfoSource information from interfaceStatus, isn't it obvious the InfoSource here is InfoSourceDomainAndGA?

Copy link
Contributor Author

@oshoval oshoval Dec 30, 2021

Choose a reason for hiding this comment

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

Since the merge has one of 3 values:

  1. domain InfoSourceDomain
  2. guest-agent (can't be in this specific line, because we know we are iterating the spec)
  3. domain and guest-agent (InfoSourceDomainAndGA)

then there are two options left 1 and 3, not just InfoSourceDomainAndGA (option 3)

@@ -180,6 +185,7 @@ func (c *NetStat) UpdateStatus(vmi *v1.VirtualMachineInstance, domain *api.Domai
IP: domainInterfaceStatus.Ip,
IPs: domainInterfaceStatus.IPs,
InterfaceName: domainInterfaceStatus.InterfaceName,
InfoSource: domainInterfaceStatus.InfoSource,
Copy link
Member

Choose a reason for hiding this comment

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

Same here, it is obvious the InfoSource is InfoSourceGuestAgent

Copy link
Contributor Author

@oshoval oshoval Dec 30, 2021

Choose a reason for hiding this comment

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

Right, but delegated it to the one that calculate it atm (the merger), here we just copied the result (we can do it explicit if needed)

for i, interfaceStatus := range interfaceStatuses {
if alias, exists := aliasByMac[interfaceStatus.Mac]; exists {
interfaceStatuses[i].Name = alias
interfaceStatuses[i].InfoSource = netvmispec.InfoSourceDomainAndGA
Copy link
Member

Choose a reason for hiding this comment

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

I believe the InfoSource information here is redundant, please refer to the comments of netstat.go.

Copy link
Contributor Author

@oshoval oshoval Dec 30, 2021

Choose a reason for hiding this comment

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

In order to move the whole logic to netstat.go
We need first this fix #6926
(which isn't enough by it's own, see example below)

I tried to start with it, and saw that it uncover the leakage in case the mac is changed
#6744 (last comment shows it)

As discussed also previously in this PR, there are couple place that are doing merges,
we can do an effort in the future to refactor them, meanwhile i prefer to keep the current logic please if possible, as it is more self contained in the current state of the code.

This change would be bit delicate, wider, and with some gotchas so I think it deserves a separate PR.
For example I tried to take #6926 + #6744 + this PR and check what happens:
We would still have the zombie ips as last comment of 6744 shows
We can see here that the ips are added because they appear in the pod, the merge code "protects"
and we would need to protect in a different method if we remove it (remove the code of 6744):

  interfaces:
  - infoSource: domain
    ipAddress: 10.244.140.77
    ipAddresses:
    - 10.244.140.77
    - fd10:244::8c4c
    mac: "02:00:05:05:05:05"
    name: default

  - infoSource: guest-agent
    interfaceName: eth0
    ipAddress: 10.244.140.77
    ipAddresses:
    - 10.244.140.77
    - fe80::5ff:fe05:505
    mac: 02:00:b5:b5:b5:b5

Another reason is that Edy is already working on improving the updateStatus, and it's test coverage,
I think it will be safer and easier to refactor the virt-launcher merger and updateStatus once we have his PRs merged.

// Do not update if interface has Masquerede binding
// virt-controller should update VMI status interface with Pod IP instead
if !isForwardingBindingInterface {
newInterface.IP = interfaceStatus.Ip
newInterface.IPs = interfaceStatus.IPs
}
delete(domainInterfaceStatusByMac, interfaceMAC)
} else {
Copy link
Member

Choose a reason for hiding this comment

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

IIUC, currently this else is redundant since domainInterfaceStatusByMac represents both the guet agent + libvirt domain interfaces. So even interfaces the are not reported y the ga by reported by libvirt will be there.

Copy link
Contributor Author

@oshoval oshoval Dec 30, 2021

Choose a reason for hiding this comment

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

it is true only if there is guest agent, if there isn't (or even if there is but until the first report of it) then we do need this else as the whole merge won't be called and we will need to set the infoSource ourself, because the interface won't be found on domainInterfaceStatusByMac

}},
}

netStat.UpdateStatus(vmi, domain)

Expect(vmi.Status.Interfaces).To(Equal([]v1.VirtualMachineInstanceNetworkInterface{
newVMIStatusIface(networkName, nil, ifaceMAC, guestIfaceName),
newVMIStatusIface(networkName, nil, ifaceMAC, guestIfaceName, netvmispec.InfoSourceDomainAndGA),
Copy link
Member

Choose a reason for hiding this comment

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

Please add a test with InfoSourceDomain.

Copy link
Contributor Author

@oshoval oshoval Dec 30, 2021

Choose a reason for hiding this comment

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

@EdDev
Copy link
Member

EdDev commented Jan 2, 2022

/sig network

@AlonaKaplan
Copy link
Member

/approve

I"m waiting for a follow-up PR removing the non guest agent information from the merge as #6744 intended to do,
And specifying the info-source directly in netstat.go (status update) and not in two plaves (the metges and the status update).

@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AlonaKaplan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubevirt-bot kubevirt-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 3, 2022
@oshoval
Copy link
Contributor Author

oshoval commented Jan 3, 2022

Thanks

CI has some problems fetching from quay / github, will retest soon

@oshoval
Copy link
Contributor Author

oshoval commented Jan 3, 2022

/retest

still
docker: Error response from daemon: Get "https://quay.io/v2/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).

@oshoval
Copy link
Contributor Author

oshoval commented Jan 3, 2022

/retest

1 similar comment
@oshoval
Copy link
Contributor Author

oshoval commented Jan 3, 2022

/retest

@kubevirt-commenter-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs.
Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 3, 2022
Since two networks can use the same network attachement defintion,
allow MultusNetwork to specify the network name in addition to
the nad name.
This way more than one network can be created using the same nad.

Signed-off-by: Or Shoval <oshoval@redhat.com>
In case of MAC change in the guest,
the vmi status will present two interfaces,
one based on the domain spec, and one based on the
guest agent (if it exists).

The reason is that the MAC address is used in order
to match the interface of the domain spec with the
interfaces reported by the guest agent.
Once the MAC is changed, this matching can't be performed.

In order to make the info easier to understand,
add a new field to each interface in vmi.status.
infoSource field has 3 possible values:
1. domain - info is based on the domain spec
2. guest-agent - info is based on guest agent report
3. domain, guest-agent - info is based on both domain spec
   and guest agent report.

Signed-off-by: Or Shoval <oshoval@redhat.com>
@kubevirt-bot kubevirt-bot removed lgtm Indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jan 4, 2022
@oshoval
Copy link
Contributor Author

oshoval commented Jan 4, 2022

rebased

@oshoval
Copy link
Contributor Author

oshoval commented Jan 4, 2022

/test pull-kubevirt-check-tests-for-flakes

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Jan 4, 2022
@kubevirt-commenter-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs.
Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@oshoval
Copy link
Contributor Author

oshoval commented Jan 5, 2022

/test pull-kubevirt-e2e-kind-1.22-sriov

for some reason CI didnt run it for 18 hours
(and once i triggered it , it did)

@kubevirt-commenter-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs.
Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

1 similar comment
@kubevirt-commenter-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs.
Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@kubevirt-bot kubevirt-bot merged commit 87ef225 into kubevirt:main Jan 5, 2022
@oshoval
Copy link
Contributor Author

oshoval commented Jan 6, 2022

/cherry-pick release-0.49

@kubevirt-bot
Copy link
Contributor

@oshoval: new pull request created: #7034

In response to this:

/cherry-pick release-0.49

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/network size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants