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
Bug 1870331: Not allow to change size for OCS based resource #6683
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ import { | |
RequestSizeInput, | ||
Timestamp, | ||
resourcePathFromModel, | ||
convertToBaseValue, | ||
} from '@console/internal/components/utils'; | ||
import { | ||
k8sCreate, | ||
|
@@ -31,7 +32,7 @@ import { | |
VolumeSnapshotModel, | ||
VolumeSnapshotClassModel, | ||
} from '@console/internal/models'; | ||
import { getName, getNamespace, Status } from '@console/shared'; | ||
import { getName, getNamespace, Status, isCephProvisioner } from '@console/shared'; | ||
import { StorageClassDropdown } from '@console/internal/components/utils/storage-class-dropdown'; | ||
import { dropdownUnits } from '@console/internal/components/storage/shared'; | ||
import { useK8sGet } from '@console/internal/components/utils/k8s-get-hook'; | ||
|
@@ -48,8 +49,9 @@ const RestorePVCModal = withHandlePromise<RestorePVCModalProps>( | |
? `${defaultSize[0]} ${dropdownUnits[defaultSize[1]]}` | ||
: ''; | ||
const [requestedSize, setRequestedSize] = React.useState(defaultSize?.[0] ?? ''); | ||
const [requestedUnit, setRequestedUnit] = React.useState(defaultSize?.[1] ?? 'Gi'); | ||
const [requestedUnit, setRequestedUnit] = React.useState(defaultSize?.[1] ?? 'Ti'); | ||
const [pvcSC, setPVCStorageClass] = React.useState(''); | ||
const [validSize, setValidSize] = React.useState(true); | ||
const namespace = getNamespace(resource); | ||
const snapshotName = getName(resource); | ||
|
||
|
@@ -74,6 +76,10 @@ const RestorePVCModal = withHandlePromise<RestorePVCModalProps>( | |
const requestedSizeInputChange = ({ value, unit }) => { | ||
setRequestedSize(value); | ||
setRequestedUnit(unit); | ||
const restoreSizeInBytes = convertToBaseValue(value + unit); | ||
const snapshotSizeInBytes = convertToBaseValue(resource?.status?.restoreSize); | ||
const isValid = restoreSizeInBytes >= snapshotSizeInBytes; | ||
setValidSize(isValid); | ||
}; | ||
|
||
const handleStorageClass = (updatedStorageClass) => | ||
|
@@ -119,7 +125,6 @@ const RestorePVCModal = withHandlePromise<RestorePVCModalProps>( | |
}, | ||
); | ||
}; | ||
|
||
return ( | ||
<div className="modal-content modal-content--no-inner-scroll"> | ||
<ModalTitle>Restore as new PVC</ModalTitle> | ||
|
@@ -165,16 +170,26 @@ const RestorePVCModal = withHandlePromise<RestorePVCModalProps>( | |
label="Size" | ||
isRequired | ||
fieldId="pvc-size" | ||
className="co-restore-pvc-modal__input" | ||
className="co-restore-pvc-modal__input co-restore-pvc-modal__ocs-size" | ||
helperTextInvalid="Size should be equal or greater than the restore size of snapshot" | ||
validated={validSize ? 'default' : 'error'} | ||
> | ||
<RequestSizeInput | ||
name="requestSize" | ||
onChange={requestedSizeInputChange} | ||
defaultRequestSizeUnit={requestedUnit} | ||
defaultRequestSizeValue={requestedSize} | ||
dropdownUnits={dropdownUnits} | ||
required | ||
/> | ||
{snapshotClassResourceLoaded ? ( | ||
<RequestSizeInput | ||
name="requestSize" | ||
onChange={requestedSizeInputChange} | ||
defaultRequestSizeUnit={requestedUnit} | ||
defaultRequestSizeValue={requestedSize} | ||
dropdownUnits={dropdownUnits} | ||
isInputDisabled={ | ||
snapshotClassResourceLoadError || | ||
isCephProvisioner(snapshotClassResource?.driver) | ||
} | ||
required | ||
/> | ||
) : ( | ||
<div className="skeleton-text" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if you have error ? It will be always showing loading state ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, its better to disable size input in that case. |
||
)} | ||
</FormGroup> | ||
<div className="co-restore-pvc-modal__details-section"> | ||
<p className="text-muted">{VolumeSnapshotModel.label} details</p> | ||
|
@@ -213,6 +228,7 @@ const RestorePVCModal = withHandlePromise<RestorePVCModalProps>( | |
</ModalBody> | ||
<ModalSubmitFooter | ||
inProgress={inProgress} | ||
submitDisabled={!validSize} | ||
errorMessage={errorMessage} | ||
submitText="Restore" | ||
cancel={cancel} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 as above