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

Remove multi instance support #1085

Merged
merged 41 commits into from
Jun 9, 2020
Merged

Remove multi instance support #1085

merged 41 commits into from
Jun 9, 2020

Conversation

fatmcgav
Copy link
Contributor

As indicated in #1068, as precursor to adding support for Elasticsearch 7.x is removing the multi-instance support from this module.

Unfortunately there was no clean way of splitting the changes into smaller PR's, and the history could probably do with some cleanup...

TODO:

  • Some more test cleanup
  • Update documentation
  • Remove any additional unused code.

@fatmcgav fatmcgav requested a review from tylerjl April 20, 2020 13:01
@fatmcgav fatmcgav self-assigned this Apr 20, 2020
Copy link
Contributor

@tylerjl tylerjl left a comment

Choose a reason for hiding this comment

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

This is looking good! I added a few comments here and there, overall it looks right though. I understand that my comment about jvm.options may just be premature since this is still a WIP, but I wanted to ensure I mentioned it since removing those module-defined files in favor of what the package ships is one motivating factor for taking out instances (jvm.options is one, the init/systemd scripts are another, etc.).

There are some other parts of the module that are very old and crufty that probably don't need the baggage with a modern release (like any sort of support for Shield), but whether that's easier to cut out as part of this or as a separate PR is totally whichever is easiest from your perspective.

@@ -85,6 +92,13 @@
# @param defaults_location
# Absolute path to directory containing init defaults file.
#
# @param deprecation_logging
# Wheter to enable deprecation logging. If enabled, deprecation logs will be
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# Wheter to enable deprecation logging. If enabled, deprecation logs will be
# Whether to enable deprecation logging. If enabled, deprecation logs will be

manifests/config.pp Outdated Show resolved Hide resolved
manifests/init.pp Outdated Show resolved Hide resolved
manifests/init.pp Outdated Show resolved Hide resolved
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

This is a massive effort and I'm so pleased it's in such good hands. As you can see, my comments are largely about trivial things.

My only serious concern is that I can't currently run the acceptance tests, but that looks like it's probably just a result of bit rot and not caused by this patch.

$ bundle exec rake beaker
[...]
Failure/Error: run_puppet_install_helper('agent') unless ENV['BEAKER_provision'] == 'no'
Beaker::Host::CommandFailure:
  Host 'ubuntu-16-04' exited with 8 running:
   wget -O /tmp/puppet.deb http://apt.puppet.com/pc1-release-xenial.deb
  Last 10 lines of output were:
        --2020-04-22 06:09:22--  http://apt.puppet.com/pc1-release-xenial.deb
        Resolving apt.puppet.com (apt.puppet.com)... 99.86.212.17, 99.86.212.23, 99.86.212.32, ...
        Connecting to apt.puppet.com (apt.puppet.com)|99.86.212.17|:80... connected.
        HTTP request sent, awaiting response... 404 Not Found
        2020-04-22 06:09:22 ERROR 404: Not Found.

$elasticsearch::homedir:
ensure => 'directory',
group => $elasticsearch::elasticsearch_group,
owner => $elasticsearch::elasticsearch_user;
Copy link

Choose a reason for hiding this comment

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

Not today, but I'd love to see this multi-resource declaration become an iterator one day.

Alternatively, a default: section could DRY this up a lot.

https://puppet.com/docs/puppet/latest/style_guide.html#multiple-resources

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed

}
}
} else { # absent
file { "${elasticsearch::defaults_location}/elasticsearch":
Copy link

Choose a reason for hiding this comment

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

There's a bunch of variable references that have explicit paths from the top-level scope with $::, but some don't.

It's been a while, but I had a feeling that modern Puppet versions don't need leading colons. Is that right? Either way, it's probably worth being consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question... I'll find out what the current best practise is :)

manifests/init.pp Outdated Show resolved Hide resolved
manifests/init.pp Outdated Show resolved Hide resolved
manifests/init.pp Outdated Show resolved Hide resolved
Comment on lines -568 to -596

# Manage users/roles before instances (req'd to keep dir in sync)
Elasticsearch::Role <| |>
-> Elasticsearch::Instance <| |>
Elasticsearch::User <| |>
-> Elasticsearch::Instance <| |>

# Ensure instances are started before managing REST resources
Elasticsearch::Instance <| ensure == 'present' |>
-> Elasticsearch::Template <| |>
Elasticsearch::Instance <| ensure == 'present' |>
-> Elasticsearch::Pipeline <| |>
Elasticsearch::Instance <| ensure == 'present' |>
-> Elasticsearch::Index <| |>
Elasticsearch::Instance <| ensure == 'present' |>
-> Elasticsearch::Snapshot_repository <| |>
# Ensure instances are stopped after managing REST resources
Elasticsearch::Template <| |>
-> Elasticsearch::Instance <| ensure == 'absent' |>
Elasticsearch::Pipeline <| |>
-> Elasticsearch::Instance <| ensure == 'absent' |>
Elasticsearch::Index <| |>
-> Elasticsearch::Instance <| ensure == 'absent' |>
Elasticsearch::Snapshot_repository <| |>
-> Elasticsearch::Instance <| ensure == 'absent' |>

# Ensure scripts are installed before copying them to configuration directory
Elasticsearch::Script <| |>
-> File["${configdir}/scripts"]
Copy link

Choose a reason for hiding this comment

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

<3

Comment on lines 61 to 62
%w[elasticsearch.yml jvm.options log4j2.properties].each do |file|
it { should contain_file("/etc/elasticsearch/#{file}") }
Copy link

Choose a reason for hiding this comment

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

Nice :)

manifests/config.pp Outdated Show resolved Hide resolved
manifests/config.pp Outdated Show resolved Hide resolved
spec/acceptance/tests/acceptance_spec.rb Outdated Show resolved Hide resolved
Gavin Williams added 3 commits April 22, 2020 16:35
Remove the `elasticsearch_service_file` type/provider and associated
tests.
@fatmcgav fatmcgav force-pushed the remove_multi-instance branch from eca2cf3 to 05f557f Compare April 24, 2020 10:30
This removes the templated 'jvm.options' file, instead we append to the
shipped 'jvm.options' file by using the `file_line` resource.

Removed associated tests and template file.
Add additional tests to cover specifying 'jvm_options'.
@fatmcgav fatmcgav force-pushed the remove_multi-instance branch from 05f557f to bec95ae Compare April 24, 2020 10:45
@fatmcgav fatmcgav force-pushed the remove_multi-instance branch 2 times, most recently from a5487bb to 6dca520 Compare April 29, 2020 21:52
@fatmcgav fatmcgav force-pushed the remove_multi-instance branch from 6dca520 to d2d83e5 Compare April 29, 2020 21:53
Gavin Williams added 5 commits April 30, 2020 14:38
Also update unit tests to reflect changes.
This can be used to override the default sleep interval, for example on
a slower system.
Also updated default value from `2` seconds to `10` seconds.

Finally, added a unit test for the type.
@fatmcgav
Copy link
Contributor Author

fatmcgav commented May 6, 2020

Right, this PR is big enough now and I think it covers most of the important stuff, so can you take another look @tylerjl and @Jarpy?

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Sorry to keep you waiting. Please ship this magnificent monster!

@marvi
Copy link

marvi commented May 13, 2020

I'm trying out your branch on CentOS 7 and get an error when running puppet apply:

  class { 'elasticsearch':
    manage_repo => false,
    version     => '7.6.2',
  }

systemd[1]: elasticsearch.service: main process exited, code=exited, status=233/RUNTIME_DIRECTORY

If I manually run systemctl start elasticsearch it works.

In the unit file RuntimeDirectory is specified. The directory is also created in config.pp and a tmpfiles.d config is added. I think there is a conflict among these three.

@fatmcgav
Copy link
Contributor Author

fatmcgav commented Jun 9, 2020

@marvi Thank you for taking the time to test this PR and report your findings
I've not been able to replicate the behaviour using our Docker tests.

However I'll run some more in-depth tests using Vagrant images once I've merged this PR.

@fatmcgav fatmcgav merged commit 82b5380 into master Jun 9, 2020
@fatmcgav fatmcgav deleted the remove_multi-instance branch June 9, 2020 14:43
@marvi
Copy link

marvi commented Jun 9, 2020

I solved it for CentOS 7 by setting elasticsearch::pid_dir: ~.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants