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

Take image virtual size into account when creating Volumes (backport #1113) #1144

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions pkg/harvester/edit/harvesterhci.io.volume.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export default {
const hash = await allHash(_hash);

this.snapshots = hash.snapshots;
this.images = hash.images;

const defaultStorage = this.$store.getters[`harvester/all`](STORAGE_CLASS).find( O => O.isDefault);

Expand All @@ -77,6 +78,7 @@ export default {
storage,
imageId,
snapshots: [],
images: [],
};
},

Expand Down Expand Up @@ -108,10 +110,8 @@ export default {
},

imageOption() {
const choices = this.$store.getters['harvester/all'](HCI.IMAGE);

return sortBy(
choices
this.images
.filter(obj => obj.isReady)
.map((obj) => {
return {
Expand Down Expand Up @@ -249,7 +249,17 @@ export default {

this.$set(this.value, 'spec', spec);
},
updateImage() {
if (this.isVMImage && this.imageId) {
const imageResource = this.images?.find(image => this.imageId === image.id);
const imageSize = Math.max(imageResource?.status?.size, imageResource?.status?.virtualSize);

if (imageSize) {
this.storage = `${ Math.ceil(imageSize / 1024 / 1024 / 1024) }Gi`;
}
}
this.update();
},
generateYaml() {
const out = saferDump(this.value);

Expand Down Expand Up @@ -300,7 +310,7 @@ export default {
required
:mode="mode"
class="mb-20"
@input="update"
@input="updateImage"
/>

<LabeledSelect
Expand Down
Loading