Skip to content

Commit

Permalink
improve compatability with outdated versions of elasticsearch
Browse files Browse the repository at this point in the history
  • Loading branch information
cars10 committed Aug 13, 2023
1 parent 435bca2 commit ff15f7b
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"build": {
"distDir": "../dist",
"devPath": "http://localhost:5173",
"beforeDevCommand": "",
"beforeDevCommand": "npx cross-env VITE_APP_BUILD_MODE=tauri yarn dev",
"beforeBuildCommand": "npx cross-env VITE_APP_BUILD_MODE=tauri yarn build"
},
"tauri": {
Expand Down
7 changes: 5 additions & 2 deletions src/components/clusterselection/ClusterSelection.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<template>
<q-btn color="dark-grey" no-caps :title="btnTitle" data-testid="cluster-selection">
<q-btn color="dark-grey" no-caps data-testid="cluster-selection">
<cluster-status-indicator :status="connectionStore.activeCluster?.status"
:loading="connectionStore.activeCluster?.loading" />
<span class="ellipsis" style="max-width: 200px">{{ connectionStore.activeCluster?.name }}</span>
<unsupported-version :major-version="connectionStore.activeCluster?.majorVersion" size="16px" class="q-mr-sm" />
<span class="ellipsis" style="max-width: 200px" :title="btnTitle">{{ connectionStore.activeCluster?.name }}</span>
<q-icon :name="menuOpen ? 'expand_less' : 'expand_more'" />
Expand All @@ -22,6 +24,7 @@
import { useTranslation } from '../../composables/i18n'
import { useClusterHealth } from '../../composables/components/home/ClusterHealth.ts'
import { useConnectionStore } from '../../store/connection'
import UnsupportedVersion from './UnsupportedVersion.vue'
const t = useTranslation()
const connectionStore = useConnectionStore()
Expand Down
15 changes: 3 additions & 12 deletions src/components/clusterselection/ClusterTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,7 @@
<td class="small-wrap">
<div class="flex items-center no-wrap">
{{ row.version }}
<q-icon v-if="!SUPPORTED_MAJOR_VERSIONS.includes(row.majorVersion)" name="warning" color="warning"
class="q-pl-xs">
<q-tooltip class="bg-dark text-body2">
{{
t('cluster_selection.cluster_table.row.unsupported', {
majorVersion: row.majorVersion,
supportedVersions: SUPPORTED_MAJOR_VERSIONS.join(", ")
})
}}
</q-tooltip>
</q-icon>
<unsupported-version :major-version="row.majorVersion" />
</div>
</td>
<td class="small-wrap">
Expand All @@ -74,11 +64,12 @@
import EditCluster from './EditCluster.vue'
import FilterInput from '../shared/FilterInput.vue'
import NewCluster from './NewCluster.vue'
import { DEFAULT_ROWS_PER_PAGE, SUPPORTED_MAJOR_VERSIONS } from '../../consts'
import { DEFAULT_ROWS_PER_PAGE } from '../../consts'
import { useClusterTable } from '../../composables/components/clusterselection/ClusterTable'
import { useConnectionStore } from '../../store/connection'
import { useTranslation } from '../../composables/i18n.ts'
import ClusterStatusIndicator from './ClusterStatusIndicator.vue'
import UnsupportedVersion from './UnsupportedVersion.vue'
const t = useTranslation()
const connectionStore = useConnectionStore()
Expand Down
22 changes: 22 additions & 0 deletions src/components/clusterselection/UnsupportedVersion.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<template>
<q-icon v-if="!SUPPORTED_MAJOR_VERSIONS.includes(majorVersion)" name="warning" color="warning"
class="q-pl-xs">
<q-tooltip class="bg-dark text-body2">
{{
t('cluster_selection.cluster_table.row.unsupported', {
majorVersion: majorVersion,
supportedVersions: SUPPORTED_MAJOR_VERSIONS.join(", ")
})
}}
</q-tooltip>
</q-icon>
</template>

<script setup lang="ts">
import { SUPPORTED_MAJOR_VERSIONS } from '../../consts'
import { useTranslation } from '../../composables/i18n'
const t = useTranslation()
defineProps<{ majorVersion: string }>()
</script>
4 changes: 3 additions & 1 deletion src/components/home/HomeStatus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<q-card v-if="data" class="full-height" data-testid="cluster-status">
<q-card-section>
<h3 class="text-h6 q-my-none">{{ data.cluster_name }}</h3>
<span class="text-muted font-13">{{ data.cluster_uuid }}</span>
<span class="text-muted font-13">{{ connectionStore.activeCluster.uuid }}</span>
</q-card-section>
<q-card-section class="items-center justify-between flex">
<div :class="`text-h6 inline-block health--${data.status}`">
Expand Down Expand Up @@ -86,6 +86,8 @@
import ClusterHealth from './ClusterHealth.vue'
import ClusterInformation from './ClusterInformation.vue'
import UnhealthyReason from './UnhealthyReason.vue'
import { useConnectionStore } from '../../store/connection.ts'
const connectionStore = useConnectionStore()

type ClusterStats = {
cluster_name: string
Expand Down
10 changes: 8 additions & 2 deletions src/components/nodes/ClusterNodes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,11 @@
import { useElasticsearchRequest } from '../../composables/CallElasticsearch'
import { useTranslation } from '../../composables/i18n'
import { EsNode } from '../../types/types.ts'
import { useConnectionStore } from '../../store/connection.ts'
const t = useTranslation()
const connectionStore = useConnectionStore()
const CAT_METHOD_PARAMS = {
h: [
'ip',
Expand All @@ -84,8 +87,11 @@
'disk.used_percent',
'disk.used',
'disk.total'
],
full_id: true
]
}
if (connectionStore.activeCluster && connectionStore.activeCluster.majorVersion > 5) {
CAT_METHOD_PARAMS.full_id = true
}
const { load, requestState, data } = useElasticsearchRequest<EsNode[]>('catNodes', CAT_METHOD_PARAMS)
Expand Down
12 changes: 7 additions & 5 deletions src/components/nodes/NodesTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@
<node-percent-progress :value="row.heapPercent" class="q-mt-xs" />
</td>
<td>
<div class="flex justify-between">
<small>{{ row.diskPercent }}%</small>
<small>{{ row.diskCurrent }}/{{ row.diskMax }}</small>
</div>
<node-percent-progress :value="row.diskPercent" class="q-mt-xs" />
<template v-if="row.diskPercent">
<div class="flex justify-between">
<small>{{ row.diskPercent }}%</small>
<small>{{ row.diskCurrent }}/{{ row.diskMax }}</small>
</div>
<node-percent-progress :value="row.diskPercent" class="q-mt-xs" />
</template>
</td>
</tr>
</template>
Expand Down
11 changes: 9 additions & 2 deletions src/composables/ClusterConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ export const useClusterConnection = (cluster: Ref<ElasticsearchCluster>) => {
uri,
clusterName: infoJson.cluster_name,
version: infoJson.version.number,
majorVersion: parseInt(infoJson.version.number[0]),
uuid: infoJson.cluster_uuid,
majorVersion: infoJson.version.number[0],
uuid: clusterUuid(infoJson),
status: clusterHealthBody.status
})

Expand Down Expand Up @@ -109,3 +109,10 @@ export const useClusterConnection = (cluster: Ref<ElasticsearchCluster>) => {
formValid
}
}

const clusterUuid = (infoJson: any) => {
if (infoJson.cluster_uuid) return infoJson.cluster_uuid

// fallback for elasticsearch < 5
return `${infoJson.cluster_name}-${infoJson.version.number}-${infoJson.version.build_hash}`.replaceAll(/\s/g, '')
}
2 changes: 1 addition & 1 deletion src/composables/components/home/ClusterHealth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const checkHealth = async (cluster: ElasticsearchCluster) => {
cluster.clusterName = pingBody.cluster_name
cluster.version = version
cluster.majorVersion = version[0]
cluster.uuid = pingBody.cluster_uuid
if (pingBody.cluster_uuid) cluster.uuid = pingBody.cluster_uuid

delete cluster.loading
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"remove_cluster": {
"confirm": "Remove cluster '{name}' ({uri})?"
},
"unsupported": "Elasticsearch {majorVersion} is not officially supported by elasticvue. Only elasticsearch versions {supportedVersions} are supported."
"unsupported": "Elasticsearch {majorVersion} is not supported by elasticvue. Only versions {supportedVersions} are supported. You may encounter bugs and limited functionality."
}
},
"edit_cluster": {
Expand Down

0 comments on commit ff15f7b

Please sign in to comment.