Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

Jib refactor #1766

Merged
merged 11 commits into from
Mar 2, 2020
Merged

Jib refactor #1766

merged 11 commits into from
Mar 2, 2020

Conversation

devang-gaur
Copy link
Contributor

@devang-gaur devang-gaur commented Dec 3, 2019

blocked on fabric8io/docker-maven-plugin#1309

Edit: Not blocked anymore.

@devang-gaur
Copy link
Contributor Author

fixes #1763 , #1764 , #1738

CHANGELOG.md Outdated Show resolved Hide resolved
@manusa
Copy link
Member

manusa commented Jan 14, 2020

This constructor is redundant, please remove (public constructor with parameters automatically removes the possibility of a public no-args constructor for the class)

@manusa
Copy link
Member

manusa commented Jan 14, 2020

} catch (Exception ex) {
throw new UnsupportedOperationException(ex);
}

UnsupportedOperationExceptionis too generic, use at least Fabric8ServiceException like the rest of implementing classes.

@devang-gaur devang-gaur force-pushed the jib-refactor branch 2 times, most recently from cb77c35 to ccf6bf6 Compare January 30, 2020 02:01
@devang-gaur devang-gaur added jkube/pending The issue/PR has to be taken care of in JKube https://github.com/eclipse/jkube target/JKube Implementation to be performed in JKube and removed pr/wip Work in Progress, do not merge labels Jan 30, 2020
@devang-gaur
Copy link
Contributor Author

fixes #1765 , #1757

@devang-gaur devang-gaur force-pushed the jib-refactor branch 3 times, most recently from 02dc4e2 to 9238397 Compare February 5, 2020 11:21
@devang-gaur devang-gaur force-pushed the jib-refactor branch 2 times, most recently from ea80edb to feef207 Compare February 18, 2020 07:53
Copy link
Member

@rohanKanojia rohanKanojia left a comment

Choose a reason for hiding this comment

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

Looks good overall with few minor comments.

Also, it would be nice if we could add some more documentation about this feature's usage.

CHANGELOG.md Outdated Show resolved Hide resolved
samples/spring-boot/pom.xml Outdated Show resolved Hide resolved
private void jibPush(ImageConfiguration imageConfiguration) throws MojoExecutionException {
BuildImageConfiguration buildImageConfiguration = imageConfiguration.getBuildConfiguration();

String outputDir = preapareAbsoluteOutputDirPath(EMPTY_STRING).getAbsolutePath();
Copy link
Member

Choose a reason for hiding this comment

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

Something looks fishy here, Why are you passing an empty string to get output directory path?

}
}

private void jibPush(ImageConfiguration imageConfiguration) throws MojoExecutionException {
Copy link
Member

Choose a reason for hiding this comment

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

In my opinion, this method should go to JibService or JibServiceUtil since it's doing everything related to JIB here. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function uses a lot of pushmojo class properties here and actually uses the JibServiceUtil.pushImage function.
I don't think there's gonna be improvement in clarity by shifting this function to JibServiceUtil and making it unnecessarily static.

@manusa thoughts?

Copy link
Member

@manusa manusa Feb 25, 2020

Choose a reason for hiding this comment

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

Ideally PushMojo should be agnostic to the ImageService that implements it, so it doesn't make sense to have here a method named jibPush neither dockerPush neither buildahPush

On the other hand, our PushMojo is extending DMP PushMojo, so it's difficult to override the current ServiceHubFactory and its implementations in AbstractDockerMojo without a major refactor to have something similar to what's in BuildMojo(Fabric8ServiceHub).

So, only for FMP, I would make it static and move it to a helper class. This only requires passing 4 fields: MavenProject, ImageConfiguration, RegistryConfig and Logger.

Once we port this to JKube we'll perform a deeper refactor. It doesn't make much sense to work on this for FMP

@rohanKanojia
Copy link
Member

While testing this feature one thing I noticed is the change in logging during JIB mode. Somehow it seems to be messed up right now. Earlier it was more interactive and dynamic, now it seems redundant:

Current behavior(as per on this PR):

~/work/repos/jib-helloworld-sample : $ mvn fabric8:build
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------< io.fabric8.dmp.samples:dmp-sample-helloworld >------------
[INFO] Building dmp-sample-helloworld 4.5-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- fabric8-maven-plugin:4.5-SNAPSHOT:build (default-cli) @ dmp-sample-helloworld ---
[INFO] F8: Running in Kubernetes mode
[INFO] F8: Building Container image with JIB(Java Image Builder) in Kubernetes mode
[INFO] F8: JIB image build started
[INFO] F8: Preparing assembly files
[INFO] Copying files to /home/rohaan/work/repos/jib-helloworld-sample/target/docker/rohankanojia/helloworld-java/build/maven
[INFO] F8: Building Image Tarball at rohankanojia/helloworld-java.tar ...
[WARNING] F8: Base image 'openjdk' does not use a specific image digest - build may not be reproducible
[INFO] F8: Containerizing application with the following files:
[INFO] F8: 	:
[INFO] F8: 		/home/rohaan/work/repos/jib-helloworld-sample/target/docker/rohankanojia/helloworld-java/work/maven/dmp-sample-helloworld-4.5-SNAPSHOT.jar
[INFO] F8: Executing tasks:
[INFO] F8: [                              ] 0.0% complete
[INFO] F8: > building image to tar file
[INFO] F8: Executing tasks:
[INFO] F8: Executing tasks:
[INFO] F8: [                              ] 0.0% complete
[INFO] F8: > pulling base image manifest
[INFO] F8: > launching application layer builders
[INFO] F8: [                              ] 0.0% complete
[INFO] F8: > pulling base image manifest
[INFO] F8: Executing tasks:
[INFO] F8: [                              ] 0.0% complete
[INFO] F8: > pulling base image manifest
[INFO] F8: > building  layer
[INFO] F8: Executing tasks:
[INFO] F8: [======                        ] 20.0% complete
[INFO] F8: > pulling base image manifest
[INFO] F8: Executing tasks:
[INFO] F8: [======                        ] 20.0% complete
[INFO] F8: > retrieving credentials for registry-1.docker.io
[INFO] F8: No credentials could be retrieved for registry registry-1.docker.io
[INFO] F8: Executing tasks:
[INFO] F8: [=========                     ] 30.0% complete
[INFO] F8: > pulling base image manifest
[INFO] F8: Executing tasks:
[INFO] F8: [=========                     ] 30.0% complete
[INFO] F8: > pull container configuration sha256:6adc576f6a5804a5a8be24a959bda91821030adcb70437d4e3cf8fe32d60e36c
[INFO] F8: Executing tasks:
[INFO] F8: [============                  ] 40.0% complete
[INFO] F8: > building image to tar file
[INFO] F8: Executing tasks:
[INFO] F8: [============                  ] 40.0% complete
[INFO] F8: > launching base image layer pullers
[INFO] F8: Executing tasks:
[INFO] F8: [============                  ] 40.0% complete
[INFO] F8: > checking base image layer sha256:a1d217c4e16034b1dca5abb6ea80aabded93c73f35686d806d9f2aa8555743da
[INFO] F8: Executing tasks:
[INFO] F8: [==============                ] 46.7% complete
[INFO] F8: > launching base image layer pullers
[INFO] F8: Executing tasks:
[INFO] F8: [==============                ] 46.7% complete
[INFO] F8: > checking base image layer sha256:86607bb85307f4e017c6cc236573951482f1de084e0987480fecea9295c2f923
[INFO] F8: Executing tasks:
[INFO] F8: Executing tasks:
[INFO] F8: [================              ] 53.3% complete
[INFO] F8: > checking base image layer sha256:9595022a553604b9baa8a02558174325cd4be3fb6b7920f86a7e425fc4539de5
[INFO] F8: [==============                ] 46.7% complete
[INFO] F8: > checking base image layer sha256:86607bb85307f4e017c6cc236573951482f1de084e0987480fecea9295c2f923
[INFO] F8: > checking base image layer sha256:9595022a553604b9baa8a02558174325cd4be3fb6b7920f86a7e425fc4539de5
[INFO] F8: Executing tasks:
[INFO] F8: [==================            ] 60.0% complete
[INFO] F8: > building image to tar file
[INFO] F8: Executing tasks:
[INFO] F8: [==================            ] 60.0% complete
[INFO] F8: > building image format
[INFO] F8: Executing tasks:
[INFO] F8: [========================      ] 80.0% complete
[INFO] F8: > building image to tar file
[INFO] F8: Executing tasks:
[INFO] F8: [========================      ] 80.0% complete
[INFO] F8: > writing to tar file
[INFO] F8: Executing tasks:
[INFO] F8: [==============================] 100.0% complete
[INFO] F8:  /home/rohaan/work/repos/jib-helloworld-sample/target/docker/rohankanojia/helloworld-java.tar successfully built
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  12.819 s
[INFO] Finished at: 2020-02-20T19:52:25+05:30
[INFO] ------------------------------------------------------------------------
~/work/repos/jib-helloworld-sample : $ 

Behavior on 4.4.0:
Peek 2020-02-20 19-55

@manusa
Copy link
Member

manusa commented Feb 20, 2020

While testing this feature one thing I noticed is the change in logging during JIB mode. Somehow it seems to be messed up right now. Earlier it was more interactive and dynamic, now it seems redundant...

This is something that I changed because previous logging was relying on JIB's own logger which in order to be instantiated required the creation of fake Executors which is very nasty and dirty.

Logging can be improved but will probably need some changed in our own logger implementations. My suggestion is to leave this as is for FMP, port it to JKube, and then improve the UX in a separate issue.

samples/spring-boot/pom.xml Outdated Show resolved Hide resolved
samples/spring-boot/pom.xml Outdated Show resolved Hide resolved
@@ -23,6 +23,9 @@ Usage:
```

### 4.5-SNAPSHOT
* Refactor #1766: Jib Refactor
* Revert #1737 : Reverted "Wrong Jib output directory in Maven multi-module build"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rohanKanojia made changes, how about this?

Copy link
Member

@manusa manusa left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -178,6 +179,39 @@
</fmp-service>
</config>
</enricher>
<!-- sample assembly configuration. make sure all the directories configured exist. -->
<!--<images>
<image>
Copy link
Member

Choose a reason for hiding this comment

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

Is it okay to leave this code as commented?

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 have knowingly added this here in the sample pom. We actually don't have any sample demonstrating AssemblyConfig feature so I thought this will be helpful.

if (value == null) {
value = project.getProperties().getProperty(key);
}
return value;
Copy link
Member

Choose a reason for hiding this comment

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

This looks like a util function, I think there should already be some method available in EnvUtil for this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This method should be inherited from the AbstractFabric8Mojo class, but since BuildMojo and PushMojo don't inherit the AbstractFabric8Mojo this method has been defined separately for just these two cases.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
jkube/pending The issue/PR has to be taken care of in JKube https://github.com/eclipse/jkube target/JKube Implementation to be performed in JKube
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants