Skip to content

Commit

Permalink
fix: Fix resourceVersion conflict when put resource
Browse files Browse the repository at this point in the history
Signed-off-by: leoliu <leoliu@yunify.com>
  • Loading branch information
leoliu committed Jul 21, 2020
1 parent af2987e commit b280ae1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
9 changes: 7 additions & 2 deletions src/stores/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* along with KubeSphere Console. If not, see <https://www.gnu.org/licenses/>.
*/

import { get } from 'lodash'
import { get, set } from 'lodash'
import { action, observable } from 'mobx'
import ObjectMapper from 'utils/object.mapper'

Expand Down Expand Up @@ -203,7 +203,12 @@ export default class BaseStore {
}

@action
update(params, newObject) {
async update(params, newObject) {
const result = await require.get(this.getDetailUrl(params))
const resourceVersion = get(result, 'metadata.resourceVersion')
if (resourceVersion) {
set(newObject, 'metadata.resourceVersion', resourceVersion)
}
return this.submitting(request.put(this.getDetailUrl(params), newObject))
}

Expand Down
11 changes: 0 additions & 11 deletions src/stores/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,17 +157,6 @@ export default class ServiceStore extends Base {
return this.submitting(withDryRun(requests))
}

@action
update({ name, cluster, namespace, resourceVersion }, newObject) {
if (!has(newObject, 'metadata.resourceVersion')) {
set(newObject, 'metadata.resourceVersion', resourceVersion)
}

return this.submitting(
request.put(this.getDetailUrl({ name, cluster, namespace }), newObject)
)
}

@action
async fetchWorkload({ cluster, namespace, ...params }) {
const workloadTypes = ['deployments', 'statefulsets']
Expand Down

0 comments on commit b280ae1

Please sign in to comment.