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

Plugin script: Fix ES_HOME with spaces #12508

Merged
merged 2 commits into from Aug 3, 2015
Merged

Conversation

nik9000
Copy link
Member

@nik9000 nik9000 commented Jul 28, 2015

When ES_HOME has spaces we get funky "cannot find main class directory>"
errors. This makes them stop by escaping directories and using eval instead
of exec.

Closes #12504

When ES_HOME has spaces we get funky "cannot find main class directory>"
errors. This makes them stop by escaping directories and using eval instead
of exec.

Closes elastic#12504
@nik9000 nik9000 added >bug :Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts v1.7.2 labels Jul 28, 2015
@nik9000
Copy link
Member Author

nik9000 commented Jul 28, 2015

I'm not sure if this is 1.7.2 or 1.7.1.

@electrical
Copy link
Contributor

@tlrx @spinscale could you guys review this? thanks!

@jaymode
Copy link
Member

jaymode commented Jul 30, 2015

I tested this out in a directory with spaces and this fixes the issue described in the ticket. If we also have a space in one of the parameters like the plugin URL we still have an issue in that the parameter is split into two by the space.

bin/plugin install plugin -u "file:///path/with space/plugin.zip"

It will try to install space/plugin.zip

The fix is similar to what's already been done here and it would be awesome to get it included now:

# real getopt cannot be used because we need to hand options over to the PluginManager
while [ $# -gt 0 ]; do
  case $1 in
    -D*=*)
      properties="$properties \"$1\""
      ;;
    -D*)
      var="$1"
      shift
      properties="$properties \"$var\"=\"$1\""
      ;;
    *)
      args="$args \"$1\""
  esac
  shift
done

@nik9000 what do you think? If you'd prefer to keep it separate, we can and I can open up a different PR.

@nik9000
Copy link
Member Author

nik9000 commented Jul 30, 2015

@nik9000 what do you think? If you'd prefer to keep it separate, we can and I can open up a different PR.

It makes sense to me. This isn't really my area of expertise but I'm happy to add it.

BTW, this is against the 1.7 branch and I'm not sure that this is still an issue in 2.0. Is this another one of things we should just wait on 2.0 to fix?

@jaymode
Copy link
Member

jaymode commented Jul 30, 2015

I also tested with 2.0 and it is still an issue there as well, so we definitely need to fix it in master.

@nik9000
Copy link
Member Author

nik9000 commented Jul 30, 2015

Cool. In that case I'll grab this issue in a bit and fix the spaces in
plugin paths issue. I'll also look at adding some bats tests. Then forward
port to 2.0.....

On Thu, Jul 30, 2015 at 10:17 AM, Jay Modi notifications@github.com wrote:

I also tested with 2.0 and it is still an issue there as well, so we
definitely need to fix it in master.


Reply to this email directly or view it on GitHub
#12508 (comment)
.

@nik9000 nik9000 added WIP and removed review labels Jul 30, 2015
@nik9000
Copy link
Member Author

nik9000 commented Jul 30, 2015

Swap review for WIP because I have to add another fix and some bats tests.

@nik9000
Copy link
Member Author

nik9000 commented Jul 30, 2015

@tlrx do you have any special setup that you do to run bats? The bats stuff in 1.7 claims to be very destructive to you system so I spun up an ubuntu vm to test it in.

Also add some bats tests
@nik9000 nik9000 added review and removed WIP labels Jul 30, 2015
@nik9000
Copy link
Member Author

nik9000 commented Jul 30, 2015

Ok - ready for review I think.


# Checks that the plugin is correctly removed
assert_file_not_exist "$ES_DIR/bin/shield"
assert_file_exist "$ES_DIR/config/shield"
Copy link
Contributor

Choose a reason for hiding this comment

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

$ES_DIR/config is intentionally not removed? might be worth a comment in the test

Copy link
Member Author

Choose a reason for hiding this comment

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

Honestly? I have no idea - this is the same checks that are done when the installation directory doesn't have a space. I'd love there to be some method call for this but the other tests seemed to prefer copy and paste over a refactor and I was afraid to do it - especially as I'll have to forward port this to 1.7 and my bash-foo is weak.

Copy link
Member Author

Choose a reason for hiding this comment

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

"I just copy and pasted like the last guy" <--- its a poor defense but in this case I'm sticking to it.

Copy link
Member

Choose a reason for hiding this comment

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

$ES_DIR/config is intentionally not removed? might be worth a comment in the test

Configuration is not removed when removing a plugin. I think elasticsearch configuration is removed when purging the package.

@jaymode
Copy link
Member

jaymode commented Jul 30, 2015

LGTM. Built and ran it in a directory with spaces and used a path with spaces as well.

@tlrx
Copy link
Member

tlrx commented Aug 3, 2015

@tlrx do you have any special setup that you do to run bats? The bats stuff in 1.7 claims to be very destructive to you system so I spun up an ubuntu vm to test it in.

Yeah, always use a vm to run the tests! They install/remove packages, user and dirs. See https://github.com/elastic/elasticsearch/blob/master/TESTING.asciidoc#testing-scripts

@tlrx
Copy link
Member

tlrx commented Aug 3, 2015

LGTM

BATS tests succeed on Debian 7.8, Debian 8, CentOS 6.6, CentOS 7, Ubuntu 12.04 and Ubuntu 15.04

@electrical
Copy link
Contributor

LGTM. ready to merge i think.

@nik9000
Copy link
Member Author

nik9000 commented Aug 3, 2015

BATS tests succeed on Debian 7.8, Debian 8, CentOS 6.6, CentOS 7, Ubuntu 12.04 and Ubuntu 15.04

That is a good list.

nik9000 added a commit that referenced this pull request Aug 3, 2015
Plugin script: Fix ES_HOME and plugin directory with spaces
@nik9000 nik9000 merged commit ae548e1 into elastic:1.7 Aug 3, 2015
@clintongormley clintongormley added :Core/Infra/Plugins Plugin API and infrastructure and removed :Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts labels Aug 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Core/Infra/Plugins Plugin API and infrastructure v1.7.2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants