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

Add better logging functionality #119

Merged
merged 1 commit into from
Feb 4, 2016
Merged

Conversation

mnagy
Copy link
Contributor

@mnagy mnagy commented Feb 1, 2016

This is my first stab at #112. I'd like to get feedback before adopting this for 5.6 and other DB images. For now I'm only adding one logging function (first point of #112), but will add debugging variable shortly.

CC: @bparees @rhcarvalho @hhorak @praiskup @eliskasl @mfojtik

Sample run:

[vagrant@openshiftdev perl_example]$ docker run -e MYSQL_ROOT_PASSWORD=pass -ti --rm fd3a72c89014
CONTAINER[3f610f6821d5] 11:07:28     Processing MySQL configuration files ...
CONTAINER[3f610f6821d5] 11:07:28     Initializing database ...
CONTAINER[3f610f6821d5] 11:07:28     Running mysql_install_db ...
160201 11:07:28 [Note] /opt/rh/mysql55/root/usr/libexec/mysqld (mysqld 5.5.45) starting as process 40 ...
160201 11:07:28 [Note] /opt/rh/mysql55/root/usr/libexec/mysqld (mysqld 5.5.45) starting as process 47 ...

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

scl enable mysql55 -- /opt/rh/mysql55/root/usr/bin/mysqladmin -u root password 'new-password'
scl enable mysql55 -- /opt/rh/mysql55/root/usr/bin/mysqladmin -u root -h 3f610f6821d5 password 'new-password'

Alternatively you can run:
scl enable mysql55 -- /opt/rh/mysql55/root/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

Please report any problems at http://bugs.mysql.com/

CONTAINER[3f610f6821d5] 11:07:28     Starting MySQL server with disabled networking ...
160201 11:07:28 [Note] /opt/rh/mysql55/root/usr/libexec/mysqld (mysqld 5.5.45) starting as process 53 ...
CONTAINER[3f610f6821d5] 11:07:28     Waiting for MySQL to start ...
160201 11:07:28 [Note] Plugin 'FEDERATED' is disabled.
160201 11:07:28 InnoDB: The InnoDB memory heap is disabled
160201 11:07:28 InnoDB: Mutexes and rw_locks use GCC atomic builtins
160201 11:07:28 InnoDB: Compressed tables use zlib 1.2.7
160201 11:07:28 InnoDB: Using Linux native AIO
160201 11:07:28 InnoDB: Initializing buffer pool, size = 128.0M
160201 11:07:28 InnoDB: Completed initialization of buffer pool
InnoDB: The first specified data file ./ibdata1 did not exist:
InnoDB: a new database to be created!
160201 11:07:28  InnoDB: Setting file ./ibdata1 size to 10 MB
InnoDB: Database physically writes the file full: wait...
160201 11:07:28  InnoDB: Log file ./ib_logfile0 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile0 size to 5 MB
InnoDB: Database physically writes the file full: wait...
160201 11:07:28  InnoDB: Log file ./ib_logfile1 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: 127 rollback segment(s) active.
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
160201 11:07:28  InnoDB: Waiting for the background threads to start
CONTAINER[3f610f6821d5] 11:07:29     Waiting for MySQL to start ...
160201 11:07:29 InnoDB: 5.5.45 started; log sequence number 0
160201 11:07:29 [Warning] 'user' entry 'root@3f610f6821d5' ignored in --skip-name-resolve mode.
160201 11:07:29 [Warning] 'user' entry '@3f610f6821d5' ignored in --skip-name-resolve mode.
160201 11:07:29 [Warning] 'proxies_priv' entry '@ root@3f610f6821d5' ignored in --skip-name-resolve mode.
160201 11:07:29 [Note] Event Scheduler: Loaded 0 events
160201 11:07:29 [Note] /opt/rh/mysql55/root/usr/libexec/mysqld: ready for connections.
Version: '5.5.45'  socket: '/tmp/mysql.sock'  port: 0  MySQL Community Server (GPL)
CONTAINER[3f610f6821d5] 11:07:30     MySQL started successfully
CONTAINER[3f610f6821d5] 11:07:30     Dropping the "test" database ...
Database "test" dropped
CONTAINER[3f610f6821d5] 11:07:30     Setting password for root ...
CONTAINER[3f610f6821d5] 11:07:30     Initialization finished
CONTAINER[3f610f6821d5] 11:07:30     Setting passwords ...
CONTAINER[3f610f6821d5] 11:07:30     Sourcing post-init.sh ...
CONTAINER[3f610f6821d5] 11:07:30     Shutting down MySQL ...
160201 11:07:30 [Warning] 'user' entry 'root@3f610f6821d5' ignored in --skip-name-resolve mode.
160201 11:07:30 [Warning] 'user' entry '@3f610f6821d5' ignored in --skip-name-resolve mode.
160201 11:07:30 [Warning] 'proxies_priv' entry '@ root@3f610f6821d5' ignored in --skip-name-resolve mode.
160201 11:07:30 [Note] /opt/rh/mysql55/root/usr/libexec/mysqld: Normal shutdown

160201 11:07:30 [Note] Event Scheduler: Purging the queue. 0 events
160201 11:07:30  InnoDB: Starting shutdown...
160201 11:07:32  InnoDB: Shutdown completed; log sequence number 1595675
160201 11:07:32 [Note] /opt/rh/mysql55/root/usr/libexec/mysqld: Shutdown complete

CONTAINER[3f610f6821d5] 11:07:32     Cleaning up environment variables ...
CONTAINER[3f610f6821d5] 11:07:32     Running final exec -- Only MySQL server logs after this point
160201 11:07:32 [Note] /opt/rh/mysql55/root/usr/libexec/mysqld (mysqld 5.5.45) starting as process 1 ...
160201 11:07:32 [Note] Plugin 'FEDERATED' is disabled.
160201 11:07:32 InnoDB: The InnoDB memory heap is disabled
160201 11:07:32 InnoDB: Mutexes and rw_locks use GCC atomic builtins
160201 11:07:32 InnoDB: Compressed tables use zlib 1.2.7
160201 11:07:32 InnoDB: Using Linux native AIO
160201 11:07:32 InnoDB: Initializing buffer pool, size = 128.0M
160201 11:07:32 InnoDB: Completed initialization of buffer pool
160201 11:07:32 InnoDB: highest supported file format is Barracuda.
160201 11:07:32  InnoDB: Waiting for the background threads to start
160201 11:07:33 InnoDB: 5.5.45 started; log sequence number 1595675
160201 11:07:33 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
160201 11:07:33 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
160201 11:07:33 [Note] Server socket created on IP: '0.0.0.0'.
160201 11:07:33 [Warning] 'user' entry 'root@3f610f6821d5' ignored in --skip-name-resolve mode.
160201 11:07:33 [Warning] 'user' entry '@3f610f6821d5' ignored in --skip-name-resolve mode.
160201 11:07:33 [Warning] 'proxies_priv' entry '@ root@3f610f6821d5' ignored in --skip-name-resolve mode.
160201 11:07:33 [Note] Event Scheduler: Loaded 0 events
160201 11:07:33 [Note] /opt/rh/mysql55/root/usr/libexec/mysqld: ready for connections.
Version: '5.5.45'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server (GPL)

@mnagy
Copy link
Contributor Author

mnagy commented Feb 1, 2016

What I personally don't like is that messages from scripts are a bit harder to stop. Some "ascii art" could help, e.g. >>> prefix, or something similar.

@@ -0,0 +1,3 @@
function info-log {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not much a fan of dashes in function name, something like log_info (words deliberately swapped) would create space for potential log_warning, log_error in the future.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw. I'm not seeing the reason to have a separate file and not define the function directly in common.sh, but you might have a reason..

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I second renaming this to log_info.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and putting it in common.sh

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason why I wanted it outside of common.sh is that common.sh isn't really common across images. I wanted to have a separate file that could be directly copyable so it would be easy to keep up-to-date.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with renaming.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason why I wanted it outside of common.sh is that common.sh isn't really common across images. I wanted to have a separate file that could be directly copyable so it would be easy to keep up-to-date.

so "morecommon.sh"? :) fair enough i guess.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

common_functions.sh?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

common_functions.sh or morecommon.sh are just weird. I like lib.sh best, because it kind of is a "library".

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's not dwell on this. lib.sh is fine. my "morecommon.sh" suggestion was a joke, if that wasn't clear.

@hhorak
Copy link
Member

hhorak commented Feb 1, 2016

Generally I like this and agree we should play with it a bit... What about UTF instead of ASCII, like prefixing with ▥▥▥, so ▥▥▥ [3f610f6821d5]?

@bparees
Copy link
Collaborator

bparees commented Feb 1, 2016

Having the container id in the output feels like overkill to me. Maybe worth having if debug mode is enabled, but otherwise it's pretty ugly and rarely likely to be all that useful.

i think we should just copy the assemble syntax we've used for delineating our log entries:
https://github.com/openshift/sti-ruby/blob/master/2.2/s2i/bin/assemble#L19

@mnagy
Copy link
Contributor Author

mnagy commented Feb 1, 2016

@bparees it's actually $HOSTNAME. I don't know, I thought it might be useful.

@bparees
Copy link
Collaborator

bparees commented Feb 1, 2016

@mnagy i'm even less inclined to keep it if it's $HOSTNAME :)

@mnagy mnagy changed the title WIP: Add better logging functionality Add better logging functionality Feb 2, 2016
@mnagy mnagy changed the title Add better logging functionality WIP: Add better logging functionality Feb 2, 2016
@hhorak
Copy link
Member

hhorak commented Feb 2, 2016

I don't have a big problem with lib.sh and otherwise don't see any issue, LGTM.

. ${CONTAINER_SCRIPTS_PATH}/passwd-change.sh
fi
if [ -f ${CONTAINER_SCRIPTS_PATH}/post-init.sh ]; then
log_info 'Sourcing post-init.sh ...'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this message mean for the user? Wouldn't be better to explain what post-init do here?

@mnagy mnagy changed the title WIP: Add better logging functionality Add better logging functionality Feb 4, 2016
@mnagy
Copy link
Contributor Author

mnagy commented Feb 4, 2016

Addressed Michal's comments. PTAL

@mfojtik
Copy link
Contributor

mfojtik commented Feb 4, 2016

[test][openshift]

@mfojtik
Copy link
Contributor

mfojtik commented Feb 4, 2016

LGTM

@bparees
Copy link
Collaborator

bparees commented Feb 4, 2016

lgtm

bparees added a commit that referenced this pull request Feb 4, 2016
Add better logging functionality
@bparees bparees merged commit 7d8c13c into sclorg:master Feb 4, 2016
@rhcarvalho
Copy link
Contributor

This PR has different patches for the 5.5 dir and 5.6 dir.
@mnagy or anyone, is there a reason for that?

I made a diff of the diffs:
https://gist.github.com/rhcarvalho/3a8de68dd8eab107de7ef619475c22b8

Much easier to visualize with a tool like meld, though.

In summary:

  • log_volume_info $MYSQL_DATADIR put in different places (5.5 x 5.6)
  • Portions of code only in one image (e.g., look for if [ -v MYSQL_RUNNING_AS_MASTER ])

I'm trying to understand the current state of the replication examples. Thanks!

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.

5 participants