Skip to content

Commit

Permalink
Merge branch 'pingcap:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
hackersean committed Apr 11, 2024
2 parents ed84e24 + 28927f8 commit 01de734
Show file tree
Hide file tree
Showing 31 changed files with 713 additions and 307 deletions.
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
TiUP Changelog

## [1.15.0] 2023-04-01

### New Features

- Support no-sudo mode in `tiup-cluster` (#2350 #2373, @Yujie-Xie)
- Add tidb-cse mode and remove tidb-disagg mode in `tiup-playground` (#2386, @breezewish)

### Fixes

- Fix can not set runtime config in config file specific by --tiflash.config in `tiup-playground` (#2346 #2383, @Lloyd-Pottiger)
- Fix not sanitize tiproxy component config when scale in in `tiup-playground` (#2365, @xhebox)
- Fix timeout when checking component upgrade in `tiup` (#2379, @KanShiori)
- Fix pdms grafana display in `tiup-playground` (#2382, @HuSharp)
- Fix not update prometheus config when scale in in `tiup-cluster` (#2387, @Yujie-Xie)

### Improvements

- Set the TiFlash logger level to DEBUG in `tiup-playground` (#2346, @Lloyd-Pottiger)
- Add integration tests for tiproxy in `tiup-cluster` (#2371, @xhebox)
- Set tiproxy addr without schema in `tiup-playground` (#2368, @xhebox)
- Only pull nightly from cluster version in `tiup-playground` (#2364, @xhebox)
- Skip tiproxy download & copy when upgrade in `tiup-cluster` (#2366, @xhebox)
- Auto set session certs if there is a tiproxy in `tiup-cluster` (#2374, @xhebox)
- Auto generate self-signed certs for TiProxy session migration in `tiup-playground` (#2372, @xhebox)
- Remove resource manager in `tiup-playground` (#2381, @rleungx)
- Add config advertise-addr to tiproxy spec in `tiup-cluster` and `tiup-playground` (#2392, @djshow832)

## [1.14.1] 2024-01-12

### Fixes
Expand Down
6 changes: 5 additions & 1 deletion cmd/mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,11 @@ func newMirrorRenewCmd() *cobra.Command {
if !v1manifest.IsExpirationError(perrs.Cause(err)) {
return err
}
fmt.Println(err)
fmt.Printf("Ignoring expiration error: %s", err)
}

if m == nil {
return errors.New("got nil manifest")
}

if days > 0 {
Expand Down
10 changes: 9 additions & 1 deletion components/playground/instance/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ type Config struct {
Version string `yaml:"version"`
}

// CSEOptions contains configs to run TiDB cluster in CSE mode.
type CSEOptions struct {
S3Endpoint string `yaml:"s3_endpoint"`
Bucket string `yaml:"bucket"`
AccessKey string `yaml:"access_key"`
SecretKey string `yaml:"secret_key"`
}

type instance struct {
ID int
Dir string
Expand Down Expand Up @@ -115,7 +123,7 @@ func logIfErr(err error) {
func pdEndpoints(pds []*PDInstance, isHTTP bool) []string {
var endpoints []string
for _, pd := range pds {
if pd.Role == PDRoleTSO || pd.Role == PDRoleScheduling || pd.Role == PDRoleResourceManager {
if pd.Role == PDRoleTSO || pd.Role == PDRoleScheduling {
continue
}
if isHTTP {
Expand Down
40 changes: 13 additions & 27 deletions components/playground/instance/pd.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ const (
PDRoleTSO PDRole = "tso"
// PDRoleScheduling is the role of PD scheduling
PDRoleScheduling PDRole = "scheduling"
// PDRoleResourceManager is the role of PD resource manager
PDRoleResourceManager PDRole = "resource_manager"
)

// PDInstance represent a running pd-server
Expand All @@ -48,10 +46,11 @@ type PDInstance struct {
joinEndpoints []*PDInstance
pds []*PDInstance
Process
isCSEMode bool
}

// NewPDInstance return a PDInstance
func NewPDInstance(role PDRole, binPath, dir, host, configPath string, id int, pds []*PDInstance, port int) *PDInstance {
func NewPDInstance(role PDRole, binPath, dir, host, configPath string, id int, pds []*PDInstance, port int, isCSEMode bool) *PDInstance {
if port <= 0 {
port = 2379
}
Expand All @@ -65,8 +64,9 @@ func NewPDInstance(role PDRole, binPath, dir, host, configPath string, id int, p
StatusPort: utils.MustGetFreePort(host, port),
ConfigPath: configPath,
},
Role: role,
pds: pds,
Role: role,
pds: pds,
isCSEMode: isCSEMode,
}
}

Expand Down Expand Up @@ -114,8 +114,8 @@ func (inst *PDInstance) Start(ctx context.Context, version utils.Version) error
fmt.Sprintf("--client-urls=http://%s", utils.JoinHostPort(inst.Host, inst.StatusPort)),
fmt.Sprintf("--advertise-client-urls=http://%s", utils.JoinHostPort(AdvertiseHost(inst.Host), inst.StatusPort)),
fmt.Sprintf("--log-file=%s", inst.LogFile()),
fmt.Sprintf("--config=%s", configPath),
}...)

switch {
case len(inst.initEndpoints) > 0:
endpoints := make([]string, 0)
Expand All @@ -142,9 +142,7 @@ func (inst *PDInstance) Start(ctx context.Context, version utils.Version) error
fmt.Sprintf("--advertise-listen-addr=http://%s", utils.JoinHostPort(AdvertiseHost(inst.Host), inst.StatusPort)),
fmt.Sprintf("--backend-endpoints=%s", strings.Join(endpoints, ",")),
fmt.Sprintf("--log-file=%s", inst.LogFile()),
}
if inst.ConfigPath != "" {
args = append(args, fmt.Sprintf("--config=%s", inst.ConfigPath))
fmt.Sprintf("--config=%s", configPath),
}
case PDRoleScheduling:
endpoints := pdEndpoints(inst.pds, true)
Expand All @@ -155,22 +153,7 @@ func (inst *PDInstance) Start(ctx context.Context, version utils.Version) error
fmt.Sprintf("--advertise-listen-addr=http://%s", utils.JoinHostPort(AdvertiseHost(inst.Host), inst.StatusPort)),
fmt.Sprintf("--backend-endpoints=%s", strings.Join(endpoints, ",")),
fmt.Sprintf("--log-file=%s", inst.LogFile()),
}
if inst.ConfigPath != "" {
args = append(args, fmt.Sprintf("--config=%s", inst.ConfigPath))
}
case PDRoleResourceManager:
endpoints := pdEndpoints(inst.pds, true)
args = []string{
"services",
"resource-manager",
fmt.Sprintf("--listen-addr=http://%s", utils.JoinHostPort(inst.Host, inst.StatusPort)),
fmt.Sprintf("--advertise-listen-addr=http://%s", utils.JoinHostPort(AdvertiseHost(inst.Host), inst.StatusPort)),
fmt.Sprintf("--backend-endpoints=%s", strings.Join(endpoints, ",")),
fmt.Sprintf("--log-file=%s", inst.LogFile()),
}
if inst.ConfigPath != "" {
args = append(args, fmt.Sprintf("--config=%s", inst.ConfigPath))
fmt.Sprintf("--config=%s", configPath),
}
}

Expand All @@ -186,14 +169,17 @@ func (inst *PDInstance) Start(ctx context.Context, version utils.Version) error

// Component return the component name.
func (inst *PDInstance) Component() string {
if inst.Role == PDRoleNormal {
if inst.Role == PDRoleNormal || inst.Role == PDRoleAPI {
return "pd"
}
return fmt.Sprintf("pd %s", inst.Role)
return string(inst.Role)
}

// LogFile return the log file.
func (inst *PDInstance) LogFile() string {
if inst.Role == PDRoleNormal || inst.Role == PDRoleAPI {
return filepath.Join(inst.Dir, "pd.log")
}
return filepath.Join(inst.Dir, fmt.Sprintf("%s.log", string(inst.Role)))
}

Expand Down
10 changes: 10 additions & 0 deletions components/playground/instance/pd_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,15 @@ package instance
func (inst *PDInstance) getConfig() map[string]any {
config := make(map[string]any)
config["schedule.patrol-region-interval"] = "100ms"

if inst.isCSEMode {
config["keyspace.pre-alloc"] = []string{"mykeyspace"}
config["replication.enable-placement-rules"] = true
config["replication.max-replica"] = 1
config["schedule.merge-schedule-limit"] = 0
config["schedule.low-space-ration"] = 1.0
config["schedule.replica-schedule-limit"] = 500
}

return config
}
14 changes: 8 additions & 6 deletions components/playground/instance/tidb.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ type TiDBInstance struct {
instance
pds []*PDInstance
Process
enableBinlog bool
isDisaggMode bool
tiproxyCertDir string
enableBinlog bool
isCSEMode bool
}

// NewTiDBInstance return a TiDBInstance
func NewTiDBInstance(binPath string, dir, host, configPath string, id, port int, pds []*PDInstance, enableBinlog bool, isDisaggMode bool) *TiDBInstance {
func NewTiDBInstance(binPath string, dir, host, configPath string, id, port int, pds []*PDInstance, tiproxyCertDir string, enableBinlog bool, isCSEMode bool) *TiDBInstance {
if port <= 0 {
port = 4000
}
Expand All @@ -48,9 +49,10 @@ func NewTiDBInstance(binPath string, dir, host, configPath string, id, port int,
StatusPort: utils.MustGetFreePort("0.0.0.0", 10080),
ConfigPath: configPath,
},
pds: pds,
enableBinlog: enableBinlog,
isDisaggMode: isDisaggMode,
tiproxyCertDir: tiproxyCertDir,
pds: pds,
enableBinlog: enableBinlog,
isCSEMode: isCSEMode,
}
}

Expand Down
43 changes: 42 additions & 1 deletion components/playground/instance/tidb_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,54 @@

package instance

import (
"os"
"path/filepath"
)

func (inst *TiDBInstance) getConfig() map[string]any {
config := make(map[string]any)
config["security.auto-tls"] = true

if inst.isDisaggMode {
if inst.isCSEMode {
config["keyspace-name"] = "mykeyspace"
config["enable-safe-point-v2"] = true
config["force-enable-vector-type"] = true
config["use-autoscaler"] = false
config["disaggregated-tiflash"] = true
config["ratelimit.full-speed"] = 1048576000
config["ratelimit.full-speed-capacity"] = 1048576000
config["ratelimit.low-speed-watermark"] = 1048576000000
config["ratelimit.block-write-watermark"] = 1048576000000
config["security.enable-sem"] = false
config["tiflash-replicas.constraints"] = []any{
map[string]any{
"key": "engine",
"op": "in",
"values": []string{
"tiflash",
},
},
map[string]any{
"key": "engine_role",
"op": "in",
"values": []string{
"write",
},
},
}
config["tiflash-replicas.group-id"] = "enable_s3_wn_region"
config["tiflash-replicas.extra-s3-rule"] = false
config["tiflash-replicas.min-count"] = 1
}

tiproxyCrtPath := filepath.Join(inst.tiproxyCertDir, "tiproxy.crt")
tiproxyKeyPath := filepath.Join(inst.tiproxyCertDir, "tiproxy.key")
_, err1 := os.Stat(tiproxyCrtPath)
_, err2 := os.Stat(tiproxyKeyPath)
if err1 == nil && err2 == nil {
config["security.session-token-signing-cert"] = tiproxyCrtPath
config["security.session-token-signing-key"] = tiproxyKeyPath
}

return config
Expand Down
15 changes: 3 additions & 12 deletions components/playground/instance/tiflash.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,11 @@ const (
TiFlashRoleDisaggCompute TiFlashRole = "compute"
)

// DisaggOptions contains configs to run TiFlash in disaggregated mode.
type DisaggOptions struct {
S3Endpoint string `yaml:"s3_endpoint"`
Bucket string `yaml:"bucket"`
AccessKey string `yaml:"access_key"`
SecretKey string `yaml:"secret_key"`
}

// TiFlashInstance represent a running TiFlash
type TiFlashInstance struct {
instance
Role TiFlashRole
DisaggOpts DisaggOptions
cseOpts CSEOptions
TCPPort int
ServicePort int
ProxyPort int
Expand All @@ -62,7 +54,7 @@ type TiFlashInstance struct {
}

// NewTiFlashInstance return a TiFlashInstance
func NewTiFlashInstance(role TiFlashRole, disaggOptions DisaggOptions, binPath, dir, host, configPath string, id int, pds []*PDInstance, dbs []*TiDBInstance, version string) *TiFlashInstance {
func NewTiFlashInstance(role TiFlashRole, cseOptions CSEOptions, binPath, dir, host, configPath string, id int, pds []*PDInstance, dbs []*TiDBInstance, version string) *TiFlashInstance {
if role != TiFlashRoleNormal && role != TiFlashRoleDisaggWrite && role != TiFlashRoleDisaggCompute {
panic(fmt.Sprintf("Unknown TiFlash role %s", role))
}
Expand All @@ -82,7 +74,7 @@ func NewTiFlashInstance(role TiFlashRole, disaggOptions DisaggOptions, binPath,
ConfigPath: configPath,
},
Role: role,
DisaggOpts: disaggOptions,
cseOpts: cseOptions,
TCPPort: utils.MustGetFreePort(host, 9100), // 9000 for default object store port
ServicePort: utils.MustGetFreePort(host, 3930),
ProxyPort: utils.MustGetFreePort(host, 20170),
Expand Down Expand Up @@ -153,7 +145,6 @@ func (inst *TiFlashInstance) Start(ctx context.Context, version utils.Version) e
if err != nil {
return errors.Trace(err)
}
fmt.Println("userConfig", userConfig)
for _, arg := range runtimeConfig {
// if user has set the config, skip it
if !isKeyPresentInMap(userConfig, arg[0]) {
Expand Down
41 changes: 28 additions & 13 deletions components/playground/instance/tiflash_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ func (inst *TiFlashInstance) getProxyConfig() map[string]any {
config["raftdb.max-open-files"] = 256
config["storage.reserve-space"] = 0
config["storage.reserve-raft-space"] = 0

if inst.Role == TiFlashRoleDisaggWrite {
config["storage.api-version"] = 2
config["storage.enable-ttl"] = true
config["dfs.prefix"] = "tikv"
config["dfs.s3-endpoint"] = inst.cseOpts.S3Endpoint
config["dfs.s3-key-id"] = inst.cseOpts.AccessKey
config["dfs.s3-secret-key"] = inst.cseOpts.SecretKey
config["dfs.s3-bucket"] = inst.cseOpts.Bucket
config["dfs.s3-region"] = "local"
}

return config
}

Expand All @@ -31,23 +43,26 @@ func (inst *TiFlashInstance) getConfig() map[string]any {
config["logger.level"] = "debug"

if inst.Role == TiFlashRoleDisaggWrite {
config["storage.s3.endpoint"] = inst.DisaggOpts.S3Endpoint
config["storage.s3.bucket"] = inst.DisaggOpts.Bucket
config["storage.s3.root"] = "/"
config["storage.s3.access_key_id"] = inst.DisaggOpts.AccessKey
config["storage.s3.secret_access_key"] = inst.DisaggOpts.SecretKey
config["enable_safe_point_v2"] = true
config["storage.api_version"] = 2
config["storage.s3.endpoint"] = inst.cseOpts.S3Endpoint
config["storage.s3.bucket"] = inst.cseOpts.Bucket
config["storage.s3.root"] = "/tiflash-cse/"
config["storage.s3.access_key_id"] = inst.cseOpts.AccessKey
config["storage.s3.secret_access_key"] = inst.cseOpts.SecretKey
config["storage.main.dir"] = []string{filepath.Join(inst.Dir, "main_data")}
config["flash.disaggregated_mode"] = "tiflash_write"
config["flash.use_autoscaler"] = false
} else if inst.Role == TiFlashRoleDisaggCompute {
config["storage.s3.endpoint"] = inst.DisaggOpts.S3Endpoint
config["storage.s3.bucket"] = inst.DisaggOpts.Bucket
config["storage.s3.root"] = "/"
config["storage.s3.access_key_id"] = inst.DisaggOpts.AccessKey
config["storage.s3.secret_access_key"] = inst.DisaggOpts.SecretKey
config["enable_safe_point_v2"] = true
config["storage.s3.endpoint"] = inst.cseOpts.S3Endpoint
config["storage.s3.bucket"] = inst.cseOpts.Bucket
config["storage.s3.root"] = "/tiflash-cse/"
config["storage.s3.access_key_id"] = inst.cseOpts.AccessKey
config["storage.s3.secret_access_key"] = inst.cseOpts.SecretKey
config["storage.remote.cache.dir"] = filepath.Join(inst.Dir, "remote_cache")
config["storage.remote.cache.capacity"] = 1000000000 // 1GB
config["storage.remote.cache.capacity"] = 20000000000 // 20GB
config["storage.main.dir"] = []string{filepath.Join(inst.Dir, "main_data")}
config["flash.disaggregated_mode"] = "tiflash_compute"
config["flash.use_autoscaler"] = false
}

return config
Expand Down
Loading

0 comments on commit 01de734

Please sign in to comment.