-
Notifications
You must be signed in to change notification settings - Fork 7
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: encrypt option can only choose encrypted storage class when creating VM image #93
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ const CLONE = 'clone'; | |
const DOWNLOAD = 'download'; | ||
const UPLOAD = 'upload'; | ||
const rawORqcow2 = 'raw_qcow2'; | ||
const LONGHORN = 'longhorn'; | ||
|
||
export default { | ||
name: 'EditImage', | ||
|
@@ -61,9 +62,7 @@ export default { | |
storageClasses: this.$store.dispatch(`${ inStore }/findAll`, { type: STORAGE_CLASS }), | ||
}); | ||
|
||
const defaultStorage = this.$store.getters[`${ inStore }/all`](STORAGE_CLASS).find((s) => s.isDefault); | ||
|
||
this['storageClassName'] = this.storageClassName || defaultStorage?.metadata?.name || 'longhorn'; | ||
this['storageClassName'] = this.storageClassName || this.defaultStorageClassName(); | ||
this.images = this.$store.getters[`${ inStore }/all`](HCI.IMAGE); | ||
|
||
const { securityParameters } = this.value.spec; | ||
|
@@ -144,10 +143,23 @@ export default { | |
]; | ||
}, | ||
|
||
storageClassOptions() { | ||
encryptedStorageClasses() { | ||
const inStore = this.$store.getters['currentProduct'].inStore; | ||
const storages = this.$store.getters[`${ inStore }/all`](STORAGE_CLASS); | ||
|
||
return storages.filter((s) => s.isEncrypted); | ||
}, | ||
|
||
nonEncryptedStorageClasses() { | ||
const inStore = this.$store.getters['currentProduct'].inStore; | ||
const storages = this.$store.getters[`${ inStore }/all`](STORAGE_CLASS); | ||
|
||
return storages.filter((s) => !s.isEncrypted); | ||
}, | ||
|
||
storageClassOptions() { | ||
const storages = this.value.spec?.securityParameters?.cryptoOperation === ENCRYPT ? this.encryptedStorageClasses : this.nonEncryptedStorageClasses; | ||
|
||
return storages | ||
.filter((s) => !s.parameters?.backingImage && s.provisioner !== LVM_DRIVER) // Lvm storage is not supported. | ||
.map((s) => { | ||
|
@@ -239,6 +251,13 @@ export default { | |
this.$refs.file.value = null; | ||
} | ||
}, | ||
'value.spec.securityParameters.cryptoOperation'() { | ||
if (this.value.spec?.securityParameters?.cryptoOperation === ENCRYPT) { | ||
this.storageClassName = this.encryptedStorageClasses[0]?.name || LONGHORN; | ||
} else { // URL / FILE / DECRYPT should use default storage class | ||
this.storageClassName = this.defaultStorageClassName(); | ||
} | ||
} | ||
}, | ||
|
||
methods: { | ||
|
@@ -385,6 +404,14 @@ export default { | |
return str.toLowerCase().includes(os.value.toLowerCase()) ? os.value : false; | ||
} | ||
}); | ||
}, | ||
|
||
defaultStorageClassName() { | ||
const inStore = this.$store.getters['currentProduct'].inStore; | ||
const defaultStorage = this.$store.getters[`${ inStore }/all`](STORAGE_CLASS).find((s) => s.isDefault); | ||
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. fallback to 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 idea. If there is no default SC, we can fallback to longhorn. |
||
|
||
// if default sc is encrypted, use longhorn as default | ||
return defaultStorage.isEncrypted ? LONGHORN : defaultStorage?.metadata?.name; | ||
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. Is there any chance that 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. Longhorn sc can be deleted from UI. But backend won't actually delete it. 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. That was actually deleted but soon was recreated by someone... |
||
} | ||
}, | ||
}; | ||
|
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 use
this.value.metadata.annotations[HCI_ANNOTATIONS.STORAGE_CLASS]
to retrieve thestorageClassName
on line 177.Is this value always be the same of
this.$store.getters[${ inStore }/all](STORAGE_CLASS).find((s) => s.isDefault)
?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.
updated in 6e9350e