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

Break apart container configuration build and push step #252

Merged
merged 8 commits into from
May 4, 2018

Conversation

TadCordle
Copy link
Contributor

Separating build and push steps so we can build and export to Docker daemon.


return containerConfigurationBlobDescriptor;
return new BlobAndDigest(containerConfigurationBlob, digestOutputStream.toBlobDescriptor());
Copy link
Contributor

Choose a reason for hiding this comment

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

This could probably avoid creating a new tuple class BlobAndDigest by just returning the Blob here and generating the Digest in the push step.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, I wasn't sure if the Digest generation should be kept in the build step.

new PushContainerConfigurationStep(
buildConfiguration,
authenticatePushFuture,
buildContainerConfigurationFutureFuture.get(),
Copy link
Contributor

@coollog coollog May 3, 2018

Choose a reason for hiding this comment

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

This call to get would be executed before anything is run, which would cause race conditions and blocking. Any get for a Future should be called in the call method of the step that uses it and should be wrapped in a NonBlockingFutures.get for busy-wait safety (it makes sure that the get does not block).

ListeningExecutorService listeningExecutorService) {
this.buildConfiguration = buildConfiguration;
this.pushAuthorizationFuture = pushAuthorizationFuture;
this.blobFuturesFuture = blobFuturesFuture;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: *FutureFuture since it is just a future wrapping a since future

Copy link
Contributor

Choose a reason for hiding this comment

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

Might also be clearer to name this like buildContainerConfigurationF... to make it explicit where this should be coming from.

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;

class PushContainerConfigurationStep implements Callable<ListenableFuture<BlobDescriptor>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Short javadoc here

Copy link
Contributor

@coollog coollog left a comment

Choose a reason for hiding this comment

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

Just some naming things

@@ -59,11 +60,11 @@
@Override
public ListenableFuture<Blob> call() throws ExecutionException, InterruptedException {
// TODO: This might need to belong in BuildImageSteps.
List<ListenableFuture<?>> afterBaseImageLayerFuturesFutureDependencies = new ArrayList<>();
afterBaseImageLayerFuturesFutureDependencies.addAll(
List<ListenableFuture<?>> afterBaseImageLayerFutureFutureDependencies = new ArrayList<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh this one is actually a future of futures (it refers to being after pullBaseImageLayerFuturesFuture)

@@ -78,7 +80,8 @@ private BlobDescriptor afterBlobFuturesFuture()

CountingDigestOutputStream digestOutputStream =
new CountingDigestOutputStream(ByteStreams.nullOutputStream());
Blob blob = NonBlockingFutures.get(NonBlockingFutures.get(blobFuturesFuture));
Blob blob =
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe containerConfigurationBlob for specificity?

/** Depends on {@code blobFuturesFuture} and {@code pushAuthorizationFuture}. */
@Override
public ListenableFuture<BlobDescriptor> call() throws ExecutionException, InterruptedException {
List<ListenableFuture<?>> blobFuturesFutureDependencies = new ArrayList<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a after...FutureFuture too. afterBuildContainerConfigurationFutureFutureDependencies would be the exact name (meaning the dependencies for the afterBuildContainerConfigurationFutureFuture method), but it is quite long.

Copy link
Contributor Author

@TadCordle TadCordle May 4, 2018

Choose a reason for hiding this comment

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

How about afterBuildConfigFutureFuture so it isn't so long? I think when variable names get too long they become just as hard to understand as short names.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm yeah we try to avoid abbreviations, so not sure what the best practice here should be. @loosebazooka

Copy link
Member

Choose a reason for hiding this comment

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

Genereally we want to avoid abbreviations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Went with afterBuildConfigurationFutureFuture.

}

/** Depends on {@code blobFuturesFuture.get()} and {@code pushAuthorizationFuture}. */
private BlobDescriptor afterBlobFuturesFuture()
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

@TadCordle TadCordle merged commit 5173da8 into master May 4, 2018
@TadCordle TadCordle deleted the modularize_build_steps branch May 4, 2018 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants