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

Reject port ranges in discovery.seed_hosts #41404

Merged
merged 9 commits into from
May 7, 2019
Merged

Reject port ranges in discovery.seed_hosts #41404

merged 9 commits into from
May 7, 2019

Conversation

Hohol
Copy link
Contributor

@Hohol Hohol commented Apr 22, 2019

Today Elasticsearch accepts, but silently ignores, port ranges in the
discovery.seed_hosts setting:

discovery.seed_hosts: 10.1.2.3:9300-9400

Silently ignoring part of a setting like this is trappy. With this change we
reject seed host addresses of this form.

Closes #40786

@dliappis dliappis added the :Distributed Coordination/Cluster Coordination Cluster formation and cluster state publication, including cluster membership and fault detection. label Apr 22, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed

@dliappis
Copy link
Contributor

@elasticmachine test this please

@Hohol
Copy link
Contributor Author

Hohol commented Apr 22, 2019

Got an error
Forbidden annotation use: org.junit.Test [defaultMessage Just name your test method testFooBar]
I was using @Test annotation to check if a method throws an exception.
Should I just use try/catch in the test instead?

@dnhatn
Copy link
Member

dnhatn commented Apr 22, 2019

Should I just use try/catch in the test instead?

@Hohol You can use expectThrows.

@Hohol
Copy link
Contributor Author

Hohol commented Apr 25, 2019

@DaveCTurner can you review it please?

Copy link
Contributor

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

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

Please don't force-push to PR branches. It loses the history of the changes, including any comments, and generally makes it harder to review.

I think the fix can be made much more deeply. TcpTransport#parse() has a perAddressLimit that is always 1 except when discovery.seed_hosts is unset, and as far as I can tell this method is only used to read the discovery.seed_hosts setting. I think we could reasonably ditch this parameter and, instead, compute the local addresses in SettingsBasedSeedHostsProvider.

@Hohol
Copy link
Contributor Author

Hohol commented Apr 26, 2019

I noticed an inconsistency with documentation.

Out of the box, without any network configuration, Elasticsearch will bind to
the available loopback addresses and will scan local ports 9300 to 9305 to try
to connect to other nodes running on the same server.

It sounds to me like ports 9300, 9301, 9302, 9303, 9304, 9305 should be scanned.

But actually LOCAL_PORTS_COUNT = 5 and the code scans for ports 9300, 9301, 9302, 9303, 9304 only.

Should I do something with it?

@DaveCTurner
Copy link
Contributor

But actually LOCAL_PORTS_COUNT = 5 and the code scans for ports 9300, 9301, 9302, 9303, 9304 only.

Good catch, yes. Let's treat the docs as the desired behaviour and consider it as a bug that we don't scan port 9305.

@Hohol
Copy link
Contributor Author

Hohol commented Apr 26, 2019

PR was updated.
I'm sorry, but I used force-push again. I believe it was justified because changes of the old commit were completely discarded.

@DaveCTurner
Copy link
Contributor

It's still better to avoid a force-push, even if you start again, because now the conversation above doesn't make much sense.

@elasticmachine ok to test.

@Hohol
Copy link
Contributor Author

Hohol commented Apr 26, 2019

elasticsearch-ci/1 build failed.
Errors I found in log don't seem to be caused by my changes.
https://scans.gradle.com/s/ebfqezvw2jgco/console-log?task=:modules:percolator:integTestRunner#L24
Could it be some noisy failure?

@DaveCTurner
Copy link
Contributor

Yes, that looks weird and totally unrelated. @elasticmachine please run elasticsearch/ci-1

@Hohol
Copy link
Contributor Author

Hohol commented Apr 26, 2019

Looks like build hasn't started.
BTW can I give commands to @elasticmachine by myself?

@DaveCTurner
Copy link
Contributor

@elasticmachine please run elasticsearch/ci-1

@Hohol no, I think @elasticmachine only pays attention to members of the Elastic organisation.

@DaveCTurner
Copy link
Contributor

Bah, it's not running the build because I'm spelling it wrong.

@elasticmachine please run elasticsearch-ci/1 😁

@Hohol
Copy link
Contributor Author

Hohol commented Apr 29, 2019

@DaveCTurner please review it.

@Hohol
Copy link
Contributor Author

Hohol commented Apr 29, 2019

Builds failed with some weird errors again.

@Hohol
Copy link
Contributor Author

Hohol commented Apr 30, 2019

@DaveCTurner sorry for bothering you again, but I'd like to finish it sooner. Could you please rerun tests and review?

@Hohol
Copy link
Contributor Author

Hohol commented May 6, 2019

@DaveCTurner done.

Copy link
Contributor

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

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

Nice work. I went through the whole PR including the tests and left a few more small suggestions.

Copy link
Contributor

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

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

LGTM

@Hohol
Copy link
Contributor Author

Hohol commented May 7, 2019

@DaveCTurner are we waiting for something else?

@DaveCTurner
Copy link
Contributor

Hi @Hohol, as I've indicated, this PR looks good to me. I will merge and backport it when I have the availability, but the backport will take time since it requires documentation changes and I am not available to do it now. It is by no means urgent. Please be more patient in future.

@Hohol
Copy link
Contributor Author

Hohol commented May 7, 2019

I really wanted to know what's going on. Thanks for reply. I'll try to be less annoying next time.

@DaveCTurner DaveCTurner merged commit e6019b4 into elastic:master May 7, 2019
@Hohol Hohol deleted the reject-port-ranges branch May 7, 2019 16:11
DaveCTurner pushed a commit to DaveCTurner/elasticsearch that referenced this pull request May 7, 2019
Today Elasticsearch accepts, but silently ignores, port ranges in the
`discovery.seed_hosts` setting:

```
discovery.seed_hosts: 10.1.2.3:9300-9400
```

Silently ignoring part of a setting like this is trappy. With this change we
reject seed host addresses of this form.

Closes elastic#40786
Backport of elastic#41404
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request May 7, 2019
* elastic/master: (50 commits)
  Cleanup versioned deprecations in analysis (elastic#41560)
  Allow unknown task time in QueueResizingEsTPE (elastic#41810)
  SQL: Remove CircuitBreaker from parser (elastic#41835)
  [DOCS] Fix callouts for dataframe APIs (elastic#41904)
  Handle serialization exceptions during publication (elastic#41781)
  Correct spelling of MockLogAppender.PatternSeenEventExpectation (elastic#41893)
  Update TLS ciphers and protocols for JDK 11 (elastic#41808)
  Remove Harmful Exists Check from BlobStoreFormat (elastic#41898)
  Fix fractional seconds for strict_date_optional_time (elastic#41871)
  Remove op.name configuration setting (elastic#41445)
  Reject port ranges in `discovery.seed_hosts` (elastic#41404)
  [ML-DataFrame] migrate to PageParams for get and stats, move PageParams into core (elastic#41851)
  Reenable RareClusterStateIT Mapping Propagation Tests (elastic#41884)
  [DOCS] Rewrite `exists` query docs (elastic#41868)
  Revert "Mute MinimumMasterNodesIT.testThreeNodesNoMasterBlock()"
  [DOCS] Fix typo referring to multi search API
  Provide names for all artifact repositories (elastic#41857)
  Move InternalAggregations to Writeable (elastic#41841)
  Fix compilation after incorrect merge
  Unmute TestClustersPluginIT.testMultiNode (elastic#41340)
  ...
DaveCTurner added a commit that referenced this pull request May 8, 2019
Today Elasticsearch accepts, but silently ignores, port ranges in the
`discovery.seed_hosts` setting:

```
discovery.seed_hosts: 10.1.2.3:9300-9400
```

Silently ignoring part of a setting like this is trappy. With this change we
reject seed host addresses of this form.

Closes #40786
Backport of #41404
jaymode added a commit to jaymode/elasticsearch that referenced this pull request May 8, 2019
This change makes the default seed address tests account for the lack
of an IPv6 network. By default docker containers only run with IPv4 and
these tests fail in a vanilla installation of elasticsearch-ci. To
resolve this we only expect IPv6 seed addresses if IPv6 is available.

Relates elastic#41404
jaymode added a commit that referenced this pull request May 9, 2019
This change makes the default seed address tests account for the lack
of an IPv6 network. By default docker containers only run with IPv4 and
these tests fail in a vanilla installation of elasticsearch-ci. To
resolve this we only expect IPv6 seed addresses if IPv6 is available.

Relates #41404
jaymode added a commit that referenced this pull request May 9, 2019
This change makes the default seed address tests account for the lack
of an IPv6 network. By default docker containers only run with IPv4 and
these tests fail in a vanilla installation of elasticsearch-ci. To
resolve this we only expect IPv6 seed addresses if IPv6 is available.

Relates #41404
gurkankaymak pushed a commit to gurkankaymak/elasticsearch that referenced this pull request May 27, 2019
Today Elasticsearch accepts, but silently ignores, port ranges in the
`discovery.seed_hosts` setting:

```
discovery.seed_hosts: 10.1.2.3:9300-9400
```

Silently ignoring part of a setting like this is trappy. With this change we
reject seed host addresses of this form.

Closes elastic#40786
gurkankaymak pushed a commit to gurkankaymak/elasticsearch that referenced this pull request May 27, 2019
This change makes the default seed address tests account for the lack
of an IPv6 network. By default docker containers only run with IPv4 and
these tests fail in a vanilla installation of elasticsearch-ci. To
resolve this we only expect IPv6 seed addresses if IPv6 is available.

Relates elastic#41404
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>breaking >bug :Distributed Coordination/Cluster Coordination Cluster formation and cluster state publication, including cluster membership and fault detection. v7.2.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reject port ranges in discovery.seed_hosts
6 participants