-
Notifications
You must be signed in to change notification settings - Fork 154
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 non-default config that allows InboundQuarantineCheck to ignore 'harmless' quarantine events #1555
Merged
+292
−19
Merged
add non-default config that allows InboundQuarantineCheck to ignore 'harmless' quarantine events #1555
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
aa23dad
stub test for harmless=true
pjfanning 3aa7747
add quarantinedButHarmless check for tests
pjfanning 37c8c9a
new test case
pjfanning dd77a35
Update OutboundIdleShutdownSpec.scala
pjfanning b471302
try to not shutdown when quarantine is harmless
pjfanning 423f3cc
Update OutboundIdleShutdownSpec.scala
pjfanning df969a6
Create quarantine.backwards.excludes
pjfanning ea82dec
Update quarantine.backwards.excludes
pjfanning 4dd39b6
update log message
pjfanning 6a70f2e
try to add config
pjfanning 27e3b3c
Update ArterySettings.scala
pjfanning fc1429b
add tests
pjfanning 642d408
Update OutboundIdleShutdownSpec.scala
pjfanning 7c34c67
rework test
pjfanning File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
remote/src/main/mima-filters/1.1.x.backwards.excludes/quarantine.backwards.excludes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
# changes made due to issues with downing during harmless quarantine | ||
# https://github.com/apache/pekko/issues/578 | ||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.remote.artery.AssociationState#QuarantinedTimestamp.copy") | ||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.remote.artery.AssociationState#QuarantinedTimestamp.this") | ||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.remote.artery.AssociationState#QuarantinedTimestamp.apply") | ||
ProblemFilters.exclude[IncompatibleSignatureProblem]("org.apache.pekko.remote.artery.AssociationState#QuarantinedTimestamp.unapply") | ||
ProblemFilters.exclude[MissingTypesProblem]("org.apache.pekko.remote.artery.AssociationState$QuarantinedTimestamp$") | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
142 changes: 142 additions & 0 deletions
142
remote/src/test/scala/org/apache/pekko/remote/artery/HarmlessQuarantineSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* license agreements; and to You under the Apache License, version 2.0: | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* This file is part of the Apache Pekko project, which was derived from Akka. | ||
*/ | ||
|
||
/* | ||
* Copyright (C) 2009-2022 Lightbend Inc. <https://www.lightbend.com> | ||
*/ | ||
|
||
package org.apache.pekko.remote.artery | ||
|
||
import scala.concurrent.Future | ||
import scala.concurrent.Promise | ||
|
||
import org.scalatest.concurrent.Eventually | ||
import org.scalatest.time.Span | ||
|
||
import org.apache.pekko | ||
import pekko.actor.ActorRef | ||
import pekko.actor.ActorSystem | ||
import pekko.actor.Address | ||
import pekko.actor.RootActorPath | ||
import pekko.remote.RARP | ||
import pekko.remote.UniqueAddress | ||
import pekko.testkit.ImplicitSender | ||
import pekko.testkit.TestActors | ||
import pekko.testkit.TestProbe | ||
|
||
class HarmlessQuarantineSpec extends ArteryMultiNodeSpec(""" | ||
pekko.loglevel=INFO | ||
pekko.remote.artery.propagate-harmless-quarantine-events = off | ||
pekko.remote.artery.advanced { | ||
stop-idle-outbound-after = 1 s | ||
connection-timeout = 2 s | ||
remove-quarantined-association-after = 1 s | ||
compression { | ||
actor-refs.advertisement-interval = 5 seconds | ||
} | ||
} | ||
""") with ImplicitSender with Eventually { | ||
|
||
override implicit val patience: PatienceConfig = { | ||
import pekko.testkit.TestDuration | ||
PatienceConfig(testKitSettings.DefaultTimeout.duration.dilated * 2, Span(200, org.scalatest.time.Millis)) | ||
} | ||
|
||
private def futureUniqueRemoteAddress(association: Association): Future[UniqueAddress] = { | ||
val p = Promise[UniqueAddress]() | ||
association.associationState.addUniqueRemoteAddressListener(a => p.success(a)) | ||
p.future | ||
} | ||
|
||
"Harmless Quarantine Events" should { | ||
|
||
"eliminate quarantined association when not used - echo test" in withAssociation { | ||
(remoteSystem, remoteAddress, _, localArtery, localProbe) => | ||
// event to watch out for, indicator of the issue | ||
remoteSystem.eventStream.subscribe(testActor, classOf[ThisActorSystemQuarantinedEvent]) | ||
|
||
val remoteEcho = remoteSystem.actorSelection("/user/echo").resolveOne(remainingOrDefault).futureValue | ||
|
||
val localAddress = RARP(system).provider.getDefaultAddress | ||
|
||
val localEchoRef = | ||
remoteSystem.actorSelection(RootActorPath(localAddress) / localProbe.ref.path.elements).resolveOne( | ||
remainingOrDefault).futureValue | ||
remoteEcho.tell("ping", localEchoRef) | ||
localProbe.expectMsg("ping") | ||
|
||
val association = localArtery.association(remoteAddress) | ||
val remoteUid = futureUniqueRemoteAddress(association).futureValue.uid | ||
localArtery.quarantine(remoteAddress, Some(remoteUid), "Test") | ||
association.associationState.isQuarantined(remoteUid) shouldBe true | ||
association.associationState.quarantinedButHarmless(remoteUid) shouldBe false | ||
|
||
remoteEcho.tell("ping", localEchoRef) // trigger sending message from remote to local, which will trigger local to wrongfully notify remote that it is quarantined | ||
eventually { | ||
expectMsgType[ThisActorSystemQuarantinedEvent] // this is what remote emits when it learns it is quarantined by local | ||
} | ||
} | ||
|
||
"eliminate quarantined association when not used - echo test (harmless=true)" in withAssociation { | ||
(remoteSystem, remoteAddress, _, localArtery, localProbe) => | ||
// event to watch out for, indicator of the issue | ||
remoteSystem.eventStream.subscribe(testActor, classOf[ThisActorSystemQuarantinedEvent]) | ||
|
||
val remoteEcho = remoteSystem.actorSelection("/user/echo").resolveOne(remainingOrDefault).futureValue | ||
|
||
val localAddress = RARP(system).provider.getDefaultAddress | ||
|
||
val localEchoRef = | ||
remoteSystem.actorSelection(RootActorPath(localAddress) / localProbe.ref.path.elements).resolveOne( | ||
remainingOrDefault).futureValue | ||
remoteEcho.tell("ping", localEchoRef) | ||
localProbe.expectMsg("ping") | ||
|
||
val association = localArtery.association(remoteAddress) | ||
val remoteUid = futureUniqueRemoteAddress(association).futureValue.uid | ||
localArtery.quarantine(remoteAddress, Some(remoteUid), "HarmlessTest", harmless = true) | ||
association.associationState.isQuarantined(remoteUid) shouldBe true | ||
association.associationState.quarantinedButHarmless(remoteUid) shouldBe true | ||
|
||
remoteEcho.tell("ping", localEchoRef) // trigger sending message from remote to local, which will trigger local to wrongfully notify remote that it is quarantined | ||
eventually { | ||
expectNoMessage() | ||
} | ||
} | ||
|
||
/** | ||
* Test setup fixture: | ||
* 1. A 'remote' ActorSystem is created to spawn an Echo actor, | ||
* 2. A TestProbe is spawned locally to initiate communication with the Echo actor | ||
* 3. Details (remoteAddress, remoteEcho, localArtery, localProbe) are supplied to the test | ||
*/ | ||
def withAssociation(test: (ActorSystem, Address, ActorRef, ArteryTransport, TestProbe) => Any): Unit = { | ||
val remoteSystem = newRemoteSystem() | ||
try { | ||
remoteSystem.actorOf(TestActors.echoActorProps, "echo") | ||
val remoteAddress = RARP(remoteSystem).provider.getDefaultAddress | ||
|
||
def remoteEcho = system.actorSelection(RootActorPath(remoteAddress) / "user" / "echo") | ||
|
||
val echoRef = remoteEcho.resolveOne(remainingOrDefault).futureValue | ||
val localProbe = new TestProbe(localSystem) | ||
|
||
echoRef.tell("ping", localProbe.ref) | ||
localProbe.expectMsg("ping") | ||
|
||
val artery = RARP(system).provider.transport.asInstanceOf[ArteryTransport] | ||
|
||
test(remoteSystem, remoteAddress, echoRef, artery, localProbe) | ||
|
||
} finally { | ||
shutdown(remoteSystem) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class is in
private[remote]
context, so indeed these changes are safe.I think you could use a wildcard: