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

cluster: validate topo changes after edit-config #609

Merged
merged 6 commits into from
Jul 21, 2020

Conversation

AstroProfundis
Copy link
Contributor

What problem does this PR solve?

add validation for topology diff to forbid changes of immutable fields

Check List

Tests

  • Unit test

Code changes

  • Has exported function/method change
  • Has exported variable/fields change

Side effects

  • Possible performance regression
  • Increased code complexity

Related changes

  • Need to cherry-pick to the release branch

@AstroProfundis AstroProfundis added type/new-feature Categorizes pr as related to a new feature. status/WIP category/testing Categorizes issue or PR as a testing enhancement. category/stability Categorizes issue or PR as a stability enhancement. labels Jul 17, 2020
@AstroProfundis AstroProfundis self-assigned this Jul 17, 2020
@AstroProfundis AstroProfundis force-pushed the edit-config-validate branch 2 times, most recently from 7f6e6f9 to eaad121 Compare July 20, 2020 10:44
@codecov-commenter
Copy link

codecov-commenter commented Jul 20, 2020

Codecov Report

Merging #609 into master will increase coverage by 0.14%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #609      +/-   ##
==========================================
+ Coverage   51.20%   51.34%   +0.14%     
==========================================
  Files         225      225              
  Lines       16573    16593      +20     
==========================================
+ Hits         8486     8520      +34     
+ Misses       6901     6888      -13     
+ Partials     1186     1185       -1     
Flag Coverage Δ
#coverage 51.34% <ø> (+0.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...c/github.com/pingcap/tiup/pkg/cluster/edit/diff.go 89.18% <0.00%> (-10.82%) ⬇️
...om/pingcap/tiup/pkg/repository/v1manifest/types.go 80.00% <0.00%> (-3.64%) ⬇️
...cap/tiup/components/cluster/command/edit_config.go 44.44% <0.00%> (-1.46%) ⬇️
...b.com/pingcap/tiup/pkg/repository/remote/modify.go 0.00% <0.00%> (ø)
go/src/github.com/pingcap/tiup/cmd/mirror.go 39.95% <0.00%> (+0.09%) ⬆️
...c/github.com/pingcap/tiup/pkg/cluster/api/pdapi.go 60.24% <0.00%> (+2.48%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9d5f96e...76aa890. Read the comment docs.

@AstroProfundis AstroProfundis marked this pull request as ready for review July 21, 2020 03:28
pkg/cluster/edit/diff.go Outdated Show resolved Hide resolved
pathEditable := true
pathIgnore := false
for _, p := range c.Path {
if _, err := strconv.Atoi(p); err == nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we cannot ignore the slice, for example, user add a new host into tidb_servers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tidb_servers is not ignored, server_configs.tidb is.

continue
}
}
msg = append(msg, fmt.Sprintf("(%s) %s '%v' -> '%v'", c.Type, strings.Join(c.Path, "."), c.From, c.To))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should generate more readable error message. e.g:

  1. update: cannot change the xxx field from 1 to 2
  2. delete: cannot delete the field xxx
  3. create: cannot add the field xxx into yyy

@ti-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 21, 2020
@lonng
Copy link
Contributor

lonng commented Jul 21, 2020

/merge

@ti-srebot ti-srebot added the status/can-merge Indicates a PR has been approved by a committer. label Jul 21, 2020
@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot ti-srebot merged commit 8c8b3f1 into pingcap:master Jul 21, 2020
@AstroProfundis AstroProfundis deleted the edit-config-validate branch July 22, 2020 03:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category/stability Categorizes issue or PR as a stability enhancement. category/testing Categorizes issue or PR as a testing enhancement. status/can-merge Indicates a PR has been approved by a committer. status/LGT1 Indicates that a PR has LGTM 1. type/new-feature Categorizes pr as related to a new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants