-
Notifications
You must be signed in to change notification settings - Fork 74
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
Generate support bundle Async #617
Generate support bundle Async #617
Conversation
@@ -309,11 +314,17 @@ private WebResponse doBundle(String action, String bundle, String user, String e | |||
} | |||
|
|||
private ZipFile downloadBundle(String s) throws IOException, SAXException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the test remain the same , as the only thing that changed was how the zip file was obtained, previoulsy it was a sync call , now its async , we just fetch the zip file after the support bundle is created
…ugin into generate-support-bundle-async
src/test/java/com/cloudbees/jenkins/support/SupportActionTest.java
Outdated
Show resolved
Hide resolved
src/test/java/com/cloudbees/jenkins/support/SupportActionTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments, but seems to work as advertised.
if (!outputDir.mkdirs()) { | ||
throw new IOException("Failed to create directory: " + outputDir.getAbsolutePath()); | ||
Path outputDir = SUPPORT_BUNDLE_CREATION_FOLDER.resolve(taskId.toString()); | ||
if (!Files.exists(outputDir)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My point was that you do not need to do this check: createDirectories
quietly returns if the directory already exists.
try { | ||
Files.createDirectories(outputDir); | ||
} catch (IOException e) { | ||
throw new IOException("Failed to create directory: " + outputDir.toAbsolutePath(), e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably unnecessary to wrap and rethrow; the original IOException
would include sufficient details.
try (FileOutputStream fileOutputStream = | ||
new FileOutputStream(new File(outputDir.toString(), SYNC_SUPPORT_BUNDLE))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preferable to use Files.newOutputStream
.
@@ -517,7 +520,7 @@ public ProgressiveRendering getGeneratorByTaskId(String taskId) throws Exception | |||
} | |||
|
|||
public static class SupportBundleAsyncGenerator extends ProgressiveRendering { | |||
private final Logger logger = Logger.getLogger(SupportBundleAsyncGenerator.class.getName()); | |||
private final Logger logger = Logger.getLogger(SupportAction.class.getName()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No I meant you could just use
support-core-plugin/src/main/java/com/cloudbees/jenkins/support/SupportAction.java
Line 105 in effed5e
private final Logger logger = Logger.getLogger(SupportAction.class.getName()); |
if (!outputDir.mkdirs()) { | ||
throw new IOException("Failed to create directory: " + outputDir.getAbsolutePath()); | ||
Path outputDir = SUPPORT_BUNDLE_CREATION_FOLDER.resolve(taskId.toString()); | ||
if (!Files.exists(outputDir)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
} catch (IOException e) { | ||
throw new IOException("Failed to create directory: " + outputDir.toAbsolutePath(), e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
} | ||
} | ||
|
||
try (FileOutputStream fileOutputStream = new FileOutputStream(new File(outputDir, supportBundleName))) { | ||
try (FileOutputStream fileOutputStream = | ||
new FileOutputStream(new File(outputDir.toString(), supportBundleName))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
try (ServletOutputStream outputStream = rsp.getOutputStream(); | ||
FileInputStream inputStream = new FileInputStream(bundleFile)) { | ||
IOUtils.copy(inputStream, outputStream); | ||
try (ServletOutputStream outputStream = rsp.getOutputStream()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stylistically, just
try (ServletOutputStream outputStream = rsp.getOutputStream()) { | |
try (OutputStream outputStream = rsp.getOutputStream()) { |
or
try (ServletOutputStream outputStream = rsp.getOutputStream()) { | |
try (var outputStream = rsp.getOutputStream()) { |
suffices
@@ -347,7 +345,7 @@ private ZipFile downloadSupportBundleByButtonClick() throws IOException, SAXExce | |||
AtomicReference<HtmlPage> pageRef = new AtomicReference<>(page); | |||
|
|||
HtmlPage finalPage = page; | |||
await().timeout(10, TimeUnit.HOURS).until(() -> { | |||
await().timeout(10, TimeUnit.SECONDS).until(() -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or simply
await().timeout(10, TimeUnit.SECONDS).until(() -> { | |
await().until(() -> { |
since this is the default timeout
The problem that I am trying to solve
Currently, when users click on the "Generate Bundle" button on the /jenkins/support/ page, There is no user feedback.In case the generation process takes too long, the request may result in a 503 Timeout
Here is the fix
We will generate support bundle anync in backend which we poll for its status from UI.
The support bundle will be saved in the tmp folder, this will be deleted once the user has downloaded the files
here is a gif for the UX