-
Notifications
You must be signed in to change notification settings - Fork 79
Add ability to disable fingerprint recording #85
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ | |
| */ | ||
| package org.jenkinsci.plugins.docker.commons.fingerprint; | ||
|
|
||
| import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; | ||
| import hudson.BulkChange; | ||
| import hudson.model.Fingerprint; | ||
| import hudson.model.Run; | ||
|
|
@@ -39,6 +40,8 @@ | |
| import javax.annotation.Nonnull; | ||
| import jenkins.model.FingerprintFacet; | ||
| import org.apache.commons.lang.StringUtils; | ||
| import org.kohsuke.accmod.Restricted; | ||
| import org.kohsuke.accmod.restrictions.NoExternalUse; | ||
|
|
||
| /** | ||
| * Entry point into fingerprint related functionalities in Docker. | ||
|
|
@@ -47,7 +50,15 @@ | |
| public class DockerFingerprints { | ||
|
|
||
| private static final Logger LOGGER = Logger.getLogger(DockerFingerprints.class.getName()); | ||
|
|
||
|
|
||
| /** | ||
| * System property, which, when set to true (default false), disables | ||
| * recording of new fingerprints. | ||
| */ | ||
| @SuppressFBWarnings(value="MS_SHOULD_BE_FINAL", justification="mutable for scripts") | ||
| @Restricted(NoExternalUse.class) | ||
| public static boolean DISABLE = Boolean.getBoolean(DockerFingerprints.class.getName() + ".DISABLE"); | ||
|
|
||
| private DockerFingerprints() {} // no instantiation | ||
|
|
||
| /** | ||
|
|
@@ -221,6 +232,10 @@ private DockerFingerprints() {} // no instantiation | |
| * Adds a new {@link ContainerRecord} for the specified image, creating necessary intermediate objects as it goes. | ||
| */ | ||
| public static void addRunFacet(@Nonnull ContainerRecord record, @Nonnull Run<?,?> run) throws IOException { | ||
| if (DISABLE) { | ||
| LOGGER.info("Recording of fingerprints is disabled, no RUN fingerprint record will be made."); | ||
| return; | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it also make sense to add logging on the FINE or INFO levels?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not the expert here, after all, I'm the one making a change to disable all of this, so I have a hard time finding a point where it would be useful. But if you can see a reason for adding it, I'll happily add it :) Besides, at level FINE/INFO it would require the user to actively set the log level in order to get it to the system logs etc (have it on by default would be way to chatty IMHO). |
||
| String imageId = record.getImageId(); | ||
| Fingerprint f = forImage(run, imageId); | ||
| synchronized (f) { | ||
|
|
@@ -256,6 +271,10 @@ public static void addRunFacet(@Nonnull ContainerRecord record, @Nonnull Run<?,? | |
| * @param run the build in which the image building occurred | ||
| */ | ||
| public static void addFromFacet(@CheckForNull String ancestorImageId, @Nonnull String descendantImageId, @Nonnull Run<?,?> run) throws IOException { | ||
| if (DISABLE) { | ||
| LOGGER.info("Recording of fingerprints is disabled, no FROM fingerprint record will be made."); | ||
| return; | ||
| } | ||
| long timestamp = System.currentTimeMillis(); | ||
| if (ancestorImageId != null) { | ||
| Fingerprint f = forImage(run, ancestorImageId); | ||
|
|
@@ -311,4 +330,13 @@ public static void addFromFacet(@CheckForNull String ancestorImageId, @Nonnull S | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * Indicates whether recording of new fingerprints are disabled. | ||
| * | ||
| * @return true if fingerprint recording is disabled, otherwise false. | ||
| */ | ||
| public static boolean isFingerprintsDisabled() { | ||
| return DISABLE; | ||
| } | ||
|
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.