Skip to content

Commit

Permalink
fix: HPA api response 404 (#4249)
Browse files Browse the repository at this point in the history
fix: hpa api response 404

Signed-off-by: donniean <acmilank22@gmail.com>
  • Loading branch information
donniean committed Nov 6, 2023
1 parent ad6b4c4 commit bf799bc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions server/services/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ const getKSConfig = async token => {
resp = { ...config }
if (version) {
resp.ksVersion = version.gitVersion
resp.k8sVersion = get(version, 'kubernetes.gitVersion')
}
} catch (error) {
console.error(error)
Expand Down
18 changes: 18 additions & 0 deletions src/stores/workload/hpa.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,31 @@

import { action } from 'mobx'

import { compareVersion } from 'utils'
import { API_VERSIONS } from 'utils/constants'
import { getHpaFormattedData } from 'utils/workload'

import Base from '../base'

const VERSION = 'v1.23.0'

export default class HpaStore extends Base {
module = 'horizontalpodautoscalers'

get apiVersion() {
const k8sVersion = globals?.ksConfig?.k8sVersion
const result = compareVersion(VERSION, k8sVersion)
let module = ''

if (result > 0) {
module = 'horizontalpodautoscalers_outdated'
} else {
module = this.module
}

return API_VERSIONS[module] || ''
}

@action
create(data, params) {
return this.submitting(
Expand Down
1 change: 1 addition & 0 deletions src/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,7 @@ export const API_VERSIONS = {
strategies: 'apis/servicemesh.kubesphere.io/v1alpha2',
servicepolicies: 'apis/servicemesh.kubesphere.io/v1alpha2',
horizontalpodautoscalers: 'apis/autoscaling/v2',
horizontalpodautoscalers_outdated: 'apis/autoscaling/v2beta2',
customresourcedefinitions: 'apis/apiextensions.k8s.io/v1',
clusters: 'apis/cluster.kubesphere.io/v1alpha1',
workspaces: 'apis/tenant.kubesphere.io/v1alpha2',
Expand Down
1 change: 0 additions & 1 deletion src/utils/workload.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ export const getHpaFormattedData = (formData = {}) => {
: []

const data = merge(formData, {
apiVersion: 'autoscaling/v2',
kind: 'HorizontalPodAutoscaler',
metadata: {
annotations: {
Expand Down

0 comments on commit bf799bc

Please sign in to comment.