Code Monkey home page Code Monkey logo

mysqlapi's Introduction

tsuru

Build Status Go Report Card

What is tsuru?

tsuru is an extensible and open source Platform as a Service (PaaS) that makes application deployments faster and easier. With tsuru, you don’t need to think about servers at all. As an application developer, you can:

  • Write apps in the programming language of your choice
  • Back apps with add-on resources such as SQL and NoSQL databases, including memcached, Redis, and many others
  • Manage apps using the tsuru command-line tool

Links:

Popular platforms supported:

Quick Start

Getting tsuru-client

Download the latest release for your platform at: https://github.com/tsuru/tsuru-client/releases/

Example for release 1.1.1 and OS X:

$ curl -sSL https://github.com/tsuru/tsuru-client/releases/download/1.1.1/tsuru-1.1.1-darwin_amd64.tar.gz | tar xz

Install Guides

Testing

If everything's gone well you have the tsuru running in a Kubernetes Cluster. Call app list to see tsuru working, this command needs to return one app called tsuru-dashboard.

$ tsuru app list

mysqlapi's People

Contributors

andrewsmedina avatar flavianmissi avatar fsouza avatar guestisp avatar renatogp avatar wiliamsouza avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mysqlapi's Issues

implement better queue for instance state checking

when launching a new instance, code that checks state of the instance runs in a thread [1]. If, at any time, the service is restarted, this change is lost. One way to solve this is starting a new thread with the serve and process instances from a non-persistent queue, that is filled up when the server starts with all pending instances. The started thread will run forever, checking instances in this queue.

[1] https://github.com/timeredbull/mysqlapi/blob/73fa4de5349c64bd282a94d970b51186f9079f26/mysqlapi/api/models.py#L104

Can't connect to created database

Hello,

I'm deploying a PHP app. I've set up a MySQL service on a dedicated server and bound mysql service to that app. As I access the app site, it says that it can not connect to MySQL server. Here are the users of the database server:

screenshot 2014-06-20 17 52 50

And here're the default privileges on the created database (I created another db named 'testdbwp'):

screenshot 2014-06-23 11 50 41

After changing the host from '127.0.0.1' in both the 'user' and 'db' tables, I could get my app to work with the database. But is there any configuration or something that can make this happen automatically?

should return friendly error if the database already exists

% curl -qd "appname=myapp" http://myapi.net/resources/ 
{"MYSQL_PASSWORD": "ed7a9525509745d93c2730052e3a0d0813cab63a", "MYSQL_USER": "myapp", "MYSQL_DATABASE_NAME": "myapp", "MYSQL_HOST": "localhost", "MYSQL_PORT": "3306"}
% curl -qd "appname=myapp" http://myapi.net/resources/ 
{"MYSQL_PASSWORD": "ed7a9525509745d93c2730052e3a0d0813cab63a", "MYSQL_USER": "myapp", "MYSQL_DATABASE_NAME": "myapp", "MYSQL_HOST": "localhost", "MYSQL_PORT": "3306"}
...
DatabaseError at /resources/
  (1007, Can't create database "myapp" database exists)
...

Failed to bind the instance: mysqlapi

Configured mysql server, mysqlapi application, and mysqlapi service properly
Able to create a new db instance using tsuru service-instance-create mysqlapi instance_name
But whenever I try to bind the instance with an existign app it throws this error.
Error: Failed to bind the instance "mysqlapi/tsuru_wp" to the app "wordpress": invalid response: Using GRANT statement to modify existing user's properties other than privileges is deprecated and will be removed in future release. Use ALTER USER statement for this operation. (code: 500) ("tsuru_wp" is up)

I believe that it is because we are trying to create user using grant command in file (mysqlapi/models.py) ( line 87) which would create user and grant specified permissions on a database directly. But the tsuru error shows it is deprecated.

However, when I execute same command on mysql server's prompt, it shows warning but also creates user and grants privileges. I am trying to resolve , but don't know how, please help.
I want to execute create user first and then grant upon execution of bind command.

Wrong env var for MYSQLAPI_DB_HOST

Actually, mysqlapi is looking for MYSQLAPI_HOST as mysql hostname.
This is wrong, because tsuru uses MYSQLAPI_DB_* vars (as all other env vars wronte on code)

MYSQLAPI_HOST should be renamed MYSQLAPI_DB_HOST

Security

Looking through code, i don't see any security check on who is calling APIs.
This means the everyone would be able to post DELETE actions.

Am I missing something?

Docker support

You should support docker when creating dedicated VMs.
Actually only EC2 instances are supported.

should return friendly error if appname is missing or empty

Samples:

Missing the variable appname:

% curl -d "xyku=chico" http://myapi.net/resources/
...
MultiValueDictKeyError at /resources/
Key "appname" not found in QueryDict
...

With empty appname:

% curl -d "appname=" http://myapi.net/resources/
...
DatabaseError at /resources/
(1064, 'You have an error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near "default character set utf8
default collate utf8_general_ci" at line 1'
...

Error: Failed to create the instance xxx: no such route

I installed tsuru with now script and following the tutorial Deploying Python applications in tsuru and HOWTO Install a MySQL service, but when I create mysql service instance, I got the following error message.

wlzx@ubuntu:~/tsuru/tsuru-django-sample$ tsuru app-list
+-----------------+-------------------------+-------------------------------------+
| Application     | Units State Summary     | Address                             |
+-----------------+-------------------------+-------------------------------------+
| blog            | 0 of 0 units in-service | blog.113.55.12.64.nip.io            |
+-----------------+-------------------------+-------------------------------------+
| mysql-api       | 1 of 1 units in-service | mysql-api.113.55.12.64.nip.io       |
+-----------------+-------------------------+-------------------------------------+
| tsuru-dashboard | 1 of 1 units in-service | tsuru-dashboard.113.55.12.64.nip.io |
+-----------------+-------------------------+-------------------------------------+
wlzx@ubuntu:~/tsuru/tsuru-django-sample$ tsuru app-info --app blog
Application: blog
Repository: [email protected]:blog.git
Platform: python
Teams: admin
Address: blog.113.55.12.64.nip.io
Owner: [email protected]
Team owner: admin
Deploys: 0
Pool: theonepool
Quota: 0/-1 units

App Plan:
+---------------+--------+------+-----------+--------+---------+
| Name          | Memory | Swap | Cpu Share | Router | Default |
+---------------+--------+------+-----------+--------+---------+
| autogenerated | 0      | 0    | 100       |        | false   |
+---------------+--------+------+-----------+--------+---------+

wlzx@ubuntu:~/tsuru/tsuru-django-sample$
wlzx@ubuntu:~/tsuru/tsuru-django-sample$ tsuru service-list
+----------+-----------+
| Services | Instances |
+----------+-----------+
| mysqlapi |           |
+----------+-----------+
wlzx@ubuntu:~/tsuru/tsuru-django-sample$ cat ../mysql-api/manifest.yaml 
id: mysqlapi
username: admin
password: admin
team: admin
endpoint:
  production: 113.55.12.64
wlzx@ubuntu:~/tsuru/tsuru-django-sample$ 
wlzx@ubuntu:~/tsuru/tsuru-django-sample$ tsuru service-add mysqlapi blogsq
Error: You must provide a team to execute this action.
wlzx@ubuntu:~/tsuru/tsuru-django-sample$ tsuru service-add mysqlapi blogsq -t admin
Error: Failed to create the instance blogsq: no such route
wlzx@ubuntu:~/tsuru/tsuru-django-sample

Any ideas?

Problems installing

Hi,

I am using https://github.com/tsuru/tsuru-bootstrap.git and decided to try mysql as well. For that, I did this:

git clone [email protected]:tsuru/mysqlapi.git
tsuru app-create mysqlapi python -t namoroon
git remote add tsuru [email protected]:mysqlapi.git
git push tsuru
tsuru env-set MYSQLAPI_SHARED_SERVER=localhost -a mysqlapi
tsuru env-set DJANGO_SETTINGS_MODULE=mysqlapi.settings -a mysqlapi
crane create service.yaml
tsuru service-add mysqlapi namoroonmysql small -t namoroon
Error: Failed to create the instance namoroonmysql: Post http://mysqlapi.com/resources: dial tcp: lookup mysqlapi.com: no such host

Makes sense, so I edited service.yaml:

crane remove mysqlapi
vi service.yaml, production: mysqlapi.192.168.46.226.nip.io
crane create service.yaml
tsuru service-add mysqlapi namoroonmysql small -t namoroon
Error: Failed to create the instance namoroonmysql:

<title>Error 502 - Application Not Responding</title> <style> body { background-color: #fff; margin: 0px; padding-top: 280px; text-align: center; } h1 { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 24px; font-weight: normal; } h2 { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; color: #999; font-weight: normal; } </style>

Application Not Responding

Please try again in a few moments.

tsuru app-log --lines 5 -a mysqlapi
2015-03-31 08:18:07 -0300 [web][7a92435c6ad4]: Using worker: gevent
2015-03-31 08:18:07 -0300 [web][7a92435c6ad4]: Booting worker with pid: 186
2015-03-31 08:18:07 -0300 [web][7a92435c6ad4]: Worker exiting (pid: 186)
2015-03-31 08:18:08 -0300 [web][7a92435c6ad4]: Shutting down: Master
2015-03-31 08:18:08 -0300 [web][7a92435c6ad4]: Reason: Worker failed to boot.

No extra info in the logs. This did not help: tsuru env-set MYSQLAPI_DEBUG=1 -a mysqlapi

If I can suggest something, I'd say the documentation could be improved . It is not clear to the reader if the mysql instance is managed by mysqlapi itself, via docker instances it manages, or if I really need to pre-install a shared MySQL server and mysqlapi manages just databases in it (I suspect it is this option). But if I want a DEV environment, is it ok if I install mysql in the tsar-bootstrap VM itself? Or can I have it as a Docker? I would like to automate the database install as well.

Basically I am trying to use tsar for DEV deploys on developers machines for now (still using Heroku for LIVE). If it works, I will try STAGING next and LIVE last.

Note: I am having a similar problem with redisapi (ticket 28 there). So, it is probably something missing in the docs (assumes the person is a tsar expert).

Thanks!

Error when installing mysqlapi on tsuru-bootstrap

Command: sudo pip install -r requirements.txt

running build_ext

building 'gevent.core' extension

creating build/temp.linux-x86_64-2.7

creating build/temp.linux-x86_64-2.7/gevent

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c gevent/core.c -o build/temp.linux-x86_64-2.7/gevent/core.o

In file included from gevent/core.c:253:0:

gevent/libevent.h:9:19: fatal error: event.h: No such file or directory

#include "event.h"

               ^

compilation terminated.

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1


Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;file='/tmp/pip_build_root/gevent/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /tmp/pip-a8ZjvC-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/gevent
Storing debug log for failure in /home/vagrant/.pip/pip.log

API return sql error when app name has a dash

e.g.:

$> tsuru service-add mysql some-app

This is a valid app name for tsuru, mysql api should treat it properly, maybe transform some-app to some_app_hash123, the hash is added so we don't get problems with another app named some_app.

Automatically create HA environments

users should be able to choose an HA database when binding to this service.
If HA is choosen, mysqlapi should create 2 databases, automatically configure a master-slave replica and automatically set a failover.

Even better would be adding support for migration from standard DB to HA db. In this case, a new replica would be created and automatically replicated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.