Skip to content

Commit

Permalink
infosync: omit the 404 error when /config/placement-rule is not exist…
Browse files Browse the repository at this point in the history
…ed (#21247)

Signed-off-by: Ryan Leung <rleungx@gmail.com>
  • Loading branch information
rleungx authored Nov 26, 2020
1 parent 2f79d6c commit f7f48e3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
7 changes: 0 additions & 7 deletions domain/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
"github.com/pingcap/tidb/bindinfo"
"github.com/pingcap/tidb/config"
"github.com/pingcap/tidb/ddl"
"github.com/pingcap/tidb/ddl/placement"
ddlutil "github.com/pingcap/tidb/ddl/util"
"github.com/pingcap/tidb/domain/infosync"
"github.com/pingcap/tidb/errno"
Expand Down Expand Up @@ -150,12 +149,6 @@ func (do *Domain) loadInfoSchema(handle *infoschema.Handle, usedSchemaVersion in
}

bundles, err := infosync.GetAllRuleBundles(nil)
failpoint.Inject("FailPlacement", func(val failpoint.Value) {
if val.(bool) {
bundles = []*placement.Bundle{}
err = nil
}
})
if err != nil {
return 0, nil, fullLoad, err
}
Expand Down
4 changes: 2 additions & 2 deletions domain/domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func unixSocketAvailable() bool {
}

func TestInfo(t *testing.T) {
err := failpoint.Enable("github.com/pingcap/tidb/domain/FailPlacement", `return(true)`)
err := failpoint.Enable("github.com/pingcap/tidb/domain/infosync/FailPlacement", `return(true)`)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -230,7 +230,7 @@ func TestInfo(t *testing.T) {
t.Fatalf("dom.refreshServerIDTTL err %v", err)
}

err = failpoint.Disable("github.com/pingcap/tidb/domain/FailPlacement")
err = failpoint.Disable("github.com/pingcap/tidb/domain/infosync/FailPlacement")
if err != nil {
t.Fatal(err)
}
Expand Down
9 changes: 7 additions & 2 deletions domain/infosync/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,15 +330,20 @@ func doRequest(ctx context.Context, addrs []string, route, method string, body i
}

res, err = util2.InternalHTTPClient().Do(req)
failpoint.Inject("FailPlacement", func(val failpoint.Value) {
if val.(bool) {
res = &http.Response{StatusCode: http.StatusNotFound, Body: http.NoBody}
err = nil
}
})
if err == nil {
bodyBytes, err := ioutil.ReadAll(res.Body)
if err != nil {
return nil, err
}
if res.StatusCode != http.StatusOK {
err = errors.Errorf("%s", bodyBytes)
// ignore if placement rules feature is not enabled
if strings.HasPrefix(err.Error(), `"placement rules feature is disabled"`) {
if res.StatusCode == http.StatusNotFound || res.StatusCode == http.StatusPreconditionFailed {
err = nil
bodyBytes = nil
}
Expand Down

0 comments on commit f7f48e3

Please sign in to comment.