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
kubevirt: deprecate using StorageClassConfigMap in inappropriate placess + SC/volume-access modes fixes #4850
Conversation
@@ -391,6 +404,8 @@ export const CreateVMWizardPageComponent: React.FC<CreateVMWizardPageComponentPr | |||
); | |||
} | |||
|
|||
const storageClassConfigMap = useStorageClassConfigMapWrapped(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this hook should load the correct config map for us. IMO it shouldn't be a problem to do this only once per wizard as the map should not change dynamically. And even if it does change it probably makes sense to have a consistent behaviour for a single instance of a wizard
@@ -120,6 +128,8 @@ export const getDisks = (parsedVm): VMWizardStorage[] => { | |||
size: size.value, | |||
unit: size.unit, | |||
}) | |||
.setVolumeMode(getDefaultSCVolumeMode(storageClassConfigMap)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all the SC defaults should gets resolved when the storage gets created
isEditing, | ||
errorMessage, | ||
handlePromise, | ||
close, | ||
cancel, | ||
templateValidations, | ||
storageClassConfigMap: _storageClassConfigMap, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be agnostic to the source of the config map
} | ||
}, [isEditing, source, storageClassName]); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [isLoaded(_storageClassConfigMap)]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modal disabled until it loads ant then it should set the defaults only once and only for a new storage
if (newVolumeMode !== volumeMode) { | ||
setVolumeMode(newVolumeMode); | ||
} | ||
if (newAMode !== accessMode || newVolumeMode !== volumeMode) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
notify the user when we change hidden fields by the SC
static readonly READ_ONLY = new AccessMode('ReadOnlyMany'); | ||
static readonly READ_WRITE_ONCE = new AccessMode('ReadWriteOnce', 'Single User (RWO)'); | ||
static readonly READ_WRITE_MANY = new AccessMode('ReadWriteMany', 'Shared Access (RWX)'); | ||
static readonly READ_ONLY_MANY = new AccessMode('ReadOnlyMany', 'Read Only (ROX)'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO we should use the k8s names as it is can be confusing for a programmer to map these to the k8s ones
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This definitely works for me. I was just making sure that the k8s names were used in the UI because that's what the designers decided was best. I like the way you refactored this.
} | ||
return getVMLikePatches(vmLikeEntity, (vm) => { | ||
): Patch[] => | ||
getVMLikePatches(vmLikeEntity, (vm) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should not be doing these resolves anymore behind the users back
getDefaultSCVolumeMode(storageClassConfigMap, dataVolumeWrapper.getStorageClassName()), | ||
getDefaultSCAccessModes(storageClassConfigMap, dataVolumeWrapper.getStorageClassName()), | ||
); | ||
.setNamespace(isPlainDataVolume ? namespace : undefined); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here and in the v2v storages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One substantial change in sc-defaults.ts, a question about the UX in disk-modal.tsx, a few nitpicks, and some comments. Overall, I really like the changes you made.
} | ||
} | ||
} | ||
if (!controller.current.signal.aborted) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Could you add an empty line here? I think it helps readability to add some vertical space between blocks like this, especially when there's a lot of nesting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, I also removed the react ref and moved the controller inside the useEffect. As I realized there is probably not a use case for canceling the request outside of this hook.
return acc; | ||
}, {}), | ||
...[...DetectCommonDataChanges] | ||
.filter((v) => v !== VMWizardProps.storageClassConfigMap) // pased directly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: In the comment, 'pased' should be 'passed'.
@@ -197,27 +190,27 @@ export const DiskModal = withHandlePromise((props: DiskModalProps) => { | |||
if (source.requiresDatavolume()) { | |||
resultDataVolume = DataVolumeWrapper.initializeFromSimpleData({ | |||
name: resultDataVolumeName, | |||
storageClassName, | |||
storageClassName: storageClassName || null, // || null are for merge to work |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: In the comment "|| null are for merge to work" would be more correctly written as "|| null is to enable merging"
} | ||
|
||
let resultPersistentVolumeClaim; | ||
if (source.requiresNewPVC()) { | ||
resultPersistentVolumeClaim = new PersistentVolumeClaimWrapper() | ||
.init({ | ||
name, | ||
storageClassName, | ||
storageClassName: storageClassName || null, // || null are for merge to work |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: In the comment "|| null are for merge to work" would be more correctly written as "|| null is to enable merging"
// eslint-disable-next-line eqeqeq | ||
if (newStorageClassName != storageClassName) { | ||
setStorageClassName(newStorageClassName); | ||
const newAMode = getDefaultSCAccessModes(storageClassConfigMap, newStorageClassName)[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why shorten the variable name here? Did it push you over the character limit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed :)
static readonly READ_ONLY = new AccessMode('ReadOnlyMany'); | ||
static readonly READ_WRITE_ONCE = new AccessMode('ReadWriteOnce', 'Single User (RWO)'); | ||
static readonly READ_WRITE_MANY = new AccessMode('ReadWriteMany', 'Shared Access (RWX)'); | ||
static readonly READ_ONLY_MANY = new AccessMode('ReadOnlyMany', 'Read Only (ROX)'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This definitely works for me. I was just making sure that the k8s names were used in the UI because that's what the designers decided was best. I like the way you refactored this.
if (!controller.current.signal.aborted) { | ||
setStorageClassConfigMap(null); | ||
setError( | ||
`Could not load storage config map in following namespaces: ${joinGrammaticallyListOfItems( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this say "Could not load storage class config map..."?
getDefaultSCVolumeMode(storageClassConfigMap, storageClassName), | ||
getDefaultSCAccessModes(storageClassConfigMap, storageClassName), | ||
) | ||
.setVolumeMode(getDefaultSCVolumeMode(storageClassConfigMap, storageClassName)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I definitely like this better.
@@ -35,12 +35,12 @@ export const getDefaultSCVolumeMode = ( | |||
return volumeMode; | |||
} | |||
|
|||
return storageClassName === 'local-sc' ? VolumeMode.FILESYSTEM : VolumeMode.BLOCK; | |||
return storageClassName === 'local-sc' ? VolumeMode.BLOCK : VolumeMode.FILESYSTEM; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I talked to Alex Wels on the storage team. He said that if nothing is returned from the config map then we can default to FileSystem and RWO since every storage class should support those settings. So, we can drop the check for local-sc
and just return FileSystem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good to know
@@ -54,5 +54,7 @@ export const getDefaultSCAccessModes = ( | |||
return [accessMode]; | |||
} | |||
|
|||
return storageClassName === 'local-sc' ? [AccessMode.SINGLE_USER] : [AccessMode.SHARED_ACCESS]; | |||
return storageClassName === 'local-sc' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above. We can just return RWO if the config map doesn't return anything.
…ess + SC/volume-access modes fixes - introduce useStorageClassConfigMap hook - move volume/access modes resolution into the places where dv/pvc gets created - from modal - from import - prefer visible volume/access mode - deprecate assertDefaultModes - add storageClassConfigMap to common data in VMWizard - fix disk modal - allow empty modes - allow empty or no storage class - fix enums - show volume/access modes in ReviewTab - remove async and get requests from modal patches - show CDs in disks tab to allow editing of volume/access modes - allow editing storages until the DV gets created - simplify create/import VM request flow
fixed review comments |
I added a small enhancement to this PR. I noticed that we do not notify user in any way when we change access/volume modes when the storage class changes. The user might not know this has occurred and run into some problems in the future. With this change, the drawer will open when any of the modes change. But it will stay closed when the modes stay the same, upon the storage class change. Thoughts? @matthewcarleton @Ranelim |
This PR adds the CDs and Environment Vars to the discs list. VMs consume CDs and Environment Vars resources as discs, so it makes seance to add them here, but CD's and Environment are special cases of discs, for example: @matthewcarleton @Ranelim my questions are: |
The disks tab doesn't conflict with these. It does not have a power to change some fields (e.g. config map), but it can change other fields which these other dialogs cannot.
agree this should get accounted for
these modals do not allow editing bus and access volume modes, so it is necessary to have such option for these disks through disk tab. |
/lgtm IMHO we will need a follow-up PR for: |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: suomiy, yaacov 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 |
c - take care of links from the overview card ... @matthewcarleton we will need some design thought on adding the new discs typs |
this bug was already present before this PR. I posted a fix here: #4873 IMO we should allow changing the bus and the name for all sources as it is available for them. Btw you can do the same through the YAML |
@yaacov so just to confirm for a follow up PR we'll need designs to cover how to edit different types in the disks tab (CDs, Environments)? |
Nice catch @suomiy ! |
and probably adding them? since we can edit them in the table
maybe. I though maybe a highlighting would do but notification would probably give the best idea to all types of users. Could you please take a look at it? Also we are preselecting these values according to the config map when you create new disk and not showing the advanced drawer. I suppose we can probably keep this behaviour, but just in case. |
@matthewcarleton hi, thanks for the replay, yes, we will need help to align the current changes in the disks tab functionality with the UX design. We agreed off-line with @jelkosz and @suomiy that we will push this as is, and adjust what needed in follow-up PRs. The open questions I have are: 2 - In the Details tab we have "Edit CD" modal that is different in one field from the "Edit CD" we have in the disks tab, do we align them ? 3 - in the Environment tab we add/edit/delete the Secrets/CM/SA, now we can do it also from the disks tab, is it ok ? do we need to alert users that deleting some disk will actually change the secrets available for this VM ? |
Please take a look @pcbailey @yaacov