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

CNV-32684: Fixing the dynamic ssh key injection #1538

Conversation

DanaOrr
Copy link
Contributor

@DanaOrr DanaOrr commented Sep 13, 2023

📝 Description

These changes involve adding the missing line - 'runcmd - [ setsebool, -P, virt_qemu_ga_manage_ssh, on ]` to the YAML in instanceTypes.
Also, I fixed the problem that after creating a VM, and the dynamic SSH key injection switch was turned on, we could not edit the ssh key. Now, we should be able to edit or remove the SSH key.
If the dynamic SSH key injection switch has not been activated, it will not be possible to edit the ssh key after creation and the option to edit will be disabled.

🎥 Demo

Template-
templateCheckDynamic
templateUnCheckDynamic

InstanceType -
itCheckDynamic
itUnCheckDynamic

@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented Sep 13, 2023

@DanaOrr: This pull request references CNV-32684 which is a valid jira issue.

In response to this:

📝 Description

These changes involve adding the missing line - 'runcmd:\n- [ setsebool, -P, virt_qemu_ga_manage_ssh, on ]` to the YAML in instanceTypes.
Also, I fixed the problem that after creating a VM, and the dynamic SSH key injection switch was turned on, we could not edit the ssh key. Now, we should be able to edit or remove the SSH key.
If the dynamic SSH key injection switch has not been activated, it will not be possible to edit the ssh key after creation and the option to edit will be disabled.

🎥 Demo

Template-
templateCheckDynamic
templateUnCheckDynamic

InstanceType -
itCheckDynamic
itUnCheckDynamic

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.

@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented Sep 13, 2023

@DanaOrr: This pull request references CNV-32684 which is a valid jira issue.

In response to this:

📝 Description

These changes involve adding the missing line - 'runcmd - [ setsebool, -P, virt_qemu_ga_manage_ssh, on ]` to the YAML in instanceTypes.
Also, I fixed the problem that after creating a VM, and the dynamic SSH key injection switch was turned on, we could not edit the ssh key. Now, we should be able to edit or remove the SSH key.
If the dynamic SSH key injection switch has not been activated, it will not be possible to edit the ssh key after creation and the option to edit will be disabled.

🎥 Demo

Template-
templateCheckDynamic
templateUnCheckDynamic

InstanceType -
itCheckDynamic
itUnCheckDynamic

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.

@DanaOrr
Copy link
Contributor Author

DanaOrr commented Sep 13, 2023

/retest

1 similar comment
@DanaOrr
Copy link
Contributor Author

DanaOrr commented Sep 14, 2023

/retest

src/utils/resources/vm/utils/source.ts Show resolved Hide resolved
): V1beta1DataVolumeSourcePVC | V1beta1DataVolumeSourceRef => {
const bootDisk = getBootDisk(vm);
const volume = getVolumes(vm)?.find((vol) => vol.name === bootDisk?.name);
const dataVolumeTemplate = vm?.spec?.dataVolumeTemplates?.find(
Copy link
Member

Choose a reason for hiding this comment

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

instead of vm?.spec?.dataVolumeTemplates please use the selector function getDataVolumeTemplates

const bootDisk = getBootDisk(vm);
const volume = getVolumes(vm)?.find((vol) => vol.name === bootDisk?.name);
const dataVolumeTemplate = vm?.spec?.dataVolumeTemplates?.find(
(dv) => dv.metadata?.name === volume?.dataVolume?.name,
Copy link
Member

Choose a reason for hiding this comment

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

instead of using ?.metadata?.name use selector function getName for dv and volume

src/utils/resources/vm/utils/source.ts Show resolved Hide resolved
}

if (dataVolumeTemplate?.spec?.source?.pvc) {
return dataVolumeTemplate?.spec?.source?.pvc;
Copy link
Member

Choose a reason for hiding this comment

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

consider returning something like:
{
name: pvc?.name
namespace: pvc?.namespace
kind: PersistentVolumeClaimModel.kind
}
this will allow you to get a specific resource in your hook useDynamicSSHInjectionEnabledForVM
(no need to fetch all volumes, and find the specific one in the hook)

Comment on lines 53 to 54
const isDynamicSSHInjectionTemplate = useMemo(() => getIsDynamicSSHInjectionEnabled(vm), [vm]);
const isDynamicSSHInjectionInstanceType = useDynamicSSHInjectionEnabledForVM(vm);
Copy link
Member

Choose a reason for hiding this comment

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

both constants are used together wherever they are used, combine the getIsDynamicSSHInjectionEnabled function with the useDynamicSSHInjectionEnabledForVM hook.
Also useDynamicSSHInjection would be fine as a name for the hook if you want a shorter one

Comment on lines 12 to 14
const isDynamicSSHInjectionEnabled =
getLabel(bootableVolume, DYNAMIC_CREDENTIALS_SUPPORT) === 'true' &&
Boolean(getAccessCredentials(vm)?.[0]?.sshPublicKey?.propagationMethod?.qemuGuestAgent);
Copy link
Member

Choose a reason for hiding this comment

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

this code is very similar to getIsDynamicSSHInjectionEnabled, can you make getIsDynamicSSHInjectionEnabled to get any kind of K8s resource and not just vm?

@DanaOrr DanaOrr force-pushed the fixinig-dynamic-ssh-key-injection branch from 192a7b3 to 159bd5f Compare September 19, 2023 14:37
Signed-off-by: Dana Orr <dorr@redhat.com>
@DanaOrr DanaOrr force-pushed the fixinig-dynamic-ssh-key-injection branch from 159bd5f to 2828997 Compare September 21, 2023 08:14
@openshift-ci openshift-ci bot added the lgtm Passed code review, ready for merge label Sep 26, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 26, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: avivtur, DanaOrr

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

@openshift-ci openshift-ci bot added the approved This issue is something we want to fix label Sep 26, 2023
@openshift-merge-robot openshift-merge-robot merged commit 30da813 into kubevirt-ui:main Sep 26, 2023
8 checks passed
@DanaOrr
Copy link
Contributor Author

DanaOrr commented Oct 1, 2023

/cherry-pick release-4.14

@openshift-cherrypick-robot
Copy link
Collaborator

@DanaOrr: new pull request created: #1574

In response to this:

/cherry-pick release-4.14

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 This issue is something we want to fix jira/valid-reference lgtm Passed code review, ready for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants