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

[release-3.4] fix: HPA api response 404 #4251

Merged
Show file tree
Hide file tree
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
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