Skip to content

Commit 2cbf0a1

Browse files
committed
Logging updates & DockerConfig fix.
1 parent 35ed765 commit 2cbf0a1

File tree

16 files changed

+65
-43
lines changed

16 files changed

+65
-43
lines changed

client/src/main/java/dev/snowdrop/buildpack/BuildpackBuild.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ private String selectPlatformLevel(DockerConfig dc, PlatformConfig pc, BuilderIm
6666

6767
public int build(){
6868

69+
log.info("Buildpack build requested with config: \n"+
70+
" - builder "+config.getBuilderImage().getReference()+"\n"+
71+
" - logLevel "+config.getLogConfig().getLogLevel());
72+
73+
log.info("Pulling Builder image");
74+
6975
//obtain & pull & inspect Builder image.
7076
BuilderImage builder = new BuilderImage(config.getDockerConfig(),
7177
config.getPlatformConfig(),
@@ -77,18 +83,22 @@ public int build(){
7783
config.getPlatformConfig(),
7884
builder);
7985

86+
log.info("Pulling Run Image(s)");
87+
8088
//precache the runimages in the orig builder before extending it.
8189
builder.getRunImages(new Version(activePlatformLevel));
90+
91+
log.debug("Creating Ephemeral Builder Image...");
92+
8293
//create the extended builder image.
8394
BuilderImage extendedBuilder = BuildContainerUtils.createBuildImage(config.getDockerConfig().getDockerClient(),
8495
builder,
8596
null,
8697
null,
8798
null);
8899
try{
89-
log.info("Initiating buildpack build with config \n"+
100+
log.info("Initiating buildpack build with derived configuration: \n"+
90101
" - ephemeralBuilder "+extendedBuilder.getImage().getReference()+"\n"+
91-
" - baseBuilder "+builder.getImage().getReference()+"\n"+
92102
" - activePlatformLevel "+activePlatformLevel+"\n"+
93103
" - build uid:gid "+extendedBuilder.getUserId()+":"+extendedBuilder.getGroupId()+"\n"+
94104
" - withExtensions "+extendedBuilder.hasExtensions());

client/src/main/java/dev/snowdrop/buildpack/config/DockerConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ public DockerConfig(
5757
}
5858
}
5959

60-
public Integer getPullTimeout(){
60+
public Integer getPullTimeoutSeconds(){
6161
return this.pullTimeoutSeconds;
6262
}
6363

6464
public Integer getPullRetryCount(){
6565
return this.pullRetryCount;
6666
}
6767

68-
public Integer getPullRetryIncrease(){
68+
public Integer getPullRetryIncreaseSeconds(){
6969
return this.pullRetryIncreaseSeconds;
7070
}
7171

client/src/main/java/dev/snowdrop/buildpack/docker/ContainerUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public static void addContentToContainer(DockerClient dc, String containerId, St
186186

187187
public static void addContentToContainer(DockerClient dc, String containerId, String pathInContainer, Integer userId, Integer groupId, ContainerEntry... entries) {
188188

189-
log.info("Adding to container "+containerId+" pathInContainer "+pathInContainer);
189+
log.debug("Adding to container "+containerId+" pathInContainer "+pathInContainer);
190190

191191
Set<String> seenDirs = new HashSet<>();
192192
// Don't add entry for "/", causes issues with tar format.
@@ -252,7 +252,7 @@ public void run() {
252252
}
253253
};
254254

255-
log.info("Copying archive to container at "+containerPath);
255+
log.debug("Copying archive to container at "+containerPath);
256256

257257
Runnable reader = new Runnable() {
258258
@Override

client/src/main/java/dev/snowdrop/buildpack/docker/ImageUtils.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,14 @@ public static void pullImages(DockerConfig config, String... imageNames) {
4848
if(config.getPullPolicy() == DockerConfig.PullPolicy.IF_NOT_PRESENT) {
4949
// list the current known images
5050
List<Image> li = dc.listImagesCmd().exec();
51+
52+
log.debug("Requested Images "+imageNameSet);
5153
for (Image i : li) {
5254
if (i.getRepoTags() == null) {
5355
continue;
5456
}
5557
for (String it : i.getRepoTags()) {
58+
log.debug("Known Image : "+it);
5659
if (imageNameSet.contains(it)) {
5760
imageNameSet.remove(it);
5861
}
@@ -82,7 +85,7 @@ public static void pullImages(DockerConfig config, String... imageNames) {
8285
boolean allDone = false;
8386
while(!allDone && retryCount<=config.getPullRetryCount()){
8487
allDone = true;
85-
long thisWait = config.getPullTimeout()+(retryCount*config.getPullRetryIncrease());
88+
long thisWait = config.getPullTimeoutSeconds()+(retryCount*config.getPullRetryIncreaseSeconds());
8689
for (Entry<String, PullImageResultCallback> e : pircMap.entrySet()) {
8790
boolean done = false;
8891
try {

client/src/main/java/dev/snowdrop/buildpack/docker/VolumeUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ private static boolean internalAddContentToVolume(DockerClient dc, String volume
6767
List<String> command = Stream.of("").collect(Collectors.toList());
6868
String dummyId = ContainerUtils.createContainer(dc, useImage, command, new VolumeBind(volumeName, mountPrefix));
6969
try{
70-
log.info("Adding content to volume "+volumeName+" under prefix "+prefix+" using image "+useImage+" with volume bound at "+mountPrefix+" temp container id "+dummyId);
70+
log.debug("Adding content to volume "+volumeName+" under prefix "+prefix+" using image "+useImage+" with volume bound at "+mountPrefix+" temp container id "+dummyId);
7171
ContainerUtils.addContentToContainer(dc, dummyId, prefix, uid, gid, entries);
7272
return true;
7373
}finally{

client/src/main/java/dev/snowdrop/buildpack/lifecycle/LifecycleExecutor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ public int execute() {
136136
if(rc!=0) break;
137137
}while(false);
138138
}
139+
if(rc==0){
140+
log.info("Buildpack build phases complete, application image is at "+config.getOutputImage().getReference());
141+
}
139142
return rc;
140143
}finally{
141144
//allow factory to clean up any volumes created

client/src/main/java/dev/snowdrop/buildpack/lifecycle/LifecyclePhaseFactory.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,16 @@ public String getContainerForPhase(String args[], Integer runAsId){
104104
dockerConfig.getDockerNetwork(),
105105
binds);
106106

107-
log.info("- mounted " + buildCacheVolume + " at " + CACHE_VOL_PATH);
108-
log.info("- mounted " + launchCacheVolume + " at " + LAUNCH_CACHE_VOL_PATH);
109-
log.info("- mounted " + kanikoCacheVolume + " at " + KANIKO_VOL_PATH);
110-
log.info("- mounted " + applicationVolume + " at " + WORKSPACE_VOL_PATH);
111-
log.info("- mounted " + platformVolume + " at " + PLATFORM_VOL_PATH);
107+
log.debug("- mounted " + buildCacheVolume + " at " + CACHE_VOL_PATH);
108+
log.debug("- mounted " + launchCacheVolume + " at " + LAUNCH_CACHE_VOL_PATH);
109+
log.debug("- mounted " + kanikoCacheVolume + " at " + KANIKO_VOL_PATH);
110+
log.debug("- mounted " + applicationVolume + " at " + WORKSPACE_VOL_PATH);
111+
log.debug("- mounted " + platformVolume + " at " + PLATFORM_VOL_PATH);
112112
if(dockerConfig.getUseDaemon())
113-
log.info("- mounted " + dockerConfig.getDockerSocket() + " at " + LifecyclePhaseFactory.DOCKER_SOCKET_PATH);
114-
log.info("- mounted " + outputVolume + " at " + LAYERS_VOL_PATH);
115-
log.info("- container id " + id);
116-
log.info("- image reference "+builder.getImage().getReference());
113+
log.debug("- mounted " + dockerConfig.getDockerSocket() + " at " + LifecyclePhaseFactory.DOCKER_SOCKET_PATH);
114+
log.debug("- mounted " + outputVolume + " at " + LAYERS_VOL_PATH);
115+
log.debug("- container id " + id);
116+
log.debug("- image reference "+builder.getImage().getReference());
117117
return id;
118118
}
119119

@@ -159,13 +159,13 @@ public void createVolumes(List<Content> content){
159159
// add the application to the volume. Note we are placing it at /content,
160160
// because the volume mountpoint is mounted such that the user has no perms to create
161161
// new content there, but subdirs are ok.
162-
log.info("There are "+content.size()+" entries to add for the app dir");
162+
log.debug("There are "+content.size()+" entries to add for the app dir");
163163
List<ContainerEntry> appEntries = content
164164
.stream()
165165
.flatMap(c -> c.getContainerEntries().stream())
166166
.collect(Collectors.toList());
167167

168-
log.info("Adding aplication to volume "+applicationVolume);
168+
log.info("Adding application to volume "+applicationVolume);
169169
VolumeUtils.addContentToVolume(dockerConfig.getDockerClient(),
170170
applicationVolume,
171171
builder.getImage().getReference(),
@@ -204,7 +204,7 @@ public void createVolumes(List<Content> content){
204204
}
205205

206206
public void tidyUp(){
207-
log.info("- tidying up the build volumes");
207+
log.info("Post Build cleanup activites:");
208208
// remove volumes
209209
// (note when/if we persist the cache between builds, we'll be more selective here over what we remove)
210210
if (buildCacheConfig.getDeleteCacheAfterBuild()) {
@@ -222,7 +222,7 @@ public void tidyUp(){
222222
VolumeUtils.removeVolume(dockerConfig.getDockerClient(), outputVolume);
223223
VolumeUtils.removeVolume(dockerConfig.getDockerClient(), platformVolume);
224224

225-
log.info("- build volumes tidied up");
225+
log.info("- temporary build volumes removed");
226226
}
227227

228228
public BuilderImage getBuilderImage(){

client/src/main/java/dev/snowdrop/buildpack/lifecycle/phases/Analyzer.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ public ContainerStatus runPhase(dev.snowdrop.buildpack.Logger logger, boolean us
6565

6666
String id = factory.getContainerForPhase(args.toArray(), runAsId);
6767
try{
68-
log.info("- analyze container id " + id+ " will be run with uid "+runAsId);
68+
log.info("Analyze container id " + id+ " will be run with uid "+runAsId);
69+
log.debug("- container args "+args);
6970

7071
// launch the container!
7172
log.info("- launching analyze container");
@@ -82,7 +83,7 @@ public ContainerStatus runPhase(dev.snowdrop.buildpack.Logger logger, boolean us
8283

8384
// wait for the container to complete, and retrieve the exit code.
8485
int rc = factory.getDockerConfig().getDockerClient().waitContainerCmd(id).exec(new WaitContainerResultCallback()).awaitStatusCode();
85-
log.info("Buildpack analyze container complete, with exit code " + rc);
86+
log.info("Analyze container complete, with exit code " + rc);
8687

8788
return ContainerStatus.of(rc,id);
8889
}catch(Exception e){

client/src/main/java/dev/snowdrop/buildpack/lifecycle/phases/Builder.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public ContainerStatus runPhase(dev.snowdrop.buildpack.Logger logger, boolean us
3838
int runAsId = factory.getBuilderImage().getUserId();
3939
String id = factory.getContainerForPhase(args.toArray(), runAsId);
4040
try{
41-
log.info("- extender container id " + id+ " will be run with uid "+runAsId);
41+
log.info("Builder container id " + id+ " will be run with uid "+runAsId);
42+
log.debug("- container args "+args);
4243

4344
// launch the container!
4445
log.info("- launching builder container");
@@ -55,7 +56,7 @@ public ContainerStatus runPhase(dev.snowdrop.buildpack.Logger logger, boolean us
5556

5657
// wait for the container to complete, and retrieve the exit code.
5758
int rc = factory.getDockerConfig().getDockerClient().waitContainerCmd(id).exec(new WaitContainerResultCallback()).awaitStatusCode();
58-
log.info("Buildpack builder container complete, with exit code " + rc);
59+
log.info("Builder container complete, with exit code " + rc);
5960

6061
return ContainerStatus.of(rc,id);
6162
}catch(Exception e){

client/src/main/java/dev/snowdrop/buildpack/lifecycle/phases/Creator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ public ContainerStatus runPhase(dev.snowdrop.buildpack.Logger logger, boolean us
5050
int runAsId = 0;
5151
String id = factory.getContainerForPhase(args.toArray(), runAsId);
5252
try{
53-
log.info("- creator container id " + id+ " will be run with uid "+runAsId+" and args "+args);
53+
log.info("Creator container id " + id+ " will be run with uid "+runAsId);
54+
log.debug("- container args "+args);
5455

5556
// launch the container!
5657
log.info("- launching build container");
@@ -67,7 +68,7 @@ public ContainerStatus runPhase(dev.snowdrop.buildpack.Logger logger, boolean us
6768

6869
// wait for the container to complete, and retrieve the exit code.
6970
int rc = factory.getDockerConfig().getDockerClient().waitContainerCmd(id).exec(new WaitContainerResultCallback()).awaitStatusCode();
70-
log.info("Buildpack container complete, with exit code " + rc);
71+
log.info("Creator container complete, with exit code " + rc);
7172

7273
return ContainerStatus.of(rc,id);
7374
}catch(Exception e){

0 commit comments

Comments
 (0)