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

Embed mycnf files and init_db #5654

Merged
merged 5 commits into from
Jan 11, 2020
Merged

Conversation

morgo
Copy link
Contributor

@morgo morgo commented Jan 3, 2020

Fixes #5502

This embeds the my.cnf files for a MySQL flavor, as well as the init_db.sql file.

The examples have also been modified to search for vitess binaries in the PATH, and no longer specify an init-db file. They can now completely standalone from the vitess root, as long as the binaries are in the path:

$ mv examples/local ~/vitess-examples
$ cd ~/vitess-examples/
$ ./101_initial_cluster.sh 
add /vitess/global
add /vitess/zone1
add zone1 CellInfo
etcd start done...
Starting vtctld...
Access vtctld web UI at http://ryzen:15000
Send commands with: vtctlclient -server ryzen:15999 ...
Starting MySQL for tablet zone1-0000000100...
Starting MySQL for tablet zone1-0000000101...
Starting MySQL for tablet zone1-0000000102...
Starting vttablet for zone1-0000000100...
Access tablet zone1-0000000100 at http://ryzen:15100/debug/status
Starting vttablet for zone1-0000000101...
Access tablet zone1-0000000101 at http://ryzen:15101/debug/status
Starting vttablet for zone1-0000000102...
Access tablet zone1-0000000102 at http://ryzen:15102/debug/status
Waiting for tablets to be listening...
HTTP/1.1 200 OK
Date: Fri, 03 Jan 2020 23:45:04 GMT
Content-Type: text/html; charset=utf-8

HTTP/1.1 200 OK
Date: Fri, 03 Jan 2020 23:45:04 GMT
Content-Type: text/html; charset=utf-8

HTTP/1.1 200 OK
Date: Fri, 03 Jan 2020 23:45:04 GMT
Content-Type: text/html; charset=utf-8

Tablets up!
W0103 16:45:04.720428   19305 main.go:64] W0103 23:45:04.719741 reparent.go:185] master-elect tablet zone1-0000000100 is not the shard master, proceeding anyway as -force was used
W0103 16:45:04.720616   19305 main.go:64] W0103 23:45:04.720030 reparent.go:191] master-elect tablet zone1-0000000100 is not a master in the shard, proceeding anyway as -force was used
New VSchema object:
{
  "tables": {
    "corder": {

    },
    "customer": {

    },
    "product": {

    }
  }
}
If this is not what you expected, check the input data (as JSON parsing will skip unexpected fields).
Waiting for vtgate to be up...
vtgate is up!
Access vtgate at http://ryzen:15001/debug/status

The linter also reported that the contains function and mycnfTemplateFile variable of mysqld.go are unused.

I introduced DefaultVtRoot so that there will not be an error if VTROOT is not defined. This means that if you want to use hooks, you will need to set a VTROOT, unless you are okay with the default of /usr/local/vitess/vthook (eventually I'd like to move binary instructions to use /usr/local/vitess as the install PATH similar to how golang installs.. it's not important to switch right now, and I could have equally specified /dev/null.)

In #5502 @enisoc commented that he was concerned that embedding init_db.sql creates a security risk. In this implementation, it is still possible to overwrite with a new init_db.sql file.. so it is possible to deploy securely.

Signed-off-by: Morgan Tocker tocker@gmail.com

Signed-off-by: Morgan Tocker <tocker@gmail.com>
@morgo morgo requested a review from sougou as a code owner January 3, 2020 21:25
@morgo morgo requested a review from enisoc January 3, 2020 21:25
Signed-off-by: Morgan Tocker <tocker@gmail.com>
Hooks will just not be supported if VTROOT is not specified.

Signed-off-by: Morgan Tocker <tocker@gmail.com>
Signed-off-by: Morgan Tocker <tocker@gmail.com>
@sougou
Copy link
Contributor

sougou commented Jan 8, 2020

Shouldn't there be a generated file somewhere, like rice-box.go?

@morgo
Copy link
Contributor Author

morgo commented Jan 8, 2020

Shouldn't there be a generated file somewhere, like rice-box.go?

It is produced in the Makefile on build, and added to gitignore. I took this direction because there are not many config files (vs. web files), and the generation time is quick.

@sougou
Copy link
Contributor

sougou commented Jan 8, 2020

Go recommends that all generated files be pre-generated and be part of the repo. The main goal is that you should be able to just go get whatever binary you need.

Signed-off-by: Morgan Tocker <tocker@gmail.com>
@morgo
Copy link
Contributor Author

morgo commented Jan 8, 2020

@sougou makes sense. Feedback addressed.

@sougou sougou merged commit 4e3041e into vitessio:master Jan 11, 2020
@morgo morgo deleted the morgo-bundle-configs branch January 15, 2020 17:55
morgo added a commit to planetscale/vitess that referenced this pull request Jan 15, 2020
Regression of vitessio#5654

Signed-off-by: Morgan Tocker <tocker@gmail.com>
systay pushed a commit that referenced this pull request Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pack web files and mysql config files into binaries
2 participants