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

Issue/jperf 445 sudo dind #5

Closed
wants to merge 4 commits into from

Conversation

dagguh
Copy link
Contributor

@dagguh dagguh commented Apr 2, 2019

No description provided.

@dagguh dagguh requested a review from wyrzyk April 2, 2019 15:07
@dagguh dagguh force-pushed the issue/JPERF-445-sudo-dind branch from d3b4a6b to e7bfbd8 Compare April 2, 2019 15:25
dagguh added 2 commits April 2, 2019 18:50
Augment the vast `docker-java` lib rather than hiding it under our layers.
Drop `testcontainers` in favor of the underlying `docker-java` API.
Use `com.atlassian.performance.tools:ssh` for more interoperability.
This new API is already tested in `virtual-users` (merged for weeks) and locally in `infrastructure` (tested tens of times today).
.editorconfig Show resolved Hide resolved
@@ -29,14 +27,14 @@ configurations.all {
}

dependencies {
api("com.atlassian.performance.tools:ssh:[2.0.0,3.0.0)")
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have to add an ssh client to the ssh-ubuntu lib?

Copy link
Contributor Author

@dagguh dagguh Apr 4, 2019

Choose a reason for hiding this comment

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

Pros:

  • the consumer can immediately interact with the Ubuntu via SSH, no need to translate APIs
  • the consumer doesn't have to search for and decide on an SSH client library
  • ❗️ we can preinstall sudo as a part of API

Cons:

  • bigger dependency tree - more conflicts to resolve (unless we start using ranges)
  • doesn't let users choose their own SSH client lib

Copy link
Contributor

Choose a reason for hiding this comment

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

We could avoid the cons and keep pros by introducing another module.

* @param [ports] Binds container ports to host address space.
* @param [peerIp] Addresses the Ubuntu within the Docker network.
*/
class SshUbuntuContainer internal constructor(
Copy link
Contributor

Choose a reason for hiding this comment

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

Internal constructor means nothing to the java consumer of the library.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True. Hmm, so we make it public and wait and see if we need to add fields later?

Copy link
Contributor

@wyrzyk wyrzyk Apr 5, 2019

Choose a reason for hiding this comment

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

We were experimenting with private constructor + factory method. The function will be visible from java, but the user will be warned.

We can also make it public, I'm not insisting.

@@ -0,0 +1,7 @@
package com.atlassian.performance.tools.sshubuntu.api

interface SshUbuntuImage {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it an API or SPI? Can I use own implementations as a user of the library?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Initially there was no interface at all. I added it to mimic the original ssh-ubuntu design.
Perhaps it's unnecessary. TBH I'm not sure about the value here.

.exec(PullImageResultCallback())
.awaitCompletion()
return docker
.createContainerCmd("rastasheep/ubuntu-sshd:16.04")
Copy link
Contributor

Choose a reason for hiding this comment

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

What license does the image use?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Default one, good catch
rastasheep/ubuntu-sshd#25

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wait a minute...
https://github.com/atlassian/ssh-ubuntu/blob/release-0.1.0/docker/Dockerfile
Currently we're using the same base

fun shouldStartUbuntu() {
val docker = DockerClientBuilder.getInstance().build()
val osName = docker
.createNetworkCmd()
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the low-level knowledge about docker networks needed to use the library?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this form it is. Adding network optionality complicated the implementation.

Pros:

  • simpler, non-branching implementation
  • exposes the consumer to the real complexity of networks: internal/external addresses/ports - necessary context when dealing with browsers connecting to servers (VU tests) or servers polling themselves locally (infra upgrade REST polling)

Cons:

  • it's extra complexity for the users who do not care about connecting multiple containers

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We definitely have to leave the option for networks, but we might invest into making the usage easier for simpler use cases. I'm not sure if it's worth it. I used this code in multiple tests already and the network creation was easily hidden by a local reused method. Perhaps we should wait and see if it's actually a problem.

implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion")
implementation("org.testcontainers:testcontainers:1.10.5")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can try to shrink the scope if it's possible to implement DIND and sudo via testcontainers. I could leave out the autocloseables as well and stick to the existing coarse-grained cleanup mechanisms (leaving leftovers if there's an exception somewhere in the middle of ssh-ubuntu.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The upshot is: this is already tested in VUs and has less external dependencies (like Docker publishing).
Locally I rewrote infra for this (basically a find and replace) and it's all green and still fast.

@@ -29,14 +27,14 @@ configurations.all {
}

dependencies {
api("com.atlassian.performance.tools:ssh:[2.0.0,3.0.0)")
Copy link
Contributor Author

@dagguh dagguh Apr 4, 2019

Choose a reason for hiding this comment

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

Pros:

  • the consumer can immediately interact with the Ubuntu via SSH, no need to translate APIs
  • the consumer doesn't have to search for and decide on an SSH client library
  • ❗️ we can preinstall sudo as a part of API

Cons:

  • bigger dependency tree - more conflicts to resolve (unless we start using ranges)
  • doesn't let users choose their own SSH client lib

@dagguh
Copy link
Contributor Author

dagguh commented Apr 4, 2019

Perhaps this PR is overkill for the purposes of sudo and Docker in Docker. I opened this, because I already tested it in other places, didn't want my source to go to waste and didn't want to think too hard about it, because I was in a rush. But that reasoning is suboptimal for the community.

Here's an alternative, which is not a shotgun surgery: #6
It changes fewer things and yields a more powerful API.

Copy link
Contributor

@wyrzyk wyrzyk left a comment

Choose a reason for hiding this comment

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

The PR changes API significantly and adds more requirements that we had before. If you'd like to push the change forward, please take care to upgrade it in modules that already depend on it. For ssh module the new API will make the lib unusable.

@dagguh dagguh closed this Apr 5, 2019
@dagguh dagguh deleted the issue/JPERF-445-sudo-dind branch April 5, 2019 08:46
@dagguh
Copy link
Contributor Author

dagguh commented Apr 5, 2019

This PR is closed, because #6 has won the competition and got merged

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.

3 participants