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

Support SPI for ContainerPool and ContainerProxy #3663

Closed
wants to merge 1 commit into from

Conversation

style95
Copy link
Member

@style95 style95 commented May 16, 2018

This closes #3662.

Description

It will apply SPI to ContainerPool and ContainerProxy.
Current ContainerPool and ContainerProxy are renamed with Default prefix.

Related issue and scope

My changes affect the following components

  • API
  • Controller
  • Message Bus (e.g., Kafka)
  • Loadbalancer
  • Invoker
  • Intrinsic actions (e.g., sequences, conductors)
  • Data stores (e.g., CouchDB)
  • Tests
  • Deployment
  • CLI
  • General tooling
  • Documentation

Types of changes

  • Bug fix (generally a non-breaking change which closes an issue).
  • Enhancement or new feature (adds new functionality).
  • Breaking change (a bug fix or enhancement which changes existing behavior).

Checklist:

  • I signed an Apache CLA.
  • I reviewed the style guides and followed the recommendations (Travis CI will check :).
  • I added tests to cover my changes.
  • My changes require further changes to the documentation.
  • I updated the documentation where necessary.

@style95
Copy link
Member Author

style95 commented May 17, 2018

Could anyone trigger the build again please?
It seems failing test is not related to my changes.

@codecov-io
Copy link

Codecov Report

Merging #3663 into master will decrease coverage by 0.07%.
The diff coverage is 87.45%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3663      +/-   ##
==========================================
- Coverage   74.49%   74.41%   -0.08%     
==========================================
  Files         126      126              
  Lines        5990     5996       +6     
  Branches      390      393       +3     
==========================================
  Hits         4462     4462              
- Misses       1528     1534       +6
Impacted Files Coverage Δ
...ain/scala/whisk/core/invoker/InvokerReactive.scala 0% <0%> (ø) ⬆️
...er/src/main/scala/whisk/core/invoker/Invoker.scala 0% <0%> (ø) ⬆️
...hisk/core/containerpool/DefaultContainerPool.scala 84.88% <84.88%> (ø)
...isk/core/containerpool/DefaultContainerProxy.scala 91.27% <91.27%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 22c0807...a3c21b2. Read the comment docs.

@csantanapr
Copy link
Member

@style95
Closing the PR and then re-opening the PR will trigger the build again in Travis

@style95
Copy link
Member Author

style95 commented May 17, 2018

@csantanapr thank you for the good tip.

@style95
Copy link
Member Author

style95 commented May 24, 2018

@tysonnorris suggested to use a single SPI implementation for ContainerProxy and ContainerPool.

At first time, I thought of this kind of approach.

trait ContainerPoolProvider extends Spi {
  def getContainerPoolProps(childFactory: ActorRefFactory => ActorRef,
            poolConfig: ContainerPoolConfig,
            activationFeed: ActorRef,
            someConfig: Option[PrewarmingConfig] = None): Props

  def getContainerProxyProps(factory: (TransactionId, String, ImageName, Boolean, ByteSize, Int) => Future[Container],
            ack: (TransactionId, WhiskActivation, Boolean, InstanceId, UUID) => Future[Any],
            store: (TransactionId, WhiskActivation) => Future[Any],
            collectLogs: (TransactionId, Identity, WhiskActivation, Container, ExecutableWhiskAction) => Future[ActivationLogs],
            instance: InstanceId,
            poolConfig: ContainerPoolConfig,
            unusedTimeout: FiniteDuration = timeouts.idleContainer,
            pauseGrace: FiniteDuration = timeouts.pauseGrace): Props

  def requiredProperties: Map[String, String]
}

So we can create both ContainerProxy and ContainerPool implementation with one trait.
But with this approach, companion object of them should mix in the same trait, ContainerPoolProvider.
Since that trait has two abstract methods, it is required for all objects which mix in this trait to override both methods.
Accordingly ContainerProxy and ContainerPool should override unnecessary methods respectively.

One option is to make ContainerProxy as a inner class of ContainerPool and only expose ContainerPool via SPI.
But it might introduce huge changes.

As of now I am not quite sure which one is right direction.
I am holding to have multiple SPI for them in one hand, and to make ContainerProxy as an inner class of ContainerPool in the other hand.

WDYT?

@rabbah
Copy link
Member

rabbah commented May 24, 2018

Discalimer: i need to catch up on the tech exchange and various other write ups. But at first glance two adapters avoids conflating separate concerns. I do not see why they should be mixed or nested.

@style95
Copy link
Member Author

style95 commented May 24, 2018

The basic idea behind above approach is, ContainerProxy and ContainerPool have strong correlation to each other.
I am not sure we can independently use ContainerProxy or ContainerPool.
Logics in ContainerProxy do affect the scheduling and pool managing logics in ContainerPool.
So I thought if we make ContainerProxy as an inner class of ContainerPool then we can have better cohesion.

@style95 style95 force-pushed the container-pool-spi branch 2 times, most recently from 26715bc to 42355a8 Compare May 31, 2018 01:47
@style95 style95 closed this May 31, 2018
@style95 style95 reopened this May 31, 2018
@markusthoemmes
Copy link
Contributor

@style95 this has rotted quite a bit and the dev-list discussions seem to move in another direction. I'll close this for now due to inactivity. Please feel free to reopen it if a proposal going this way is discussed and agreed upon on the dev-list.

Thanks a lot for your work so far, very appreciated! 🎉

@style95
Copy link
Member Author

style95 commented Sep 18, 2018

@markusthoemmes got it.
Thanks.

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

Successfully merging this pull request may close these issues.

SPI for ContainerProxy and ContainerPool
5 participants