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

cluster.joinSeedNodes(...) does not throw warnings when seed hostname contains underscores #25287 #27222

Merged
merged 3 commits into from Jul 8, 2019

Conversation

helena
Copy link
Member

@helena helena commented Jun 26, 2019

@akka-ci akka-ci added the validating PR is currently being validated by Jenkins label Jun 26, 2019
* are any unusual characters in the host string.
*/
@InternalApi
private[akka] def hasInvalidHostCharacters: Boolean = host.exists(_.contains("_"))
Copy link
Member Author

Choose a reason for hiding this comment

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

Could expand of course but not all cases would need all char checks.
Could in future allow a user to provide a regex but also sounds over-engineery.
Best option is have a base here, and in a given module/function add the additional applicable checks.

private def checkHostCharacters(address: Address): Unit =
require(
!address.hasInvalidHostCharacters,
s"Joining the cluster using invalid host characters '${address.host}' in the Address is not allowed.")
Copy link
Member Author

Choose a reason for hiding this comment

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

Not saying I like a function that has a Unit signature which can throw.... but here we want to fail fast vs return something to handle.

@akka-ci akka-ci added tested PR that was successfully built and tested by Jenkins and removed validating PR is currently being validated by Jenkins labels Jun 26, 2019
@akka-ci
Copy link

akka-ci commented Jun 26, 2019

Test PASSed.

Copy link
Member

@patriknw patriknw left a comment

Choose a reason for hiding this comment

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

some more but otherwise looking good to add

@@ -300,8 +300,10 @@ class Cluster(val system: ExtendedActorSystem) extends Extension {
* The name of the [[akka.actor.ActorSystem]] must be the same for all members of a
* cluster.
*/
def join(address: Address): Unit =
def join(address: Address): Unit = {
checkHostCharacters(address)
Copy link
Member

Choose a reason for hiding this comment

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

should also be added to akka.cluster.typed.Join message (constructor check)

Copy link
Member Author

Choose a reason for hiding this comment

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

@patriknw I wonder if this is needed (because it isn't so simple to call this new existing in the Join constructor from where it is in Cluster and in typed it is immediately checked in the call to untyped. If we let it get checked in untyped it is cleaner though I agree with you.

case Join(address) =>
  adaptedCluster.join(address) // executes checkHostCharacters
case JoinSeedNodes(addresses) =>
  adaptedCluster.joinSeedNodes(addresses) // executes checkHostCharacters

Copy link
Member

Choose a reason for hiding this comment

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

since it's a message it will not be fail fast (at the sender side)

You can move checkHostCharacters to Address, or some other place that is accessible from akka-cluster-typed and akka-cluster. It doesn't have to live inside the Cluster class since it's just stateless validation logic.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good, I originally thought it belonged in Address but didn't know if it was too leaky.

Copy link
Member

Choose a reason for hiding this comment

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

yes, not good in Address since the error message talks about cluster joining. Put it in Cluster companion object.

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 removed the cluster part of the message and put it in Address for more reusability. If that makes sense.

akka-cluster/src/main/scala/akka/cluster/Cluster.scala Outdated Show resolved Hide resolved
@helena
Copy link
Member Author

helena commented Jul 2, 2019

@patriknw all review suggestions pushed.

@akka-ci akka-ci added validating PR is currently being validated by Jenkins and removed tested PR that was successfully built and tested by Jenkins labels Jul 2, 2019
@helena helena added 1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted 2 - pick next Used to mark issues which are next up in the queue to be worked on. The tag is non-binding and removed 2 - pick next Used to mark issues which are next up in the queue to be worked on. The tag is non-binding labels Jul 2, 2019
@akka-ci akka-ci added needs-attention Indicates a PR validation failure (set by CI infrastructure) and removed validating PR is currently being validated by Jenkins labels Jul 2, 2019
@akka-ci
Copy link

akka-ci commented Jul 2, 2019

Test FAILed.

Copy link
Member

@patriknw patriknw left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -65,6 +68,19 @@ final case class Address private (protocol: String, system: String, host: Option
* `system@host:port`
*/
def hostPort: String = toString.substring(protocol.length + 3)

/** INTERNAL API
Copy link
Member

Choose a reason for hiding this comment

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

weird formatting here

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed, needed to run fmt

Copy link
Member

@patriknw patriknw Jul 2, 2019

Choose a reason for hiding this comment

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

Isn't "format on save" in IntelliJ working for you? That must be annoying. I never run sbt scalafmt

Copy link
Member Author

Choose a reason for hiding this comment

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

That became too annoying while adding something new. I may try it again in future.

@helena helena force-pushed the cluster-join-address-check branch from cd59db2 to e8ca314 Compare July 2, 2019 14:14
@akka-ci akka-ci added validating PR is currently being validated by Jenkins and removed needs-attention Indicates a PR validation failure (set by CI infrastructure) labels Jul 2, 2019
@helena helena removed the 1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted label Jul 2, 2019
@akka-ci akka-ci added tested PR that was successfully built and tested by Jenkins and removed validating PR is currently being validated by Jenkins labels Jul 2, 2019
@akka-ci
Copy link

akka-ci commented Jul 2, 2019

Test PASSed.

@akka-ci akka-ci added validating PR is currently being validated by Jenkins tested PR that was successfully built and tested by Jenkins and removed tested PR that was successfully built and tested by Jenkins validating PR is currently being validated by Jenkins labels Jul 5, 2019
@akka-ci
Copy link

akka-ci commented Jul 5, 2019

Test PASSed.

@helena helena merged commit 501848d into akka:master Jul 8, 2019
@helena helena deleted the cluster-join-address-check branch July 15, 2019 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 - pick next Used to mark issues which are next up in the queue to be worked on. The tag is non-binding tested PR that was successfully built and tested by Jenkins
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants