Skip to content

Commit

Permalink
Merge pull request #1188 from harvester/mergify/bp/release-harvester-…
Browse files Browse the repository at this point in the history
…v1.4/pr-1186

Host local storage support, enhancements (backport #1186)
  • Loading branch information
torchiaf authored Oct 8, 2024
2 parents 1347413 + 4cdc4e5 commit 9da62be
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 44 deletions.
4 changes: 3 additions & 1 deletion pkg/harvester/edit/harvesterhci.io.storage/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Loading from '@shell/components/Loading';
import { _CREATE, _VIEW } from '@shell/config/query-params';
import { mapFeature, UNSUPPORTED_STORAGE_DRIVERS } from '@shell/store/features';
import { STORAGE_CLASS, LONGHORN } from '@shell/config/types';
import { STORAGE_CLASS, LONGHORN, SECRET, NAMESPACE } from '@shell/config/types';
import { CSI_DRIVER } from '../../types';
import { allHash } from '@shell/utils/promise';
import { clone } from '@shell/utils/object';
Expand Down Expand Up @@ -122,6 +122,8 @@ export default {
const inStore = this.$store.getters['currentProduct'].inStore;
await allHash({
namespaces: this.$store.dispatch(`${ inStore }/findAll`, { type: NAMESPACE }),
secrets: this.$store.dispatch(`${ inStore }/findAll`, { type: SECRET }),
storages: this.$store.dispatch(`${ inStore }/findAll`, { type: STORAGE_CLASS }),
longhornNodes: this.$store.dispatch(`${ inStore }/findAll`, { type: LONGHORN.NODES }),
csiDrivers: this.$store.dispatch(`${ inStore }/findAll`, { type: CSI_DRIVER }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import KeyValue from '@shell/components/form/KeyValue';
import LabeledSelect from '@shell/components/form/LabeledSelect';
import { LabeledInput } from '@components/Form/LabeledInput';
import RadioGroup from '@components/Form/Radio/RadioGroup';
import { SECRET, NAMESPACE, LONGHORN } from '@shell/config/types';
import { SECRET, LONGHORN } from '@shell/config/types';
import { _CREATE, _VIEW } from '@shell/config/query-params';
import { CSI_SECRETS } from '@pkg/harvester/config/harvester-map';
import { clone } from '@shell/utils/object';
Expand Down Expand Up @@ -55,16 +55,6 @@ export default {
},
},
async fetch() {
const inStore = this.$store.getters['currentProduct'].inStore;
await this.$store.dispatch(`${ inStore }/findAll`, { type: NAMESPACE });
const allSecrets = await this.$store.dispatch(`${ inStore }/findAll`, { type: SECRET });
// only show non-system secret to user to select
this.secrets = allSecrets.filter(secret => secret.isSystem === false);
},
data() {
if (this.realMode === _CREATE) {
this.$set(this.value, 'parameters', {
Expand All @@ -78,9 +68,19 @@ export default {
});
}
return { secrets: [] };
return { };
},
computed: {
secrets() {
const inStore = this.$store.getters['currentProduct'].inStore;
const allSecrets = this.$store.getters[`${ inStore }/all`](SECRET);
// only show non-system secret to user to select
return allSecrets.filter(secret => secret.isSystem === false);
},
longhornNodes() {
const inStore = this.$store.getters['currentProduct'].inStore;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import KeyValue from '@shell/components/form/KeyValue';
import LabeledSelect from '@shell/components/form/LabeledSelect';
import { LabeledInput } from '@components/Form/LabeledInput';
import RadioGroup from '@components/Form/Radio/RadioGroup';
import { SECRET, NAMESPACE, LONGHORN } from '@shell/config/types';
import { SECRET, LONGHORN } from '@shell/config/types';
import { _CREATE, _VIEW } from '@shell/config/query-params';
import { CSI_SECRETS } from '@pkg/harvester/config/harvester-map';
import { clone } from '@shell/utils/object';
Expand Down Expand Up @@ -55,16 +55,6 @@ export default {
},
},
async fetch() {
const inStore = this.$store.getters['currentProduct'].inStore;
await this.$store.dispatch(`${ inStore }/findAll`, { type: NAMESPACE });
const allSecrets = await this.$store.dispatch(`${ inStore }/findAll`, { type: SECRET });
// only show non-system secret to user to select
this.secrets = allSecrets.filter(secret => secret.isSystem === false);
},
data() {
if (this.realMode === _CREATE) {
this.$set(this.value, 'parameters', {
Expand All @@ -78,9 +68,19 @@ export default {
});
}
return { secrets: [] };
return { };
},
computed: {
secrets() {
const inStore = this.$store.getters['currentProduct'].inStore;
const allSecrets = this.$store.getters[`${ inStore }/all`](SECRET);
// only show non-system secret to user to select
return allSecrets.filter(secret => secret.isSystem === false);
},
longhornNodes() {
const inStore = this.$store.getters['currentProduct'].inStore;
Expand Down Expand Up @@ -322,6 +322,7 @@ export default {
:label="t('harvester.storage.volumeEncryption')"
:mode="mode"
:options="volumeEncryptionOptions"
:disabled="true"
/>
</div>
<div v-if="value.parameters.encrypted === 'true'" class="row mt-20">
Expand Down
12 changes: 12 additions & 0 deletions pkg/harvester/edit/harvesterhci.io.volume.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import ResourceTabs from '@shell/components/form/ResourceTabs';
import LabeledSelect from '@shell/components/form/LabeledSelect';
import { LabeledInput } from '@components/Form/LabeledInput';
import NameNsDescription from '@shell/components/form/NameNsDescription';
import { Banner } from '@components/Banner';
import { allHash } from '@shell/utils/promise';
import { get } from '@shell/utils/object';
Expand All @@ -21,11 +22,13 @@ import { HCI as HCI_ANNOTATIONS } from '@pkg/harvester/config/labels-annotations
import { STATE, NAME, AGE, NAMESPACE } from '@shell/config/table-headers';
import { LVM_DRIVER } from '../models/harvester/storage.k8s.io.storageclass';
import { DATA_ENGINE_V2 } from './harvesterhci.io.storage/index.vue';
import { LONGHORN_DRIVER } from '@shell/models/persistentvolume';
export default {
name: 'HarvesterVolume',
components: {
Banner,
Tab,
UnitInput,
CruResource,
Expand Down Expand Up @@ -219,6 +222,10 @@ export default {
rebuildStatus() {
return this.value.longhornEngine?.status?.rebuildStatus;
},
isLonghornV2() {
return this.value.storageClass?.provisioner === LONGHORN_DRIVER && this.value.storageClass?.longhornVersion === DATA_ENGINE_V2;
}
},
Expand Down Expand Up @@ -340,10 +347,15 @@ export default {
:output-modifier="true"
:increment="1024"
:mode="mode"
:disabled="isLonghornV2"
required
class="mb-20"
@input="update"
/>
<Banner v-if="isLonghornV2" color="warning">
<span>{{ t('harvester.volume.longhorn.disableResize') }}</span>
</Banner>
</Tab>
<Tab v-if="!isCreate" name="details" :label="t('harvester.volume.tabs.details')" :weight="2.5" class="bordered-table">
<LabeledInput v-model="frontendDisplay" class="mb-20" :mode="mode" :disabled="true" :label="t('harvester.volume.frontend')" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ import ModalWithCard from '@shell/components/ModalWithCard';
import { PVC } from '@shell/config/types';
import { HCI } from '../../../types';
import { clone } from '@shell/utils/object';
import { ucFirst, randomStr } from '@shell/utils/string';
import { removeObject } from '@shell/utils/array';
import { randomStr } from '@shell/utils/string';
import { SOURCE_TYPE } from '../../../config/harvester-map';
import { _VIEW, _EDIT, _CREATE } from '@shell/config/query-params';
import { PRODUCT_NAME as HARVESTER_PRODUCT } from '../../../config/harvester';
import { PLUGIN_DEVELOPER, DEV } from '@shell/store/prefs';
import { DATA_ENGINE_V2 } from '../../../edit/harvesterhci.io.storage/index.vue';
import { LONGHORN_DRIVER } from '@shell/models/persistentvolume';
export default {
components: {
Expand Down Expand Up @@ -80,6 +83,7 @@ export default {
data() {
return {
ucFirst,
SOURCE_TYPE,
rows: clone(this.value),
nameIdx: 1,
Expand Down Expand Up @@ -253,6 +257,10 @@ export default {
getImageDisplayName(id) {
return this.$store.getters['harvester/all'](HCI.IMAGE).find(image => image.id === id)?.spec?.displayName;
},
isLonghornV2(volume) {
return volume?.pvc?.storageClass?.provisioner === LONGHORN_DRIVER && volume?.pvc?.storageClass?.longhornVersion === DATA_ENGINE_V2;
}
},
};
Expand Down Expand Up @@ -327,7 +335,24 @@ export default {
</div>
</div>
<Banner v-if="volume.volumeStatus && !isCreate" class="mt-15 volume-status" color="warning" :label="volume.volumeStatus" />
<div class="mt-15">
<Banner
v-if="volume.volumeStatus && !isCreate"
class="volume-status"
color="warning"
:label="ucFirst(volume.volumeStatus)"
/>
<Banner
v-if="value.volumeBackups && value.volumeBackups.error && value.volumeBackups.error.message"
color="error"
:label="ucFirst(value.volumeBackups.error.message)"
/>
<Banner
v-if="isLonghornV2(volume) && !isView"
color="warning"
:label="t('harvester.volume.longhorn.disableResize')"
/>
</div>
</InfoBox>
</div>
</transition-group>
Expand Down Expand Up @@ -429,4 +454,8 @@ export default {
justify-content: center;
align-items: center;
}
.banner {
margin: 10px 0;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { formatSi, parseSi } from '@shell/utils/units';
import { VOLUME_TYPE, InterfaceOption } from '../../../../config/harvester-map';
import { _VIEW } from '@shell/config/query-params';
import { ucFirst } from '@shell/utils/string';
import { LONGHORN_DRIVER } from '@shell/models/persistentvolume';
import { DATA_ENGINE_V2 } from '../../../harvesterhci.io.storage/index.vue';
export default {
name: 'HarvesterEditVMImage',
Expand Down Expand Up @@ -112,6 +114,10 @@ export default {
return allPVCs.find((P) => {
return this.namespace ? P.id === `${ this.namespace }/${ this.value.volumeName }` : true;
});
},
isLonghornV2() {
return this.value.pvc?.storageClass?.provisioner === LONGHORN_DRIVER && this.value.pvc?.storageClass?.longhornVersion === DATA_ENGINE_V2;
}
},
Expand Down Expand Up @@ -278,6 +284,7 @@ export default {
:label="t('harvester.fields.size')"
:mode="mode"
:required="validateRequired"
:disable="isLonghornV2"
suffix="GiB"
@input="update"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import UnitInput from '@shell/components/form/UnitInput';
import InputOrDisplay from '@shell/components/InputOrDisplay';
import { LabeledInput } from '@components/Form/LabeledInput';
import LabeledSelect from '@shell/components/form/LabeledSelect';
import { Banner } from '@components/Banner';
import { PVC, STORAGE_CLASS } from '@shell/config/types';
import { formatSi, parseSi } from '@shell/utils/units';
import { VOLUME_TYPE, InterfaceOption } from '../../../../config/harvester-map';
Expand All @@ -13,11 +12,12 @@ import LabelValue from '@shell/components/LabelValue';
import { ucFirst } from '@shell/utils/string';
import { LVM_DRIVER } from '../../../../models/harvester/storage.k8s.io.storageclass';
import { DATA_ENGINE_V2 } from '../../../../edit/harvesterhci.io.storage/index.vue';
import { LONGHORN_DRIVER } from '@shell/models/persistentvolume';
export default {
name: 'HarvesterEditVolume',
components: {
InputOrDisplay, Loading, LabeledInput, LabeledSelect, UnitInput, LabelValue, Banner
InputOrDisplay, Loading, LabeledInput, LabeledSelect, UnitInput, LabelValue
},
props: {
Expand Down Expand Up @@ -101,6 +101,10 @@ export default {
};
}) || [];
},
isLonghornV2() {
return this.value.pvc?.storageClass?.provisioner === LONGHORN_DRIVER && this.value.pvc?.storageClass?.longhornVersion === DATA_ENGINE_V2;
}
},
watch: {
Expand Down Expand Up @@ -233,6 +237,7 @@ export default {
:mode="mode"
:required="validateRequired"
:label="t('harvester.fields.size')"
:disabled="isLonghornV2"
@input="update"
/>
</InputOrDisplay>
Expand Down Expand Up @@ -272,11 +277,5 @@ export default {
/>
</div>
</div>
<Banner
v-if="value.volumeBackups && value.volumeBackups.error && value.volumeBackups.error.message"
color="error"
class="mb-20"
:label="value.volumeBackups.error.message"
/>
</div>
</template>
2 changes: 2 additions & 0 deletions pkg/harvester/l10n/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,8 @@ harvester:
externalLink:
tips: Check volume details
rebuildingMessage: 'Rebuilding: {percentage}%'
longhorn:
disableResize: 'Longhorn V2 volumes cannot be resized.'

image:
label: Images
Expand Down
5 changes: 4 additions & 1 deletion pkg/harvester/list/harvesterhci.io.volume.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import ResourceTable from '@shell/components/ResourceTable';
import HarvesterVolumeState from '../formatters/HarvesterVolumeState';
import { allSettled } from '../utils/promise';
import { PV, PVC, SCHEMA, LONGHORN } from '@shell/config/types';
import {
PV, PVC, SCHEMA, LONGHORN, STORAGE_CLASS
} from '@shell/config/types';
import { HCI, VOLUME_SNAPSHOT } from '../types';
import { STATE, AGE, NAME, NAMESPACE } from '@shell/config/table-headers';
Expand All @@ -30,6 +32,7 @@ export default {
pvcs: this.$store.dispatch(`${ inStore }/findAll`, { type: PVC }),
pvs: this.$store.dispatch(`${ inStore }/findAll`, { type: PV }),
vms: this.$store.dispatch(`${ inStore }/findAll`, { type: HCI.VM }),
scs: this.$store.dispatch(`${ inStore }/findAll`, { type: STORAGE_CLASS }),
};
const volumeSnapshotSchema = this.$store.getters[`${ inStore }/schemaFor`](VOLUME_SNAPSHOT);
Expand Down
Loading

0 comments on commit 9da62be

Please sign in to comment.