Merge lp:~mariosplivalo/charms/trusty/percona-cluster/enable-binlogs into lp:~openstack-charmers-archive/charms/trusty/percona-cluster/next

Proposed by Mario Splivalo
Status: Superseded
Proposed branch: lp:~mariosplivalo/charms/trusty/percona-cluster/enable-binlogs
Merge into: lp:~openstack-charmers-archive/charms/trusty/percona-cluster/next
Prerequisite: lp:~niedbalski/charms/trusty/percona-cluster/fix-1425528
Diff against target: 88 lines (+38/-1)
3 files modified
config.yaml (+11/-0)
hooks/percona_hooks.py (+23/-1)
templates/my.cnf (+4/-0)
To merge this branch: bzr merge lp:~mariosplivalo/charms/trusty/percona-cluster/enable-binlogs
Reviewer Review Type Date Requested Status
James Page Needs Fixing
Felipe Reyes Needs Fixing
Edward Hope-Morley Pending
Billy Olsen Pending
Jorge Niedbalski Pending
Review via email: mp+252248@code.launchpad.net

This proposal has been superseded by a proposal from 2015-10-14.

Description of the change

This adds two charm configuration options - enable_binlogs and binlogs_path. Binlog_path defaults to /var/log/mysql/mysql.bin (it's because my.cnf which is packaged with mysql-common package suggests that location, and also because mysql charm defaults with binlogs at that location), while enable_binlogs defaults to 'False'.

To post a comment you must log in.
Revision history for this message
Felipe Reyes (freyes) wrote :

Hi Mario,

This feature makes a lot of sense, and it worked for me, but please add unit tests for your patch, I also have minor comments in the diff.

Thanks,

review: Needs Fixing
Revision history for this message
James Page (james-page) wrote :

bzr merge lp:~mariosplivalo/charms/trusty/percona-cluster/enable-binlogs
...
Text conflict in hooks/charmhelpers/contrib/database/mysql.py
1 conflicts encountered.

review: Needs Fixing
Revision history for this message
James Page (james-page) :
review: Needs Fixing
Revision history for this message
Mario Splivalo (mariosplivalo) wrote :

> bzr merge lp:~mariosplivalo/charms/trusty/percona-cluster/enable-binlogs
> ...
> Text conflict in hooks/charmhelpers/contrib/database/mysql.py
> 1 conflicts encountered.

I belive this is because of the prerequisite branch that needs merging first.

Revision history for this message
Mario Splivalo (mariosplivalo) wrote :

Based on discussion with Ed, this will be changed in a manner so that a new function is introduced, 'configure_binlogs'. That one will be called from install hook, after mysql has been installed, and will restart mysql for the change to take place.
It will also be called from config_changed hook, but it won't restart mysql - it will log a WARNING inside logs to tell administrator/operator to manually restart mysql when appropriate.

59. By Mario Splivalo

Isolate creation of binlog directory into a separate function

60. By Mario Splivalo

Merged /next

61. By Mario Splivalo

Conflicts resolved (work from another workstation)

Unmerged revisions

61. By Mario Splivalo

Conflicts resolved (work from another workstation)

60. By Mario Splivalo

Merged /next

59. By Mario Splivalo

Isolate creation of binlog directory into a separate function

58. By Mario Splivalo

Merged from /next

57. By Mario Splivalo

Fixed typos, as suggested by freyes

56. By Mario Splivalo

Fix lint errors

55. By Mario Splivalo

Remove call to lchownr as it won't change owner of the base directory.
Instead, use os.chown.

54. By Mario Splivalo

Fix directory creation

53. By Mario Splivalo

Make sure mysql can start even when binlog_path is pointing to
nonexistant path

52. By Mario Splivalo

Create binlog_directory, if missing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'config.yaml'
--- config.yaml 2015-07-27 09:44:19 +0000
+++ config.yaml 2015-10-09 11:16:10 +0000
@@ -145,3 +145,14 @@
145 description: |145 description: |
146 A comma-separated list of nagios servicegroups. If left empty, the146 A comma-separated list of nagios servicegroups. If left empty, the
147 nagios_context will be used as the servicegroup.147 nagios_context will be used as the servicegroup.
148 enable-binlogs:
149 default: False
150 type: boolean
151 description: Turns on MySQL binary logs. The placement of the logs is controlled with the binlogs_path config option.
152 binlogs-path:
153 default: /var/log/mysql/mysql-bin.log
154 type: string
155 description: |
156 Location on the filesystem where binlogs are going to be placed.
157 Default mimics what mysql-common would do for mysql (although not the
158 best place for binlogs)
148159
=== modified file 'hooks/percona_hooks.py'
--- hooks/percona_hooks.py 2015-09-23 18:29:21 +0000
+++ hooks/percona_hooks.py 2015-10-09 11:16:10 +0000
@@ -4,6 +4,8 @@
4import json4import json
5import os5import os
6import socket6import socket
7import pwd
8import grp
7import time9import time
810
9from charmhelpers.core.hookenv import (11from charmhelpers.core.hookenv import (
@@ -31,6 +33,7 @@
31 service_start,33 service_start,
32 file_hash,34 file_hash,
33 lsb_release,35 lsb_release,
36 mkdir
34)37)
35from charmhelpers.core.templating import render38from charmhelpers.core.templating import render
36from charmhelpers.fetch import (39from charmhelpers.fetch import (
@@ -124,7 +127,9 @@
124 'sst_password': config('sst-password'),127 'sst_password': config('sst-password'),
125 'innodb_file_per_table': config('innodb-file-per-table'),128 'innodb_file_per_table': config('innodb-file-per-table'),
126 'table_open_cache': config('table-open-cache'),129 'table_open_cache': config('table-open-cache'),
127 'lp1366997_workaround': config('lp1366997-workaround')130 'lp1366997_workaround': config('lp1366997-workaround'),
131 'binlogs_path': config('binlogs-path'),
132 'enable_binlogs': config('enable-binlogs')
128 }133 }
129134
130 if config('prefer-ipv6'):135 if config('prefer-ipv6'):
@@ -137,6 +142,23 @@
137 else:142 else:
138 context['ipv6'] = False143 context['ipv6'] = False
139144
145 # When render_config is called from the install hook, mysql is not
146 # yet installed. So we need to create binlogs_path directory world-writable
147 # We need that directory as otherwise mysql won't start
148 binlogs_directory = os.path.dirname(context['binlogs_path'])
149 if not os.path.isdir(binlogs_directory):
150 mkdir(binlogs_directory, 'root', 'root', 0o777)
151
152 # Assuming this is also called from config_changed, we now check if
153 # mysql uid/gid exists on the system. If so we chown binlogs_path to mysql
154 try:
155 uid = pwd.getpwnam('mysql').pw_uid
156 gid = grp.getgrnam('mysql').gr_gid
157 os.chown(binlogs_directory, uid, gid)
158 os.chmod(binlogs_directory, 0o750)
159 except KeyError:
160 pass
161
140 context.update(PerconaClusterHelper().parse_config())162 context.update(PerconaClusterHelper().parse_config())
141 render(os.path.basename(MY_CNF), MY_CNF, context, perms=0o444)163 render(os.path.basename(MY_CNF), MY_CNF, context, perms=0o444)
142164
143165
=== modified file 'templates/my.cnf'
--- templates/my.cnf 2015-06-04 14:40:54 +0000
+++ templates/my.cnf 2015-10-09 11:16:10 +0000
@@ -25,6 +25,10 @@
25# In order for Galera to work correctly binlog format should be ROW25# In order for Galera to work correctly binlog format should be ROW
26binlog_format=ROW26binlog_format=ROW
2727
28{% if enable_binlogs -%}
29log_bin={{ binlogs_path }}
30{% endif -%}
31
28# MyISAM storage engine has only experimental support32# MyISAM storage engine has only experimental support
29default_storage_engine=InnoDB33default_storage_engine=InnoDB
3034

Subscribers

People subscribed via source and target branches