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

Allow waiting for a specific number of log occurences #628

Closed
miszobi opened this issue Dec 1, 2016 · 8 comments
Closed

Allow waiting for a specific number of log occurences #628

miszobi opened this issue Dec 1, 2016 · 8 comments
Labels
Milestone

Comments

@miszobi
Copy link

miszobi commented Dec 1, 2016

Description

Info

  • d-m-p version : 0.17.1
  • Maven version (mvn -v) : 3.3.9
  • Docker version : 1.12.3

Some containers (observed both with postgres:9.5 for example) emit a log message indicating readiness multiple times (probably the db is restarted after initial env setup I assume).
Example:

waiting for server to start....LOG:  database system was shut down at 2016-12-01 09:31:22 UTC
LOG:  MultiXact member wraparound protections are now enabled
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started
 done
server started
ALTER ROLE


/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*

LOG:  received fast shutdown request
LOG:  aborting any active transactions
LOG:  autovacuum launcher shutting down
waiting for server to shut down....LOG:  shutting down
LOG:  database system is shut down
 done
server stopped

PostgreSQL init process complete; ready for start up.

LOG:  database system was shut down at 2016-12-01 09:31:30 UTC
LOG:  MultiXact member wraparound protections are now enabled
LOG:  database system is ready to accept connections

For such cases it would be useful to specify that the plugin should wait for a specific number of occurences of the specified log message pattern.

Something like:

                              <wait>
                                 <log>database system is ready to accept connections</log>
                                 <count>2</count>
                              </wait>

would wait for the second occurrence of the pattern before continuing. This seems it would solve #608 as well.

@who
Copy link

who commented Feb 14, 2017

+1

@rhuss rhuss added the feature label Feb 14, 2017
@rhuss
Copy link
Collaborator

rhuss commented Feb 14, 2017

looks useful to me. We still would have to think about to introduce the configuration. Simply <count> doesn't work because its on the same level a http checks and so on.

Ideally we would have something like:

<wait>
  <log>
     <pattern>database system is ready to accept connections</pattern>
     <count>2</count>
  </log>
</wait>

however <log> is already burned (for backwards compatibility). Maybe <out> or <stdout> (with then in addition <stderr>, too) would be a good fit as alternative for the extended definition ?

@rhuss rhuss modified the milestones: 0.20.0, 0.20.1 Feb 16, 2017
@rhuss
Copy link
Collaborator

rhuss commented Mar 25, 2017

Another idea would be to allow multi-line patterns: When the multiline option is enabled in the pattern (?s), then keep all log lines and try to match on the whole log. Of course this can be a bit more memory intensive, but should be easy to add in the LogWatcher.

Kudos to @michael-simons for the idea ;-)

rhuss added a commit to rhuss/docker-maven-plugin that referenced this issue Mar 25, 2017
This is related to fabric8io#628 and fabric8io#608 and should fix both issues.

Also, some refactoring has been performed for the wait checkers which were extracted into an extra package.
@rhuss
Copy link
Collaborator

rhuss commented Mar 25, 2017

@miszobi @who I just added multi line matching now, so that you can now wait on this condition like with

"(?s)ready to accept connections.*ready to accept connections"

for happening this line twice. I think this will perfectly fit your use case and is more flexible then a count (and also doesn't require any extension to the log configuration).

If this is good enough for you I would like to close this issue.

@miszobi
Copy link
Author

miszobi commented Mar 27, 2017

@rhuss using a multi-line pattern for this sounds like a good solution to me. Thanks a lot!

@who
Copy link

who commented Mar 27, 2017

Looks good to me! It should solve our particular use case.

@rhuss
Copy link
Collaborator

rhuss commented Mar 27, 2017

Awesome ;-). You can expect a release tomorrow :)

@rhuss rhuss closed this as completed Mar 27, 2017
rgbj pushed a commit to rgbj/docker-maven-plugin that referenced this issue Jun 21, 2017
This is related to fabric8io#628 and fabric8io#608 and should fix both issues.

Also, some refactoring has been performed for the wait checkers which were extracted into an extra package.
@zingorn
Copy link

zingorn commented May 1, 2018

"(?s)ready to accept connections.*ready to accept connections"

It works fine in 0.24.0 but broken in 0.25.2 for me. It just stop and waiting on a pattern line

[INFO] --- docker-maven-plugin:0.25.0:start (start) @ annotations-jooq ---
[INFO] DOCKER> [postgres:9.6]: Start container 9429fe081828
[INFO] DOCKER> Pattern '(?s)ready to accept connections.*ready to accept connections' matched for container 9429fe081828

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants