-
Notifications
You must be signed in to change notification settings - Fork 42
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
remove container after extraction #10
Conversation
} | ||
|
||
reader, writer := io.Pipe() | ||
go handleTarStream(reader, i.opts.DstPath) |
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.
@pweil-, @simon3z what if handleTarStream
is taking more time for some reason but createAndExtractImage
gets to its end? handleTarStream
will keep working but maybe if it is slow we will get to the scanning with some of the files not written yet. Should we add some kind of channel here and wait for handleTarStream
to finish? This existed before this patch and is not connected to it, but I noticed this now.
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 was wondering that too. We could throw a channel in there like you suggest and wait on the channel or a timeout.
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.
LGTM 👍 |
1614d58
to
1d60152
Compare
@@ -197,7 +198,8 @@ func (i *defaultImageInspector) createAndExtractImage(client *docker.Client, con | |||
} | |||
|
|||
reader, writer := io.Pipe() | |||
go handleTarStream(reader, i.opts.DstPath) | |||
notificationChannel := make(chan int) | |||
go handleTarStream(reader, i.opts.DstPath, notificationChannel) |
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.
@pweil- let's try to merge this next. (It needs to be rebased). |
1d60152
to
60e4f62
Compare
60e4f62
to
f4db9c1
Compare
rebased. @enoodle can you double check the merge here to make sure I didn't miss anything? Thanks! tests:
|
@enoodle please re-review. |
LGTM 👍 |
case <-notificationChannel: | ||
break | ||
case <-time.After(time.Minute * 2): | ||
return imageMetadata, fmt.Errorf("timeout occured waiting for handleTarStream to finish") |
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.
@pweil- I am really worried about this one. IIUC if the extraction is longer than 2 minutes then we exit. It would be better if it was "2 minutes of inactivity"... but as it is now worries me.
Any chance that we can remove it? Maybe we can make it configurable... but I am worried anyway.
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.
Why don't we just not use a separate go routine when calling handleTarStream
? Then all this goes away.
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.
never mind, that is required for the copy to start. Ok, let me look at it
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.
@pweil- yeah I am all to remove the go routine if possible.
f4db9c1
to
b0266f7
Compare
Refactored the second commit so it will wait until both Testing:
|
@enoodle please review ASAP. Thanks! |
|
||
// capture any error from the copy, ensures both the handleTarStream and CopyFromContainer | ||
// are done. | ||
err = <- errorChannel |
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.
nit: gofmt is angry at this space after the arrow
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.
fixed
b0266f7
to
f3a37e4
Compare
|
||
reader, writer := io.Pipe() | ||
// handle closing the reader/writer in the method that creates them | ||
defer writer.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.
@pweil- we didn't have anything to close writer
before?
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.
no, didn't see anything
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 also checked if CopyFromContainer was doing it but it wasn't)
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.
then we got evene better than we aimed for :) 🍰
openscap: Warn instead of fail when loading configs
Fixes #8
After a second look I realized we can do this with a single defer if I extracted a method which is probably better anyway.
@simon3z @enoodle PTAL
Build and test: