-
Notifications
You must be signed in to change notification settings - Fork 156
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
Add archive type option #494
Add archive type option #494
Conversation
cc @pickypg |
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.
One real comment and one question.
import com.elastic.support.util.ResourceCache; | ||
import com.elastic.support.util.SystemProperties; | ||
import com.elastic.support.util.SystemUtils; | ||
import com.elastic.support.util.*; |
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.
Not a fan of *
imports, but it's fine for this since the code already has others.
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.
Done.
It's weird, IntelliJ keeps adding them back automatically.
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.
IntelliJ has pretty low defaults for doing that. Most teams I work on suggest setting the limit to 9999.
@@ -132,8 +132,7 @@ public boolean runInteractive() { | |||
return Collections.singletonList("Invalid Date or Time format. Please enter the date in format YYYY-MM-dd HH:mm"); | |||
} | |||
|
|||
return emptyList; | |||
|
|||
return null; |
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.
Careful with returning null
instead of an empty list. Some parts of the code expect things that they cannot safely expect.
Given that this code relates explicitly to fetching stack monitoring data, I am unsure if you tested this behavior?
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.
Done.
This PR also fixes a nasty bug. When port
is invalid, many port validation errors are printed out. This was happening because emptyList
is mutable and shared. I have another PR in the queue to prevent those issues in the future.
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.
@pickypg actually, caller does expect it to return null
and I changed it back in cd1a275.
Here is where it gets called:
support-diagnostics/src/main/java/com/elastic/support/monitoring/MonitoringExportInputs.java
Lines 103 to 106 in e48f0d7
if (!listClusters) { | |
errors.addAll(ObjectUtils.defaultIfNull(validateCluster(clusterId), emptyList)); | |
errors.addAll(ObjectUtils.defaultIfNull(validateInterval(interval), emptyList)); | |
errors.addAll(ObjectUtils.defaultIfNull(validateTimeWindow(), emptyList)); |
When validateTimeWindow()
returns null
it defaults to emptyList
. When it returns an empty list, it also adds an empty list to errors
.
In the end, it doesn't really matter if validateTimeWindow()
returns a empty list or null
.
I will fix those issues in my next PR.
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.
LGTM
Part of #485.
Right, the utility tries to zip the output dir, if zip fails, it fallbacks to tar.gz.
However, this should be deterministic, devs should be able to choose which output file type they want: zip or tar.gz.