fix(xo-web,xo-server#probeIscsiLuns): handle undefined lun size (#5212)

See xoa-support#2815
See https://xcp-ng.org/forum/topic/3409/getting-error-when-trying-to-mount-iscsi-lun
This commit is contained in:
badrAZ 2020-09-09 12:11:50 +02:00 committed by GitHub
parent 846eff4984
commit edaae02892
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 6 deletions

View File

@ -13,6 +13,8 @@
> Users must be able to say: “I had this issue, happy to know it's fixed”
- [New SR] Fix `Cannot read property 'trim' of undefined` error (PR [#5212](https://github.com/vatesfr/xen-orchestra/pull/5212))
### Packages to release
> Packages will be released in the order they are here, therefore, they should
@ -31,3 +33,4 @@
> In case of conflict, the highest (lowest in previous list) `$version` wins.
- xo-web minor
- xo-server patch

View File

@ -719,7 +719,7 @@ export async function probeIscsiLuns({
id: lun.LUNid.trim(),
vendor: lun.vendor.trim(),
serial: lun.serial.trim(),
size: lun.size.trim(),
size: lun.size?.trim(),
scsiId: lun.SCSIid.trim(),
})
})

View File

@ -82,6 +82,7 @@ const messages = {
upgradesAvailable: 'Upgrades available',
advancedSettings: 'Advanced settings',
txChecksumming: 'TX checksumming',
unknownSize: 'Unknown size',
// ----- Modals -----
alertOk: 'OK',

View File

@ -144,6 +144,7 @@ class SelectIqn extends Component {
}
}
@injectIntl
class SelectLun extends Component {
static propTypes = {
onChange: PropTypes.func.isRequired,
@ -152,11 +153,14 @@ class SelectLun extends Component {
_getOptions = createSelector(
() => this.props.options,
options =>
() => this.props.intl.formatMessage,
(options, formatMessage) =>
map(options, (lun, index) => ({
label: `LUN ${lun.id}: ${lun.serial} - ${formatSize(+lun.size)} - (${
lun.vendor
})`,
label: `LUN ${lun.id}: ${lun.serial} - ${
lun.size !== undefined
? formatSize(+lun.size)
: formatMessage(messages.unknownSize)
} - (${lun.vendor})`,
value: index,
}))
)
@ -989,7 +993,11 @@ export default class New extends Component {
{type === 'iscsi' && (
<dl className='dl-horizontal'>
<dt>{_('newSrSize')}</dt>
<dd>{formatSize(+lun.size)}</dd>
<dd>
{lun.size !== undefined
? formatSize(+lun.size)
: _('unknownSize')}
</dd>
</dl>
)}
{includes(['nfs', 'hba'], type) && (