Merge lp:~evarlast/charms/precise/mysql/encoding into lp:charms/mysql

Proposed by Jay R. Wren
Status: Work in progress
Proposed branch: lp:~evarlast/charms/precise/mysql/encoding
Merge into: lp:charms/mysql
Diff against target: 21 lines (+4/-1)
1 file modified
hooks/db-relation-joined (+4/-1)
To merge this branch: bzr merge lp:~evarlast/charms/precise/mysql/encoding
Reviewer Review Type Date Requested Status
Jorge Castro (community) Needs Fixing
Cory Johns (community) Needs Fixing
Review via email: mp+226538@code.launchpad.net

Description of the change

  use encoding from relation for create db

  https://bugs.launchpad.net/charms/+source/mysql/+bug/965094

To post a comment you must log in.
Revision history for this message
Chris Glass (tribaal) wrote :

This seems fine, if the relation does not set an explicit encoding, it defaults to utf8 (which is sensible).

The problem in my view is that it is not part of the formal interface definition of the "mysql" relation, as described here: https://juju.ubuntu.com/docs/interface-mysql.html

I would be ok to merge this branch (if I could), if I was shown a branch against the documentation updating the formal interface definition. It matters because it seems the mysql interface is our "golden standard" interface, and pretty much the only formalized interface in the whole ecosystem.

Revision history for this message
Marco Ceppi (marcoceppi) wrote :

I wouldn't say the MySQL interface is formalized, just the first one "documented". Interfaces are designed (and loosely typed) so they can evolve overtime, much as this is a welcome and shown improvement. Chris, I think you and I are on the same page and appreciate the caution in merging.

Updating the documentation would be a huge plus for this. Jay, you can find the documentation for juju on Github in Markdown. Including the optional encoding key would indeed speed these merges along: https://github.com/juju/docs

Otherwise, +1 from me

Revision history for this message
Jay R. Wren (evarlast) wrote :

Sounds good. Here is a PR for updating that documentation.
https://github.com/juju/docs/pull/137

On Tue, Aug 5, 2014 at 7:26 AM, Marco Ceppi <email address hidden> wrote:

> I wouldn't say the MySQL interface is formalized, just the first one
> "documented". Interfaces are designed (and loosely typed) so they can
> evolve overtime, much as this is a welcome and shown improvement. Chris, I
> think you and I are on the same page and appreciate the caution in merging.
>
> Updating the documentation would be a huge plus for this. Jay, you can
> find the documentation for juju on Github in Markdown. Including the
> optional encoding key would indeed speed these merges along:
> https://github.com/juju/docs
>
> Otherwise, +1 from me
> --
>
> https://code.launchpad.net/~evarlast/charms/precise/mysql/encoding/+merge/226538
> You are the owner of lp:~evarlast/charms/precise/mysql/encoding.
>

Revision history for this message
Cory Johns (johnsca) wrote :

Jay,

Thanks for getting those docs updated. However, I see an issue with this change. The relation-joined hook will execute before the other side has any chance to call relation-set to set the encoding. At that point the database will have been created with the default encoding, and the relation-set will have no effect. This was borne out in my tests; I could not get the encoding to take effect.

This logic needs to be moved into a db-relation-changed hook, which means you will need to either delay creating the database, or change it to use ALTER DATABASE to update the encoding. (The latter option also raises the question of whether it should be possible to update the encoding after the database has been in use and has data, but the documentation only describes using it in the relation-joined hook, so maybe that is a non-issue.)

Again, thanks for this contribution. It will be an excellent addition once this issue is resolved.

review: Needs Fixing
Revision history for this message
Jorge Castro (jorge) wrote :

Thanks for the contribution Jay, I'm moving this to need's fixing, please change it back to "Needs review" when you're ready for round two!

(Also mail me your address, I have a juju shirt for you).

Revision history for this message
Jorge Castro (jorge) :
review: Needs Fixing

Unmerged revisions

125. By Jay R. Wren

use encoding from relation for create db

https://bugs.launchpad.net/charms/+source/mysql/+bug/965094

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/db-relation-joined'
2--- hooks/db-relation-joined 2012-11-02 06:41:12 +0000
3+++ hooks/db-relation-joined 2014-07-11 21:10:23 +0000
4@@ -1,6 +1,7 @@
5 #!/usr/bin/env python
6
7 from common import *
8+from charmhelpers.core import hookenv
9
10 import urllib
11 import subprocess
12@@ -68,7 +69,9 @@
13 print "database exists already"
14 else:
15 if not broken and not admin:
16- runsql("create database `%s` character set utf8" % database_name)
17+ encoding = hookenv.relation_get().get('encoding', 'utf8')
18+ runsql("create database `%s` character set %s" % (database_name,
19+ encoding))
20 with open(database_name_file, 'w') as dbname:
21 dbname.write(database_name)
22

Subscribers

People subscribed via source and target branches

to all changes: