Skip to content
This repository was archived by the owner on Feb 27, 2020. It is now read-only.

Commit 32447e2

Browse files
authored
Merge pull request #356 from taskcluster/fix-docker-attach-proxy
Fix AttachProxy on docker-engine
2 parents 4527a31 + 9260840 commit 32447e2

4 files changed

Lines changed: 29 additions & 0 deletions

File tree

engines/docker/engine_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,25 @@ func TestArtifacts(t *testing.T) {
118118

119119
c.Test()
120120
}
121+
122+
func TestProxies(t *testing.T) {
123+
c := enginetest.ProxyTestCase{
124+
EngineProvider: provider,
125+
ProxyName: "my-proxy",
126+
PingProxyPayload: `{
127+
"command": ["sh", "-ec", "` +
128+
`apk add --no-cache curl > /dev/null; ` +
129+
`echo 'Pinging'; ` +
130+
`STATUS=$(curl -s -o /tmp/output -w '%{http_code}' http://taskcluster/my-proxy/v1/ping); ` +
131+
`cat /tmp/output; ` +
132+
`test $STATUS -eq 200;` +
133+
`"],
134+
"image": {
135+
"repository": "` + dockerImageRepository + `",
136+
"tag": "` + dockerImageTag + `"
137+
}
138+
}`,
139+
}
140+
141+
c.Test()
142+
}

engines/docker/network/pool.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ func (p *Pool) GetNetwork(handler http.Handler) (*Handle, error) {
118118
}
119119
p.idleNetworks = p.idleNetworks[:len(p.idleNetworks)-1]
120120

121+
// Set handler for the network
122+
h.network.SetHandler(handler)
123+
121124
return h, nil
122125
}
123126

engines/docker/sandboxbuilder.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func newSandboxBuilder(payload *payloadType, e *engine, monitor runtime.Monitor,
3838
e: e,
3939
taskCtx: ctx,
4040
env: &docker.Env{},
41+
proxies: make(map[string]http.Handler),
4142
imageDone: make(chan struct{}, 1),
4243
}
4344
// set image

engines/enginetest/attachproxy.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func (c *ProxyTestCase) TestPingProxyPayload() {
4747

4848
result := r.buildRunSandbox()
4949
log := r.ReadLog()
50+
debug("task-log: '%s'", log)
5051

5152
assert(result, "PingProxyPayload exited unsuccessfully, log: ", log)
5253
assert(pinged, "PingProxyPayload didn't call the attachedProxy, log: ", log)
@@ -79,6 +80,7 @@ func (c *ProxyTestCase) TestPing404IsUnsuccessful() {
7980

8081
result := r.buildRunSandbox()
8182
log := r.ReadLog()
83+
debug("task-log: '%s'", log)
8284

8385
assert(!result, "PingProxyPayload exited successfully, when we returned 404")
8486
assert(pinged, "PingProxyPayload didn't call the attachedProxy")
@@ -129,6 +131,7 @@ func (c *ProxyTestCase) TestLiveLogging() {
129131

130132
result := r.buildRunSandbox()
131133
log := r.ReadLog()
134+
debug("task-log: '%s'", log)
132135

133136
assert(result, "PingProxyPayload exited unsuccessfully")
134137
assert(pinged, "PingProxyPayload didn't call the attachedProxy")

0 commit comments

Comments
 (0)