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

fix: Use the latest image of vm-console-proxy #645

Merged
merged 1 commit into from Aug 30, 2023

Conversation

akrejcir
Copy link
Collaborator

@akrejcir akrejcir commented Aug 8, 2023

What this PR does / why we need it:

  • Updated release script to change vm-console-proxy image tag.
  • csv-generator uses VM_CONSOLE_PROXY_IMAGE environment variable to set the image.

Release note:

csv-generator can be used to set the image of vm-console-proxy.

@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. labels Aug 8, 2023
@akrejcir
Copy link
Collaborator Author

akrejcir commented Aug 8, 2023

/cc @codingben @0xFelix

Copy link
Member

@codingben codingben left a comment

Choose a reason for hiding this comment

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

/lgtm

EDIT: Seems like this PR needs more work since a new vm-console-proxy v0.3.0 contains breaking changes.

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 8, 2023
@akrejcir
Copy link
Collaborator Author

akrejcir commented Aug 8, 2023

This needs more work.

@akrejcir akrejcir marked this pull request as draft August 8, 2023 13:51
@kubevirt-bot kubevirt-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 8, 2023
@kubevirt-bot kubevirt-bot added size/XL and removed lgtm Indicates that a PR is ready to be merged. size/M labels Aug 10, 2023
@akrejcir akrejcir force-pushed the fix-proxy-image branch 2 times, most recently from 77c61ec to 64a42b5 Compare August 11, 2023 13:48
@akrejcir
Copy link
Collaborator Author

This is nearly complete, it's only missing one functional test.
Can you take a look?

/cc @0xFelix @lyarwood

Copy link
Member

@0xFelix 0xFelix left a comment

Choose a reason for hiding this comment

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

Good start, added some comments!

Copy link
Member

Choose a reason for hiding this comment

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

Have you checked that these are the minimal required RBAC changes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, they are minimal in the sense of groups:

  • read permissions: get, list, watch
  • write permissions: create, update, patch, delete.

In my opinion it does not make sense to grant list permission and not get permission. Because list can be used to get a single element anyway. Similarly for update and patch.

Copy link
Member

Choose a reason for hiding this comment

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

@jcanocan what was the logic you applied with your previous RBAC audits?

I tend to agree with @0xFelix here that we shouldn't be granting everything even if a list basically provides get etc but lets stay consistant with @jcanocan 's previous work here and maybe write down the resulting best practice somewhere.

Copy link
Member

Choose a reason for hiding this comment

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

Ah @jcanocan is out this week, I'm okay leaving this as is for now if we write up a follow issue for next week to maybe reduce this down and document the best practice.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If we want to be more precise, It's harder to know what permissions libraries require, without running and failing, or reading the library code.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah appreciate that, definitely a follow up task now given @jcanocan isn't around anyway.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi all! The methodology used for auditing the rules is described here: #616. Basically, I've removed all verbs from all apiGroups, and I've added requested verbs. @akrejcir is right that it's hard to know in advance which permissions are required in advance. We are limited to trial and error in this sense.

Comment on lines +33 to +45
// +kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=clusterroles;clusterrolebindings;rolebindings,verbs=list;watch;create;update;delete
// +kubebuilder:rbac:groups=apiregistration.k8s.io,resources=apiservices,verbs=get;list;watch;create;update;delete

// Deprecated:
// +kubebuilder:rbac:groups=route.openshift.io,resources=routes,verbs=list;watch;delete

// RBAC for created roles
// +kubebuilder:rbac:groups=kubevirt.io,resources=virtualmachineinstances,verbs=get;list;watch
// +kubebuilder:rbac:groups=core,resources=pods,verbs=get;list;watch
// +kubebuilder:rbac:groups=core,resources=serviceaccounts,verbs=get;list;watch;create;update;delete;patch
// +kubebuilder:rbac:groups=core,resources=serviceaccounts/token,verbs=create
// +kubebuilder:rbac:groups=kubevirt.io,resources=virtualmachineinstances;virtualmachines,verbs=get;list;watch
// +kubebuilder:rbac:groups=subresources.kubevirt.io,resources=virtualmachineinstances/vnc,verbs=get
// +kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=roles;rolebindings,verbs=get;list;watch;create;update;delete;patch
Copy link
Member

Choose a reason for hiding this comment

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

Same as above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The same.

internal/operands/vm-console-proxy/reconcile_test.go Outdated Show resolved Hide resolved
route := &routev1.Route{
ObjectMeta: metav1.ObjectMeta{
Name: routeName,
Namespace: namespace,
Copy link
Member

Choose a reason for hiding this comment

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

Same as above.

Do these test cases add any value compared to the same ones above?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, this case tests the Cleanup() method, and the above one tests Reconcile() method.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

internal/vm-console-proxy-bundle/bundle.go Outdated Show resolved Hide resolved
@@ -17,6 +17,7 @@ jobs:
OUTPUT_FILE=./data/vm-console-proxy-bundle/vm-console-proxy.yaml
mkdir -p ./data/vm-console-proxy-bundle
curl -L https://github.com/kubevirt/vm-console-proxy/releases/download/${RELEASE_VERSION}/vm-console-proxy.yaml > ${OUTPUT_FILE}
sed -i "s/defaultVmConsoleProxyImageTag = .*$/defaultVmConsoleProxyImageTag = \"${RELEASE_VERSION}\"/" ./internal/operands/vm-console-proxy/defaults.go
Copy link
Member

Choose a reason for hiding this comment

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

IMHO, I don't think we should do that bump here.

  1. This workflow is used to update vm-console-proxy bundle only
  2. We try to change code during that workflow, what if defaults.go will be removed in the future?

Why not just use latest tag? if anyways this intended to be updated on every release to latest one, just use latest then: quay.io/kubevirt/vm-console-proxy:latest.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  1. This workflow is used to update vm-console-proxy bundle only

This workflow is used to update SSP operator code, so that it uses the latest release of vm-cosole-proxy. It can update the image tag and bundle.

  1. We try to change code during that workflow, what if defaults.go will be removed in the future?

I will add a comment to defaults.go explaining how the file is used.

Why not just use latest tag? if anyways this intended to be updated on every release to latest one, just use latest then: quay.io/kubevirt/vm-console-proxy:latest.

There is no latest tag. We would need to add automation to create and update it.
https://quay.io/repository/kubevirt/vm-console-proxy?tab=tags&tag=latest

Using the latest tag would probably not save us work, because we would need to fix the version when creating a release branch.

@akrejcir akrejcir force-pushed the fix-proxy-image branch 2 times, most recently from 4dacb93 to f533bb5 Compare August 15, 2023 13:14
@akrejcir akrejcir marked this pull request as ready for review August 15, 2023 13:14
@lyarwood
Copy link
Member

/lgtm

@lyarwood
Copy link
Member

/retest-required

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 15, 2023
@akrejcir
Copy link
Collaborator Author

/retest

@kubevirt-bot kubevirt-bot removed the lgtm Indicates that a PR is ready to be merged. label Aug 16, 2023
@akrejcir
Copy link
Collaborator Author

/retest

@akrejcir
Copy link
Collaborator Author

@ksimon1 , are the CI failures related to the CDI issue?

@akrejcir
Copy link
Collaborator Author

/retest

2 similar comments
@akrejcir
Copy link
Collaborator Author

/retest

@jcanocan
Copy link
Contributor

/retest

@akrejcir
Copy link
Collaborator Author

We cannot merge this yet.
Incorrect implementation of APIService extension in vm-cosole-proxy is blocking the deletion of any namespace in the cluster.

Holding until a fixed version of vm-console-proxy is released.

/hold

@kubevirt-bot kubevirt-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 23, 2023
@akrejcir
Copy link
Collaborator Author

I've fixed the bug in vm-cosole-proxy: kubevirt/vm-console-proxy#27
And released a new version.

/unhold

@kubevirt-bot kubevirt-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 29, 2023
- Updated data/vm-console-proxy-bundle/vm-console-proxy.yaml
- Updated release script to change vm-console-proxy image tag.
- csv-generator uses VM_CONSOLE_PROXY_IMAGE env variable to set the image.
- Operator deploys new resources needed by vm-console-proxy.
- Operator removes Route resource, that is no longer needed.

Signed-off-by: Andrej Krejcir <akrejcir@redhat.com>
@sonarcloud
Copy link

sonarcloud bot commented Aug 30, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@lyarwood
Copy link
Member

/lgtm

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

/lgtm

@kubevirt-bot kubevirt-bot merged commit 2896081 into kubevirt:main Aug 30, 2023
11 checks passed
@akrejcir akrejcir deleted the fix-proxy-image branch August 30, 2023 10:58
@akrejcir
Copy link
Collaborator Author

/cherry-pick release-v0.18

@kubevirt-bot
Copy link
Contributor

@akrejcir: #645 failed to apply on top of branch "release-v0.18":

Applying: feat: Use the latest image of vm-console-proxy
.git/rebase-apply/patch:32: trailing whitespace.
          sed -i "s/defaultVmConsoleProxyImageTag = .*$/defaultVmConsoleProxyImageTag = \"${RELEASE_VERSION}\"/" ./internal/operands/vm-console-proxy/defaults.go 
warning: 1 line adds whitespace errors.
Using index info to reconstruct a base tree...
M	config/rbac/role.yaml
M	data/olm-catalog/ssp-operator.clusterserviceversion.yaml
M	internal/common/environment.go
M	internal/operands/vm-console-proxy/reconcile.go
Falling back to patching base and 3-way merge...
Auto-merging internal/operands/vm-console-proxy/reconcile.go
CONFLICT (content): Merge conflict in internal/operands/vm-console-proxy/reconcile.go
Auto-merging internal/common/environment.go
Auto-merging data/olm-catalog/ssp-operator.clusterserviceversion.yaml
CONFLICT (content): Merge conflict in data/olm-catalog/ssp-operator.clusterserviceversion.yaml
Auto-merging config/rbac/role.yaml
CONFLICT (content): Merge conflict in config/rbac/role.yaml
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 feat: Use the latest image of vm-console-proxy
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:

/cherry-pick release-v0.18

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. size/XL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants