diff --git a/pom.xml b/pom.xml index 65ad566c4..bf8133186 100644 --- a/pom.xml +++ b/pom.xml @@ -155,11 +155,6 @@ THE SOFTWARE. org.jenkins-ci.plugins.workflow workflow-step-api - - org.kohsuke - libzfs - 0.8 - io.jenkins configuration-as-code diff --git a/src/main/java/hudson/plugins/ec2/ebs/ZPoolExpandNotice.java b/src/main/java/hudson/plugins/ec2/ebs/ZPoolExpandNotice.java deleted file mode 100644 index a11eb5a9e..000000000 --- a/src/main/java/hudson/plugins/ec2/ebs/ZPoolExpandNotice.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2004-, Kohsuke Kawaguchi, Sun Microsystems, Inc., and a number of other of contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package hudson.plugins.ec2.ebs; - -import hudson.Extension; -import hudson.model.AdministrativeMonitor; - -/** - * {@link AdministrativeMonitor} that tells the user that ZFS pool is filling up and they need to add more storage. - * - * @author Kohsuke Kawaguchi - */ -@Extension -public class ZPoolExpandNotice extends AdministrativeMonitor { - /** - * Set by {@link ZPoolMonitor}. - */ - /* package */ boolean activated = false; - - public ZPoolExpandNotice() { - super("zpool.ebs"); - } - - @Override - public boolean isActivated() { - return activated; - } - - @Override - public String getDisplayName() { - return Messages.ZPoolExpandNotice_DisplayName(); - } -} diff --git a/src/main/java/hudson/plugins/ec2/ebs/ZPoolMonitor.java b/src/main/java/hudson/plugins/ec2/ebs/ZPoolMonitor.java deleted file mode 100644 index 68dbb79e5..000000000 --- a/src/main/java/hudson/plugins/ec2/ebs/ZPoolMonitor.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2004-, Kohsuke Kawaguchi, Sun Microsystems, Inc., and a number of other of contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package hudson.plugins.ec2.ebs; - -import hudson.Extension; -import hudson.model.AdministrativeMonitor; -import hudson.model.PeriodicWork; -import java.io.IOException; -import java.net.URL; -import java.util.concurrent.TimeUnit; -import jenkins.model.Jenkins; -import org.jvnet.solaris.libzfs.LibZFS; -import org.jvnet.solaris.libzfs.ZFSFileSystem; -import org.jvnet.solaris.libzfs.ZFSPool; - -/** - * Once an hour, check if the main zpool is that hosts $HUDSON_HOME has still enough free space. - * - * @author Kohsuke Kawaguchi - */ -@Extension -public class ZPoolMonitor extends PeriodicWork { - private static Boolean isInsideEC2; - - @Override - public long getRecurrencePeriod() { - return TimeUnit.HOURS.toMillis(1); - } - - @Override - protected void doRun() { - ZPoolExpandNotice zen = AdministrativeMonitor.all().get(ZPoolExpandNotice.class); - Jenkins jenkinsInstance = Jenkins.getInstanceOrNull(); - ZFSFileSystem fs = null; - try { - if (isInsideEC2() && jenkinsInstance != null) { - fs = new LibZFS().getFileSystemByMountPoint(jenkinsInstance.getRootDir()); - } - } catch (LinkageError e) { - // probably not running on OpenSolaris - } - if (fs == null || zen == null) { - cancel(); - return; - } - ZFSPool pool = fs.getPool(); - long a = pool.getAvailableSize(); - long t = pool.getSize(); - - // if the disk is 90% filled up and the available space is less than - // 1GB, - // notify the user - zen.activated = t / a > 10 && a < 1000L * 1000 * 1000; - } - - /** - * Returns true if this JVM runs inside EC2. - */ - public static synchronized boolean isInsideEC2() { - if (isInsideEC2 == null) { - try { - new URL("http://169.254.169.254/latest").openStream().close(); - isInsideEC2 = true; - } catch (IOException e) { - isInsideEC2 = false; - } - } - return isInsideEC2; - } -} diff --git a/src/main/resources/hudson/plugins/ec2/ebs/Messages.properties b/src/main/resources/hudson/plugins/ec2/ebs/Messages.properties deleted file mode 100644 index 5ca743d62..000000000 --- a/src/main/resources/hudson/plugins/ec2/ebs/Messages.properties +++ /dev/null @@ -1 +0,0 @@ -ZPoolExpandNotice.DisplayName=ZFS Pool Monitor diff --git a/src/main/resources/hudson/plugins/ec2/ebs/ZPoolExpandNotice/index.jelly b/src/main/resources/hudson/plugins/ec2/ebs/ZPoolExpandNotice/index.jelly deleted file mode 100644 index 08f2db56b..000000000 --- a/src/main/resources/hudson/plugins/ec2/ebs/ZPoolExpandNotice/index.jelly +++ /dev/null @@ -1,40 +0,0 @@ - - - - - -

JENKINS_HOME is almost full

- -

- Your JENKINS_HOME (${app.rootDir}) is almost full. - When this directory completely fills up, it will cause problems - because Jenkins can't store any more data. -

- -

- -
-
-
\ No newline at end of file diff --git a/src/main/resources/hudson/plugins/ec2/ebs/ZPoolExpandNotice/message.jelly b/src/main/resources/hudson/plugins/ec2/ebs/ZPoolExpandNotice/message.jelly deleted file mode 100644 index 78ef3cc04..000000000 --- a/src/main/resources/hudson/plugins/ec2/ebs/ZPoolExpandNotice/message.jelly +++ /dev/null @@ -1,33 +0,0 @@ - - - -
-
- Your data directory in Jenkins (${app.rootDir} - AKA HUDSON_HOME) is getting close to full. - You should act on it before it's completely full. - - -
-
\ No newline at end of file