public void discardWorkspace(AbstractProject<?, ?> project, FilePath ws) throws IOException, InterruptedException { ws.act(new DiscardWorkspace()); } private static class DiscardWorkspace extends MasterToSlaveFileCallable<Void> {
@Extension public static AdministrativeMonitor init() { String migrationTarget = SystemProperties.getString(ZFSInstaller.class.getName() + ".migrate"); if(migrationTarget!=null) { ByteArrayOutputStream out = new ByteArrayOutputStream(); StreamTaskListener listener = new StreamTaskListener(new ForkOutputStream(System.out, out)); try { if(migrate(listener,migrationTarget)) { // completed successfully return new MigrationCompleteNotice(); } } catch (Exception e) { // if we let any exception from here, it will prevent Hudson from starting. Functions.printStackTrace(e, listener.error("Migration failed")); } // migration failed return new MigrationFailedNotice(out); } // install the monitor if applicable ZFSInstaller zi = new ZFSInstaller(); if(zi.isActivated()) return zi; return null; }
public ZFSProvisioner(Node node) throws IOException, InterruptedException { rootDataset = node.getRootPath().act(new GetName()); } private static class GetName extends MasterToSlaveFileCallable<String> {
/** * Called from the management screen. */ public HttpResponse doAct(StaplerRequest req) throws ServletException, IOException { requirePOST(); Hudson.getInstance().checkPermission(Hudson.ADMINISTER); if(req.hasParameter("n")) { // we'll shut up disable(true); return HttpResponses.redirectViaContextPath("/manage"); } return new HttpRedirect("confirm"); }
StreamTaskListener listener = new StreamTaskListener(log); try { datasetName = createZfsFileSystem(listener,username,password); } catch (Exception e) { Functions.printStackTrace(e, listener.error(e.getMessage())); sendError(log.toString(),req,rsp); return; }.start();
/** * Called from the management screen. */ @RequirePOST public HttpResponse doAct(StaplerRequest req) throws ServletException, IOException { Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER); if(req.hasParameter("n")) { // we'll shut up disable(true); return HttpResponses.redirectViaContextPath("/manage"); } return new HttpRedirect("confirm"); }
private boolean shouldBeActive() { if(!System.getProperty("os.name").equals("SunOS") || disabled) // on systems that don't have ZFS, we don't need this monitor return false; try { LibZFS zfs = new LibZFS(); List<ZFSFileSystem> roots = zfs.roots(); if(roots.isEmpty()) return false; // no active ZFS pool // if we don't run on a ZFS file system, activate ZFSFileSystem hudsonZfs = zfs.getFileSystemByMountPoint(Jenkins.getInstance().getRootDir()); if(hudsonZfs!=null) return false; // already on ZFS // decide what file system we'll create ZFSFileSystem pool = roots.get(0); prospectiveZfsFileSystemName = computeHudsonFileSystemName(zfs,pool); return true; } catch (Exception e) { LOGGER.log(Level.WARNING, "Failed to detect whether Hudson is on ZFS",e); return false; } catch (LinkageError e) { LOGGER.info("No ZFS available. If you believe this is an error, increase the logging level to get the stack trace"); LOGGER.log(Level.FINE,"Stack trace of failed ZFS load",e); return false; } }
if(system(home,listener, "/usr/bin/cp","-pR",".", tmpDir.getAbsolutePath())!=0) { out.println("Failed to copy "+home+" to "+tmpDir); return false; if(system(new File("/"),listener,"/usr/bin/rm","-rf",backup.getAbsolutePath())!=0) { out.println("Failed to delete "+backup.getAbsolutePath()); return false;
public void prepareWorkspace(AbstractBuild<?,?> build, FilePath ws, final TaskListener listener) throws IOException, InterruptedException { final String name = build.getProject().getFullName(); ws.act(new PrepareWorkspace(name, listener)); } private class PrepareWorkspace extends MasterToSlaveFileCallable<Void> {
/** * Creates a ZFS file system to migrate the data to. * * <p> * This has to be done while we still have an interactive access with the user, since it involves the password. * * <p> * An exception will be thrown if the operation fails. A normal completion means a success. * * @return * The ZFS dataset name to migrate the data to. */ private String createZfsFileSystem(final TaskListener listener, String rootUsername, String rootPassword) throws IOException, InterruptedException, ZFSException { // capture the UID that Hudson runs under // so that we can allow this user to do everything on this new partition final int uid = LIBC.geteuid(); final int gid = LIBC.getegid(); passwd pwd = LIBC.getpwuid(uid); if(pwd==null) throw new IOException("Failed to obtain the current user information for "+uid); final String userName = pwd.pw_name; final File home = Jenkins.getInstance().getRootDir(); // this is the actual creation of the file system. // return true indicating a success return SU.execute(listener, rootUsername, rootPassword, new Create(listener, home, uid, gid, userName)); } private static class Create extends MasterToSlaveCallable<String, IOException> {
@Extension public static AdministrativeMonitor init() { String migrationTarget = System.getProperty(ZFSInstaller.class.getName() + ".migrate"); if(migrationTarget!=null) { ByteArrayOutputStream out = new ByteArrayOutputStream(); StreamTaskListener listener = new StreamTaskListener(new ForkOutputStream(System.out, out)); try { if(migrate(listener,migrationTarget)) { // completed successfully return new MigrationCompleteNotice(); } } catch (Exception e) { // if we let any exception from here, it will prevent Hudson from starting. e.printStackTrace(listener.error("Migration failed")); } // migration failed return new MigrationFailedNotice(out); } // install the monitor if applicable ZFSInstaller zi = new ZFSInstaller(); if(zi.isActivated()) return zi; return null; }
/** * Called from the management screen. */ public HttpResponse doAct(StaplerRequest req) throws ServletException, IOException { requirePOST(); Hudson.getInstance().checkPermission(Hudson.ADMINISTER); if(req.hasParameter("n")) { // we'll shut up disable(true); return HttpResponses.redirectViaContextPath("/manage"); } return new HttpRedirect("confirm"); }
/** * Called from the management screen. */ @RequirePOST public HttpResponse doAct(StaplerRequest req) throws ServletException, IOException { Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER); if(req.hasParameter("n")) { // we'll shut up disable(true); return HttpResponses.redirectViaContextPath("/manage"); } return new HttpRedirect("confirm"); }
private boolean shouldBeActive() { if(!System.getProperty("os.name").equals("SunOS") || disabled) // on systems that don't have ZFS, we don't need this monitor return false; try { List<NativeZfsFileSystem> roots = nativeUtils.getZfsRoots(); if(roots.isEmpty()) return false; // no active ZFS pool // if we don't run on a ZFS file system, activate NativeZfsFileSystem hudsonZfs = nativeUtils.getZfsByMountPoint(Hudson.getInstance().getRootDir()); if(hudsonZfs!=null) return false; // already on ZFS // decide what file system we'll create NativeZfsFileSystem pool = roots.get(0); prospectiveZfsFileSystemName = computeHudsonFileSystemName(pool); return true; } catch (Exception e) { LOGGER.log(Level.WARNING, "Failed to detect whether Hudson is on ZFS",e); return false; } catch (LinkageError e) { LOGGER.info("No ZFS available. If you believe this is an error, increase the logging level to get the stack trace"); LOGGER.log(Level.FINE,"Stack trace of failed ZFS load",e); return false; } }
@Extension public static AdministrativeMonitor init() { String migrationTarget = System.getProperty(ZFSInstaller.class.getName() + ".migrate"); if (migrationTarget != null) { ByteArrayOutputStream out = new ByteArrayOutputStream(); StreamTaskListener listener = new StreamTaskListener(new ForkOutputStream(System.out, out)); try { if (migrate(listener, migrationTarget)) { // completed successfully return new MigrationCompleteNotice(); } } catch (Exception e) { // if we let any exception from here, it will prevent Hudson from starting. e.printStackTrace(listener.error("Migration failed")); } // migration failed return new MigrationFailedNotice(out); } // install the monitor if applicable ZFSInstaller zi = new ZFSInstaller(); if (zi.isActivated()) { return zi; } return null; }
/** * Called from the management screen. */ public HttpResponse doAct(StaplerRequest req) throws ServletException, IOException { requirePOST(); Hudson.getInstance().checkPermission(Hudson.ADMINISTER); if (req.hasParameter("n")) { // we'll shut up disable(true); return HttpResponses.redirectViaContextPath("/manage"); } return new HttpRedirect("confirm"); }
@Extension public static AdministrativeMonitor init() { String migrationTarget = System.getProperty(ZFSInstaller.class.getName() + ".migrate"); if(migrationTarget!=null) { ByteArrayOutputStream out = new ByteArrayOutputStream(); StreamTaskListener listener = new StreamTaskListener(new ForkOutputStream(System.out, out)); try { if(migrate(listener,migrationTarget)) { // completed successfully return new MigrationCompleteNotice(); } } catch (Exception e) { // if we let any exception from here, it will prevent Hudson from starting. e.printStackTrace(listener.error("Migration failed")); } // migration failed return new MigrationFailedNotice(out); } // install the monitor if applicable ZFSInstaller zi = new ZFSInstaller(); if(zi.isActivated()) return zi; return null; }
/** * Called from the management screen. */ public HttpResponse doAct(StaplerRequest req) throws ServletException, IOException { requirePOST(); Hudson.getInstance().checkPermission(Hudson.ADMINISTER); if(req.hasParameter("n")) { // we'll shut up disable(true); return HttpResponses.redirectViaContextPath("/manage"); } return new HttpRedirect("confirm"); }
@Extension public static AdministrativeMonitor init() { String migrationTarget = System.getProperty(ZFSInstaller.class.getName() + ".migrate"); if(migrationTarget!=null) { ByteArrayOutputStream out = new ByteArrayOutputStream(); StreamTaskListener listener = new StreamTaskListener(new ForkOutputStream(System.out, out)); try { if(migrate(listener,migrationTarget)) { // completed successfully return new MigrationCompleteNotice(); } } catch (Exception e) { // if we let any exception from here, it will prevent Hudson from starting. e.printStackTrace(listener.error("Migration failed")); } // migration failed return new MigrationFailedNotice(out); } // install the monitor if applicable ZFSInstaller zi = new ZFSInstaller(); if(zi.isActivated()) return zi; return null; }
@Extension public static AdministrativeMonitor init() { String migrationTarget = SystemProperties.getString(ZFSInstaller.class.getName() + ".migrate"); if(migrationTarget!=null) { ByteArrayOutputStream out = new ByteArrayOutputStream(); StreamTaskListener listener = new StreamTaskListener(new ForkOutputStream(System.out, out)); try { if(migrate(listener,migrationTarget)) { // completed successfully return new MigrationCompleteNotice(); } } catch (Exception e) { // if we let any exception from here, it will prevent Hudson from starting. Functions.printStackTrace(e, listener.error("Migration failed")); } // migration failed return new MigrationFailedNotice(out); } // install the monitor if applicable ZFSInstaller zi = new ZFSInstaller(); if(zi.isActivated()) return zi; return null; }