-
Notifications
You must be signed in to change notification settings - Fork 642
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
Create at most one PrintStream per log file. #661
Conversation
This avoids corrupted log files. Fixes fabric8io#652.
Current coverage is 48.96% (diff: 59.50%)@@ master #661 diff @@
==========================================
Files 113 123 +10
Lines 5881 6333 +452
Methods 0 0
Messages 0 0
Branches 1020 1077 +57
==========================================
+ Hits 2786 3101 +315
- Misses 2850 2961 +111
- Partials 245 271 +26
|
AWS ECR key exchange closes fabric8io#637 Signed-off-by: Chas Honton <chas@apache.org>
Signed-off-by: Chas Honton <chas@apache.org>
PR merged! Thanks!
PR merged! Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot ! I think we should implement the fix slightly differently, see my comment on LogDispatcher
.
If you don't have time to change this this week, I could take this over to fix this.
return ps; | ||
} | ||
|
||
public static void closeLogs() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method should be synchronized
, too
@@ -37,15 +40,16 @@ public LogDispatcher(DockerAccess dockerAccess) { | |||
} | |||
|
|||
public synchronized void trackContainerLog(String containerId, LogOutputSpec spec) throws FileNotFoundException { | |||
LogGetHandle handle = dockerAccess.getLogAsync(containerId, new DefaultLogCallback(spec)); | |||
LogGetHandle handle = dockerAccess.getLogAsync(containerId, createLogCallback(spec)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a a fan of static imports as they dilute the real locations and I always search first in the current class when doing review. Could we refer to the static method via its class (LogCallbackFactory.createLogBack()
) ? Even saves some lines.
@@ -145,7 +146,7 @@ public void startExecContainer(String containerId, LogOutputSpec outputSpec) thr | |||
} | |||
|
|||
private ResponseHandler<Object> createExecResponseHandler(LogOutputSpec outputSpec) throws FileNotFoundException { | |||
final LogCallback callback = new DefaultLogCallback(outputSpec); | |||
final LogCallback callback = createLogCallback(outputSpec); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Who is closing this DefaultLogCallback() ?
} | ||
|
||
public synchronized void untrackAllContainerLogs() { | ||
closeLogs(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will close all streams from all LogDispatcher instances running. Not sure why it could be more than one, but at least we should avoid the mismatch with the LogCallbackFactory storing the stream in a static Map vs. using object instances for the LogDispatcher here. I would prefer to have LogCallbackFactory to be an object, too.
What's about the following idea: We simply allow DefaultLogCallback
to reuse an existing printstream (i.e. we do the caching on a static field in DefaultLogCallback along with a usage count) and add a close()
method to the callback so that the user can signal that he is done with logging ? In close()
an the associated printstream's usage count will be decreased and if 0 then closed.
I think this kind of resource management makes more sense, also for potential future use cases. If you don't have the cycles to implement this, no problem, I could take over (as this is indeed an important fix to have). Also, a unit tests for DefaultLogCallback
would be awesome then.
Thanks for your feedback. I'll get back to this tomorrow... |
Awesome,thx unfortunately I just catched an ugly flu, and staying in bed
currently. I will continue here asap. Sorry ...
Harald Wellmann <notifications@github.com> schrieb am Di., 20. Dez. 2016,
13:44:
… Thanks for your feedback. I'll get back to this tomorrow...
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#661 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAGDCF5LZDD0ujqAvS_aVoM9v4dxa36oks5rJ82pgaJpZM4LP7z2>
.
|
Signed-off-by: Chas Honton <chas@apache.org>
Signed-off-by: Chas Honton <chas@apache.org>
added ability to explicitly via configuration to create named volumes via <volumes><volume> configuration. Example config ```xml <volumes> <volume> <name>Volume Name</name> <driver>local</driver> <driverOpts> <driverOpt-key-name>driverOpt-value</driverOpt-key-name> </driverOpts> <labels> <label-key>someValue</label-key> <com-github-fabric8-dmp-sample-volume> voluminous </com-github-fabric8-dmp-sample-volume> </labels> </volume> </volumes> ``` Added a new volume sample Added a new goal volume-create minor formatting / spelling correction for intro.md Signed-off-by: Tom Burton <Tom.Burton@Outlook.com>
Signed-off-by: Tom Burton <Tom.Burton@Outlook.com>
fabric8io#664 (review) corrected spelling corrected ascii-doc + formatting code formatting Signed-off-by: Tom Burton <Tom.Burton@Outlook.com>
fabric8io#664 (review) corrected spelling corrected ascii-doc + formatting code formatting Signed-off-by: Tom Burton <Tom.Burton@Outlook.com>
This is a cleanup of PR fabric8io#664 with the following major points tackled: * Cleaned formatting * Removed unneeded classes and service method for listing and getting volumes. This is not needed now and probablu not in the future. * Fixed some Copy&Pase errors (like the default phase for 'volume-remove' which was the same as for 'volume-create' * Fixed tests. Please note, that *no service method* should be adapted to be "testable". Especially do not introduce a non-private method only for this purpose and test this method instead of the offiical API. Modern Mock frameworks can deal with the the problems which are tried to be solved with this. Otherwise the API gets dilulted, more complicated, more maintenance, more coupled. * Removed assert that do nothing. Tests can be still improved for the service but its fine for now, Next step is to add support for the PropertyHandler to allow configuration of the volumes also via properties.
PR merged! Thanks!
PR merged! Thanks!
PR merged! Thanks!
PR merged! Thanks!
…ven-plugin into hwellmann-garbled-logs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot. I have some minor comments. If you dont mind I would fix them right now in order to proceed for a next release.
return printStream; | ||
} | ||
|
||
public void setPrintStream(PrintStream printStream) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesnt look like that this method is ever used. Also, removing this set-method makes the class immutable with respect to the printstream which is a good thing :)
@@ -91,6 +91,8 @@ public void fetchLogs() { | |||
parseResponse(resp); | |||
} catch (IOException exp) { | |||
callback.error(exp.getMessage()); | |||
} finally { | |||
callback.close(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should ensure, that, when the callback is closed that this any call to the LogRequestors
method is invalid (by throwing an exception).
Its also not so nice that the responsibilities for creating the callback (== caller of constructor of LogRequestor
) and the one closing the callback (== the LogRequestor
) are different objects. It would be much better when the LogRequestor
has the complete control over allocation and closing of the print stream.
I suggest therefor to introduce a an LogCallback open()
which allocates the stream instead of automatically allocating it in the constructor. Each method which can close a stream then would have to open it before.
@@ -224,6 +227,7 @@ public void finish() { | |||
} | |||
} | |||
} | |||
callback.close(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
finish() is called in case of an exception but the callback.close()
is also included in the finally clauses of the top level methods. This leads to closing a callback() twice which is probably not intended.
callback2.log(1, ts, "line 4"); | ||
callback2.close(); | ||
|
||
List<String> lines = Files.readAllLines(path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately we can't use Java 8 and are still stuck to Java 7 for now (this might change in the future). So we need some other way to read all lines here.
This change is related to fabric8io#661 to make start / stop more symmetric - removing Java 8 methods - minor cosmetics
@hwellmann I made some changes and would like to push it to this PR. Could you please grant me push permissions ? This is described here |
Sorry, my faul. Mispelled the target branch for the push. |
[merge] |
PR merged! Thanks!
This avoids corrupted log files.
Fixes #652.