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 sensu_cluster_member type #947

Merged
merged 1 commit into from
Aug 29, 2018

Conversation

treydock
Copy link
Collaborator

@treydock treydock commented Aug 5, 2018

Pull Request Checklist

Description

Add a custom type that can add cluster members.

Related Issue

Part of #901

Motivation and Context

sensuctl supports adding members. The members won't actually be fully added until the new member is started with the proper configuration. The necessary configuration is printed by this custom type in the info output which comes from output of the sensuctl command to add the member.

How Has This Been Tested?

Added new way to run acceptance tests that spawn 3 backend servers. Using only 2 caused issues (see sensu/sensu-go#1890). When BEAKER_sensu_cluster is yes or true the cluster acceptance tests are run.

General

  • Update README.md with any necessary configuration snippets

  • Tests pass - bundle exec rake validate lint spec

@treydock treydock force-pushed the sensu2-cluster-member branch 2 times, most recently from 6454ddf to 6578dd0 Compare August 5, 2018 17:46
Vagrantfile Outdated
config.vm.define "sensu-backend-peer", primary: true, autostart: true do |backend|
backend.vm.box = "centos/7"
backend.vm.hostname = 'sensu-backend-peer.example.com'
backend.vm.network :private_network, ip: ENV['ALTERNATE_IP'] || '192.168.52.11'
Copy link
Collaborator

Choose a reason for hiding this comment

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

these IP's conflict with other vagrant instances

Vagrantfile Outdated
backend.vm.network :forwarded_port, guest: 2380, host: 2380, auto_correct: true
backend.vm.network :forwarded_port, guest: 3000, host: 3000, auto_correct: true
backend.vm.network :forwarded_port, guest: 8080, host: 8080, auto_correct: true
backend.vm.network :forwarded_port, guest: 8081, host: 8081, auto_correct: true
Copy link
Collaborator

Choose a reason for hiding this comment

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

These ports conflict. I know auto_correct is true, though that makes documentation hard since a random port will be grabbed.

@@ -0,0 +1,98 @@
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'sensuctl'))
Copy link
Collaborator

Choose a reason for hiding this comment

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

The README should have an example for how this works.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There is an example in the type description that will get picked up with puppet-strings, do we also want additional examples in README? If yes, should we also document how to setup a cluster? It's currently not documented by Sensu but managed to figure it out based on their docker compose configs. This new type is tightly coupled to configs in backend.yml as they won't work without both being implemented.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's document how to setup a cluster since that's how people will run Sensu.

@treydock treydock mentioned this pull request Aug 8, 2018
@ghoneycutt
Copy link
Collaborator

@treydock please squash and rebase and this should pass tests once #948 is merged.

@treydock treydock force-pushed the sensu2-cluster-member branch from c45ae4f to 9b990e8 Compare August 9, 2018 22:45
@treydock
Copy link
Collaborator Author

treydock commented Aug 9, 2018

@ghoneycutt Squashed and rebased. Updated README with instructions on how to setup a cluster and also how to add a member to an existing cluster.

Vagrantfile Outdated
@@ -46,6 +46,32 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
backend.vm.provision :shell, :inline => "facter --custom-dir=/vagrant/lib/facter sensu_version"
end

config.vm.define "sensu-backend-peer", primary: true, autostart: true do |backend|
Copy link
Collaborator

Choose a reason for hiding this comment

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

call this one sensu-backend-peer1 to be inline with sensu-backend-peer2

README.md Outdated

Adding new members to a cluster requires two steps. First add the member using `sensu_cluster_member` type then second configure and start `sensu-backend` on the new node.

First, add the member:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this mean it takes multiple puppet runs in a certain sequence? If so, could you elaborate?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think so, I'll try to come up with some better wording on order. It's a really specific order of operations to avoid errors. Basically add member on existing backend node with sensuctl then start new member with config that differs slightly from existing backend nodes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated README, hopefully a bit clearer. Let me know if needs improvements.

@ghoneycutt
Copy link
Collaborator

This strangely had an error with amazon linux 2018.3. Perhaps the service just took too long to start?

@treydock treydock force-pushed the sensu2-cluster-member branch 3 times, most recently from e5aeb8e to d9e93f0 Compare August 10, 2018 00:29
@ghoneycutt
Copy link
Collaborator

The docs assume that two backends are running, which I thought is not good since you need one or three for quorum. If you have only two does is put the cluster is a not-good state? Could you give me a step by step in the README of why you have to setup one node, then can add more.

@treydock
Copy link
Collaborator Author

So the adding member bits are only necessary if your going from an existing cluster of say 2 nodes and want to add a third node later on. The easiest way I found to setup a cluster is to have all nodes from the very beginning, which doesn't require the sensu_cluster_member type at all, just YAML configs. The sensu_cluster_member type would only be for modifying an already established cluster. Going from a 1 node cluster to a 2 node cluster presents problems which I've raised on sensu-go (sensu/sensu-go#1890) as seems the cluster looses quorum and breaks sensuctl until the 2nd node is brought online.

@treydock
Copy link
Collaborator Author

Added a few bits of text to hopefully make it clear that adding members to an existing cluster differs from setting up a cluster from scratch.

@ghoneycutt
Copy link
Collaborator

@treydock Could you please rebase. Is this ready to merge?

Update README with backend cluster examples
@treydock treydock force-pushed the sensu2-cluster-member branch from 621f442 to 7879b1c Compare August 26, 2018 17:08
@treydock
Copy link
Collaborator Author

@ghoneycutt rebased and squashed.

@treydock
Copy link
Collaborator Author

I'd say ready for merge. Open issue upstream but not sure would impact this PR since issue I opened was going from one to two node cluster and sensuctl hanging. That's why acceptance tests go from two to three node cluster, seems keeps quorum.

@ghoneycutt ghoneycutt merged commit b4a2b5b into sensu:sensu2 Aug 29, 2018
@treydock treydock deleted the sensu2-cluster-member branch August 31, 2018 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants