Comments (4)
Hey folks, thanks for the responses! After doing a bit more reading I think this is not a problem around DIND but rather a particularity of GitLab. That said, I think something along these lines could help in my case:
https://docs.gitlab.com/ee/ci/services/#using-services-with-docker-run-docker-in-docker-side-by-side
I'll give it a go later today and return with more details.
from agones.
I don't have a particularly strong objection to making the host configurable, but it feels like even with docker-in-docker you should be able to configure the networking so that the two containers share the same network namespace.
I found this medium article that explains How Can Two Containers Communicate Via localhost on Docker? and I've also found some references to using network_mode = "host"
in /etc/gitlab-runner/config.toml
to allow connections over localhost. It seems like it should be possible to configure the network for this to work (as was found with docker compose in #1183).
from agones.
To second @roberthbailey - while I'm not familiar with GitLab's CI, I've definitely done --network=host
in DIND.
For example, this Makefile
target test-quilkin
:
https://github.com/googleforgames/quilkin/blob/81db684cadcd7f28c32306cd4d72116b50ca6e83/build/Makefile#L90-L92
Is run in Google Cloud Build (that is also DIND):
https://github.com/googleforgames/quilkin/blob/81db684cadcd7f28c32306cd4d72116b50ca6e83/cloudbuild.yaml#L26-L29
As a thought, if you can share how you are running your tests on GitLab CI, we can possibly point out a path through. My gut tells me you may need to call docker run --network=host ...
directly (rather than indirectly like how Cloud Build does it), but let's see what you have and we can take it from there.
from agones.
Hi again, I've had a look and although I could not go through til the end I'm relatively confident it can work without the custom host, but it's going to affect the way I run the tests anyway. Which btw @markmandel , I've realised I haven't shared yet despite your request, it's been a busy day πΆβπ«οΈ .
Basically the way we're running tests is through a dedicated check
job in a validation
stage. That job will simply translate into running go test ./...
.
As part of my tests, I have a testcontainers
fixture that will create a short-lived containerised game server before the test, and will tear it down after the test. My GitLab config has already some fields for GitLab DIND to play nicely with testcontainers:
services:
- name: docker:24.0.7-dind
# explicitly disable tls to avoid docker startup interruption
command: ["--tls=false"]
variables:
# instruct Testcontainers to use the daemon of DinD, use port 2375 for non-tls connections.
DOCKER_HOST: "tcp://docker:2375"
# istruct Docker not to start over TLS.
DOCKER_TLS_CERTDIR: ""
# improve performance with overlayfs.
DOCKER_DRIVER: overlay2
# Tell Testcontainers that DinD hostname is docker and not localhost
TC_HOST: docker
My actual testcontainers
fixture looks more or less like this:
Setup:
func AgonesSdkContainerFixture(t *testing.T) (context.Context, testcontainers.Container) {
ctx := context.Background()
abs, err := filepath.Abs("./")
require.NoError(t, err)
gameserverYamlPath := path.Join(abs, "gameserver.yaml")
req := testcontainers.ContainerRequest{
Image: "us-docker.pkg.dev/agones-images/release/agones-sdk:1.37.0",
ExposedPorts: []string{"9357/tcp", "9358/tcp"},
WaitingFor: wait.ForLog("Starting SDKServer grpc-gateway..."),
HostConfigModifier: func(hc *container.HostConfig) {
hc.NetworkMode = "host"
hc.Binds = []string{gameserverYamlPath + ":" + "/tmp/gameserver.yaml"}
},
Cmd: []string{"--local", "--feature-gates", "CountsAndLists=true", "-f", "/tmp/gameserver.yaml"},
}
agonesC, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
ContainerRequest: req,
Started: true,
})
if err != nil {
t.Fatal(err)
}
return ctx, agonesC
}
Teardown:
func AgonesSdkContainerCleanup(ctx context.Context, t *testing.T, agonesC testcontainers.Container) {
if err := agonesC.Terminate(ctx); err != nil {
t.Fatalf("failed to terminate container: %s", err.Error())
}
}
As I mentioned above, if I go down the GitLab service route, I will then have a single GameServer running alongside my application tests, instead of the ephemeral gameservers that I was aiming to have (I know this is not efficient, but hey test code, I prefer the reliability over the efficiency).
I wouldn't suggest the configurable host if it was production code, but since it's the simple server I think I'd like to maintain my request. Otherwise, if you have suggestions to harmonize GitLab's DIND + network host + ephemeral testcontainers I'll be more than happy to test it out!
Again thanks for your support π
from agones.
Related Issues (20)
- In-place Agones Upgrades: Storage Compatibility HOT 2
- Helm Param Update: Default to agones.controller if agones.extensions is Missing HOT 2
- RFC: Graduate Counters & Lists (`CountsAndLists` feature flag) to Beta HOT 2
- Update best practices for multi-cluster allocation
- Docs: Update High Available to include more details.
- Configurable Allocator HTTP status codes on failure HOT 6
- Fail CI if a PR updates an example without modifying the version HOT 3
- In-place Agones Upgrades: Testing HOT 2
- Release 1.40.0 HOT 1
- Direct connection to a GameServer/Pod without NAT HOT 14
- [mTLS]: allocator server can not verify client certificate when client certificate auto renew HOT 2
- Refactor simple-game-server
- `make gen-all-sdk-grpc` is ineffective for nodejs HOT 9
- [Docs] Single source of truth for example yaml files HOT 1
- Fleet autoscaler scale down delay HOT 1
- metadata.finalizers: "agones.dev": prefer a domain-qualified finalizer name to avoid accidental conflicts with other finalizer writer HOT 1
- Implement Count functions in SDKServer, and write e2e tests HOT 1
- sdkserver: add functionality to remove game server annotations
- sdkserver: add functionality to set multiple game server annotations at once
- [e2e] Document the best path for making changes to simple-game-server for e2e tests HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from agones.