-
Notifications
You must be signed in to change notification settings - Fork 51
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
Feature/add ti resources #21
Conversation
Merge upstream master
3a19635
to
ed35e60
Compare
@petoju sorry for pinging, could you please take a look?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@borissavelev sorry, I was on vacation for this week and I plan being on one in the next week.
Except for some details, it looks reasonably well. I can still merge it if I get reasonable replies or changes.
GNUmakefile
Outdated
@@ -52,12 +54,21 @@ testpercona: | |||
testtidb%: | |||
$(MAKE) MYSQL_VERSION=$* MYSQL_PORT=34$(shell echo "$*" | tr -d '.') testtidb | |||
|
|||
testtidb: | |||
-docker run --rm --name test-tidb$(MYSQL_VERSION) -d -p $(MYSQL_PORT):4000 pingcap/tidb:v$(MYSQL_VERSION) | |||
bin/tiup: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we do the same in Docker?
Your approach forces you to start considering arch, runs with nohup
, depends on some mirror without chance to cache it, there may be potentially be issues with binary compatibility on newer GLIBC and so on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, its possible with version 4.0 as described here. But its not straight forward setup as tiup does.
Starting from version 5.0 docker is not anymore supported method pulling up the cluster.
This tool is needed only for acceptance testing. I'll glue it to am64 arch only. (similar like terraform binary fetch).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pingcap still publishes the docker-compose config: https://github.com/pingcap/tidb-docker-compose - but I admit it may be more complicated.
Still, if we don't want to use that - why should it run under nohup
? Should it be left running in the background?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced tiup with minimal docker setup. PTAL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks good. There is a minor issue there and I have / already had few more questions (replying you considered those is good enough for me). After that is done, I can merge it.
mysql/resource_ti_config_variable.go
Outdated
if isNumeric(varValue) { | ||
configQuery = fmt.Sprintf("%s %s", configQuery, varValue) | ||
} else { | ||
configQuery = fmt.Sprintf("%s'%s'", configQuery, varValue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if varValue
contains apostrophes? Even spitting out a warning is better than nothing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is an example If subsystem doesn't accept apostrophes
mysql> set config pd
log.level="
warn`";
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> show warnings;
+---------+------+---------------------------------------------------------------------------------------+
| Level | Code | Message |
+---------+------+---------------------------------------------------------------------------------------+
| Warning | 1105 | bad request to http://127.0.0.1:2379/pd/api/v1/config: "log level warn
is illegal"
|
+---------+------+---------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
`
It will be later rejected by warning check.
I'll add extra logging about this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, my question was maybe laid incorrectly.
Can it happen, that some value will contain apostrophe = '
character? In that case, your SQL will be invalid. BTW your new check for backticks `
seems to be broken (like it will warn almost every single time).
For example, is it possible or likely, that a human will want to set some value to something'somethingelse
? If that is possible, then we should certainly add some escaping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for pointing out this. I added validator for this.
func testAccConfigVarConfig_withInstanceAndType(varName string, varValue string, varType string, varInstance string) string { | ||
return fmt.Sprintf(` | ||
resource "mysql_ti_config" "test" { | ||
name = "%s" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indent it please.
mysql/resource_ti_config_variable.go
Outdated
d.Set("value", defaultValue.String()) | ||
|
||
return CreateOrUpdateConfigVariable(d, meta) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No newline after return, please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
mysql/resource_ti_config_variable.go
Outdated
configQuery = fmt.Sprintf("SET CONFIG \"%s\" %s=", varInstance, quoteIdentifier(varName)) | ||
} | ||
|
||
if isNumeric(varValue) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't sound right. For DBs respecting data types, it depends on the type of key. Type of value may help (maybe that's your approximation), but it doesn't always work.
Doesn't TiDB respect it (like MySQL) in case you quote everything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
L64:
If instance is in place then it requires extra quoting like in the example
set config "127.0.0.1:20180"
split.qps-threshold=1000
Everything else should be configured like this
set config tikv
split.qps-threshold=1000
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
L64: If instance is in place then it requires extra quoting like in the example
set config "127.0.0.1:20180" `split.qps-threshold`=1000
Everything else should be configured like this
set config tikv `split.qps-threshold`=1000
We don't understand each other - is it bad, if you quote it like this?
set config tikv `split.qps-threshold`='1000'
I believe it would be also acceptable and it would make it a bit easier to understand, but I'd leave it up to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it 😀 Thank you 👍
Removed obsolete code
GNUmakefile
Outdated
@@ -52,12 +54,21 @@ testpercona: | |||
testtidb%: | |||
$(MAKE) MYSQL_VERSION=$* MYSQL_PORT=34$(shell echo "$*" | tr -d '.') testtidb | |||
|
|||
testtidb: | |||
-docker run --rm --name test-tidb$(MYSQL_VERSION) -d -p $(MYSQL_PORT):4000 pingcap/tidb:v$(MYSQL_VERSION) | |||
bin/tiup: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks good. There is a minor issue there and I have / already had few more questions (replying you considered those is good enough for me). After that is done, I can merge it.
If I understood correctly, everything should be fixed now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now - thanks.
I'm not merging it yet as you requested a rebase.
80767d3
to
4297527
Compare
Thank you!🙏 Now its clean. All acceptance tests passed and we are 🟢 to merge it. |
This commit will add dynamic TiKV and PD resource handling with TiDB cluster and closes issue #15
All supported TiKV and PD configuration parameters are described here