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

Show VM name in export status #9145

Merged
merged 2 commits into from
Feb 5, 2023
Merged

Conversation

awels
Copy link
Member

@awels awels commented Feb 1, 2023

Signed-off-by: Alexander Wels awels@redhat.com

What this PR does / why we need it:
For display purposes it is handy to have the VM name of the VM/VMSnapshot available in the export status. Added a new field containing the name and populating it during the standard reconcile loop.

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 #

Special notes for your reviewer:

Release note:

Show VirtualMachine name in the VMExport status

@kubevirt-bot kubevirt-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API size/M labels Feb 1, 2023
}
return export.Status.VirtualMachineName
}, 30*time.Second, time.Second).Should(Equal(name))
return export
Copy link
Member

Choose a reason for hiding this comment

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

This is never used right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct, but I like to return the updated objects in these types of functions so it can be passed into another function without having to re-read it.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah understood but until it's actually used it seems odd to include it.

return ""
}
return export.Status.VirtualMachineName
}, 30*time.Second, time.Second).Should(Equal(name))
Copy link
Member

Choose a reason for hiding this comment

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

nit - This could be a single bool return.

return export.Status != nil && export.Status.VirtualMachineName == name

Copy link
Member Author

Choose a reason for hiding this comment

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

But it is expecting a string not a bool.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't like making the Eventually expect a bool, the way it is written now, it prints the name (or blank if export.Status == nil) from the status object. If written your way I won't get that feedback.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah that's fair, more feedback on failure is always useful, apologies.

@lyarwood
Copy link
Member

lyarwood commented Feb 1, 2023

/lgtm

I'd rather the unused return was removed but otherwise this lgtm.

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Feb 1, 2023
For display purposes it is handy to have the VM name
of the VM/VMSnapshot available in the export status.

Signed-off-by: Alexander Wels <awels@redhat.com>
@kubevirt-bot kubevirt-bot removed the lgtm Indicates that a PR is ready to be merged. label Feb 1, 2023
@awels
Copy link
Member Author

awels commented Feb 1, 2023

Took the return out, it is not that big of a deal to me.

@lyarwood
Copy link
Member

lyarwood commented Feb 1, 2023

/lgtm

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Feb 1, 2023
@awels
Copy link
Member Author

awels commented Feb 1, 2023

/retest-required

Copy link
Member

@mhenriks mhenriks left a comment

Choose a reason for hiding this comment

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

looks good one minor comment

// VirtualMachineName shows the name of the source virtual machine if the source is either a VirtualMachine or
// a VirtualMachineSnapshot. This is mainly to easily identify the source VirtualMachine in case of a
// VirtualMachineSnapshot
VirtualMachineName string `json:"virtualMachineName,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

I think this type should probably be *string. Will be unset in the case of PVC source

https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#optional-vs-required

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, I will make that change.

Copy link
Member

@lyarwood lyarwood Feb 2, 2023

Choose a reason for hiding this comment

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

Does that doc need to be updated as +optional and omitempty work fine with empty string values? I get that using a pointer lets us check for unset values but we'd expect the name here to be empty or set?

Anyway we should really have some kind of lint rule somewhere to enforce the use of pointers for strings if we want things to be consistent, just above this ServiceName is also optional and not a pointer.

Copy link
Member Author

Choose a reason for hiding this comment

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

So with just a string we overload "" as does not exist, even though blank might be a valid value. With *string we can use nil as does not exist, and blank is just another possible value. The difference is mostly academic, but in general the rule is, if you have an optional field, it should be a pointer.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah understood, my point was that "" isn't a valid name for a VirtualMachine so we could use it to mean unset here. Either way using pointers for optional attributes is definitely something we can check and enforce in the codebase but that's for another PR, apologies for the noise!

Copy link
Member

Choose a reason for hiding this comment

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

@lyarwood good point, ServiceName maybe shouldn't be optional. There will always be a service associated to a VMExport and it's name is known as soon as the VMExport is created

What makes VirtualMachineName different from ServiceName is that VirtualMachineName will only be set for certain VMExports, not all

@kubevirt-bot kubevirt-bot removed the lgtm Indicates that a PR is ready to be merged. label Feb 2, 2023
@awels
Copy link
Member Author

awels commented Feb 2, 2023

/retest-required

@lyarwood
Copy link
Member

lyarwood commented Feb 3, 2023

Could you fix up 8cfc70c - somehow the subject and signed-off lines have swicthed?

Signed-off-by: Alexander Wels <awels@redhat.com>
@awels
Copy link
Member Author

awels commented Feb 3, 2023

Not sure how that happened fixed. Note it looks like the 1.26 storage lane has a permanent failure on some PSA pod.

@mhenriks
Copy link
Member

mhenriks commented Feb 3, 2023

/lgtm
/approve

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Feb 3, 2023
@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mhenriks

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 Feb 3, 2023
@kubevirt-commenter-bot
Copy link

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

6 similar comments
@kubevirt-commenter-bot
Copy link

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

@kubevirt-commenter-bot
Copy link

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

@kubevirt-commenter-bot
Copy link

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

@kubevirt-commenter-bot
Copy link

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

@kubevirt-commenter-bot
Copy link

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

@kubevirt-commenter-bot
Copy link

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

@kubevirt-bot
Copy link
Contributor

kubevirt-bot commented Feb 5, 2023

@awels: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubevirt-fossa acae506 link false /test pull-kubevirt-fossa

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. I understand the commands that are listed here.

@awels
Copy link
Member Author

awels commented Feb 5, 2023

/test pull-kubevirt-e2e-k8s-1.24-sig-network

@kubevirt-bot kubevirt-bot merged commit d85e704 into kubevirt:main Feb 5, 2023
@awels
Copy link
Member Author

awels commented Mar 6, 2023

/cherrypick release-0.59

@kubevirt-bot
Copy link
Contributor

@awels: #9145 failed to apply on top of branch "release-0.59":

Applying: Show VM name in export status
Using index info to reconstruct a base tree...
M	pkg/storage/export/export/vm-source.go
M	pkg/storage/export/export/vmsnapshot-source.go
M	tests/storage/export.go
Falling back to patching base and 3-way merge...
Auto-merging tests/storage/export.go
Auto-merging pkg/storage/export/export/vmsnapshot-source.go
CONFLICT (content): Merge conflict in pkg/storage/export/export/vmsnapshot-source.go
Auto-merging pkg/storage/export/export/vm-source.go
CONFLICT (content): Merge conflict in pkg/storage/export/export/vm-source.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Show VM name in export status
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherrypick release-0.59

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.

awels pushed a commit to awels/kubevirt that referenced this pull request Mar 6, 2023
awels pushed a commit to awels/kubevirt that referenced this pull request Mar 6, 2023
Show VM name in export status

Signed-off-by: Alexander Wels <awels@redhat.com>
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. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API 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. size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants