Skip to content
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

Merged
merged 7 commits into from
May 11, 2021

Conversation

brunofarache
Copy link
Contributor

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.

@brunofarache brunofarache requested a review from a team as a code owner May 10, 2021 20:52
@brunofarache
Copy link
Contributor Author

cc @pickypg

Copy link
Member

@pickypg pickypg left a 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.*;
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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;
Copy link
Member

@pickypg pickypg May 10, 2021

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?

Copy link
Contributor Author

@brunofarache brunofarache May 10, 2021

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.

Copy link
Contributor Author

@brunofarache brunofarache May 10, 2021

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:

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.

Copy link
Member

@pickypg pickypg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pickypg pickypg merged commit 5735f20 into elastic:main May 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants