Open Bug 1900602 Opened 2 years ago Updated 1 year ago

Cannot download android ndk on bitbar CI worker

Categories

(Testing :: CI Configuration, defect, P2)

Unspecified
Android
defect

Tracking

(Not tracked)

People

(Reporter: denispal, Unassigned)

References

(Blocks 1 open bug)

Details

There is a problem downloading the andriod NDK from taskcluster, it will continually fail trying to download and then the test fails with:
Intermittent Exception: Download failed, no more retries!

See https://treeherder.mozilla.org/jobs?repo=try&revision=b0ab784f96d6328da9e51bf839943643878007fe&selectedTaskRun=czMEarT9S9q_WG9-WZMuKw.0 as an example.

I need the ndk to continue work on bug 1893493, so any help on fixing this would be much appreciated.

Yarik, would you be able to help see what's happening with these downloads?

Flags: needinfo?(ykurmyza)

hey Denis, this is an interesting one. In the logs I see requests going to what is supposed to be a TASCKLUSTER_PROXY:

Downloading http://localhost:8099/api/queue/v1/task/HhSkd7NqTuyu62XzNiEbCQ/artifacts/project/gecko/android-ndk/android-ndk.tar.zst
# with following
Download failed: <urlopen error [Errno 99] Cannot assign requested address>

Which is a likely indicator that there is no proxy running on that port

What is strange is that few lines above, artifacts are being pulled directly from fxci without a proxy:

Downloading https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/Ksh20KzhTUic5pDCWL1xOQ/artifacts/public/build/node.tar.zst

I'd start by looking what is inside ['/usr/bin/python3', '-u', '/builds/task_171735509354377/./fetch-content', 'task-artifacts']
and then checking how this particular worker is being configured.

Do you know if this issue appeared recently? Could it be that restarting this task will work?

Flags: needinfo?(ykurmyza)

It has been failing for a few weeks now. It can intermittently succeed, however, as you can see from this push https://treeherder.mozilla.org/jobs?repo=try&revision=e592d34cb9a635e116cb15f1cf3f7d7d1b0c9d8f. It worked on one device, but failed on the other two. However, 90% of the time the download will fail regardless of device.

Ah, ok, checking run-task/fetch-content clarifies that difference is in the artifact type
If it starts with "public/" script uses TASKCLUSTER_ROOT_URL but if it is not public it would go through TASKCLUSTER_PROXY_URL which makes sense, as proxy should inject temporary credentials that would allow to download non-public artifacts.

So the problem here is to find why the proxy isn't running, or maybe it is running on a different interface/port, and if task environment can actually reach that network interface

Trick is to find who owns/runs this worker pool https://firefox-ci-tc.services.mozilla.com/provisioners/proj-autophone

The question is if this archive is really private and contains some sensitive data, or it can be made public, so there would be no issue downloading it on the android env.

/project/gecko/android-ndk/android-ndk.tar.zst

artifacts in taskcluster has this naming convention where all public/ artifacts are considered public and require no authentication to fetch those..
so if that's possible for this particular artifact, then it's a relatively simple hack/fix

I'm not sure what the logistics are for putting the ndk behind a proxy with authentication. Is it a licensing concern for hosting the ndk? Because it's technically publically available from https://developer.android.com/ndk/downloads.

We (relSRE/me) run these hosts. They're at Bitbar. We have documentation on how they're set up and work at https://mana.mozilla.org/wiki/display/ROPS/Android+Build+and+Test+Infrastructure. We don't explicitly start taskcluster-proxy (I thought it was launched by g-w... but not really sure. I don't believe we start taskcluster-proxy in any of our other worker-types.)

The NDK is available publicly, but you have probably have to accept a license (you do for the normal android SDK, assuming you do also for the NDK). I think when we package the SDK in taskcluster we accept the license (we touch a file indicating that we've accepted it).

It seems like g-w does/is able to launch a taskcluster-proxy instance from https://github.com/taskcluster/taskcluster/blob/9cd42bac9e73bcd0048bf2fd46bbcc7ef733f5f7/workers/generic-worker/taskcluster_proxy.go#L55.

d-w seems to use a sidecar docker container to provide taskcluster-proxy. The way the autophone workers are set up (each g-w inside a docker container will start a taskcluster-proxy instance) is a bit inefficient, but it should work. I thought that the ports might be an issue if it's trying to use the same port on all containers, but that's just inside the container (we're not doing any port mapping). I don't think taskcluster-proxy needs to accept incoming requests (correct?)... so it shouldn't need a port mapping.

Checking out the worker-manager config that this host runs with:

provider:
    providerType: standalone
    rootURL: "https://firefox-ci-tc.services.mozilla.com"
    clientID: "${TASKCLUSTER_CLIENT_ID}"
    accessToken: "${TASKCLUSTER_ACCESS_TOKEN}"
    workerPoolID: "proj-autophone/${TC_WORKER_TYPE}"
    workerGroup: "${TC_WORKER_GROUP}"
    workerID: "${DEVICE_NAME}"
getSecrets: false
worker:
    implementation: generic-worker
    path: /usr/local/bin/generic-worker
    configPath: /builds/taskcluster/generic-worker.yml
workerConfig:
    certificate:                ""
    ed25519SigningKeyLocation:   "${ED25519_PRIVKEY}"
    idleTimeoutSecs:            5400
    livelogExecutable:          "/usr/local/bin/livelog"
    numberOfTasksToRun:         1
    provisionerId:              "proj-autophone"
    publicIP:                   "127.0.0.1"
    requiredDiskSpaceMegabytes: 6500
    taskclusterProxyPort:       8099
    workerType:                 "${TC_WORKER_TYPE}"
    wstAudience:                "firefoxcitc"
    wstServerURL:               "https://firefoxci-websocktunnel.services.mozilla.com/"

Perhaps it's just a path issue... we don't specify the path to taskcluster-proxy. I don't see the class that g-w calls to start g-w doing any sort of input validation (so the path is probably empty?). https://github.com/taskcluster/taskcluster/blob/9cd42bac9e73bcd0048bf2fd46bbcc7ef733f5f7/workers/generic-worker/tcproxy/tcproxy.go

I'll make a new image and we can see if it helps.

This doesn't really explain why it would work some of the time though... it sounds like a docker bug if that's the case. We have limited control of the docker daemon as it's part of Bitbar's infastructure. I'll check what version they're running.

Thanks for the detailed answer!

Afaik, generic-worker would first check if feature is set taskclusterProxy: true and then will launch taskcluster-proxy (default TaskclusterProxyExecutable value) running on 127.0.0.1 (fixed value) using port :80 by default (taskclusterProxyPort)

And those tasks are using this feature, so it's really strange it works sometimes.

The way the autophone workers are set up (each g-w inside a docker container will start a taskcluster-proxy instance) is a bit inefficient, but it should work. I thought that the ports might be an issue if it's trying to use the same port on all containers, but that's just inside the container (we're not doing any port mapping). I don't think taskcluster-proxy needs to accept incoming requests (correct?)... so it shouldn't need a port mapping.

I think this is fair. If it runs inside a container, and launches that extra process, it shouldn't be exposed and the task should be able to talk to it.
And since g-w can only run one task at a time, there shouldn't be any collisions with multiple proxies running simultaneously.

What I'm concerned about is that tcproxy when starts should emit something to stdout: https://github.com/taskcluster/taskcluster/blob/v36.0.0/workers/generic-worker/tcproxy/tcproxy.go#L54

Started taskcluster proxy process (PID %v)

But I don't see any lines with proxy in the task above

UPD: those should be logged in the worker logs, not task logs..

Let's see if new image helps.

btw, it would be good to see worker logs (not the task logs)
Can those be accessed on the device?

There's also a trick to upload them as artifacts, if those logs are in the same container as the task. Someone who can run tasks on that pool can simply edit the task and add new artifact that points to the worker log location. And so it could be examined after task failure to see more details about those proxy calls.

Some other reasons could be OS killing proxy process because of resource constraints. Or maybe there are network-related issues, is this NDK big?

By looking at original android-ndk I can see that its size might be 600mb+ which is a lot!

In the logs we see:

[fetches 2024-06-02T19:04:55.367Z] Downloading http://localhost:8099/api/queue/...
[fetches 2024-06-02T19:06:45.849Z] Downloading http://localhost:8099/api/queue/...
[fetches 2024-06-02T19:06:46.182Z] Downloading http://localhost:8099/api/queue/...
[fetches 2024-06-02T19:08:20.228Z] Downloading http://localhost:8099/api/queue/...
[fetches 2024-06-02T19:10:34.410Z] Downloading http://localhost:8099/api/queue/...
[fetches 2024-06-02T19:13:58.090Z] Downloading http://localhost:8099/api/queue/...

So if the proxy wasn't running at that point, it would be retrying in a couple of seconds. Here retries are 2-3min apart
Which means that proxy is probably working and requests are reaching fxci api.

Here is what I think happens here:

  1. code sends request to fetch private artifact
  2. client library calls it through proxy
  3. proxy serves this request and returns redirect response (artifacts contain redirect url to the blob)
  4. client library is following this redirect and attempts to fetch the file
  5. request times out, or there is not enough free disk space to write and extract the file, it fails, and then tries again

client here is a taskgraph run-task/fetch-content + tc client library

If the size is the problem, I only really need the simpleperf directory. Can we just package that and host it?

Yeah, definitely. We'd just need to make a taskcluster/taskgraph configuration that does it.

It seems like taskcluster/scripts/misc/repack-android-ndk-linux.sh does it. That is called by a job defined in taskcluster/kinds/toolchain/android.yml. Releng can help you out if anything is confusing.

Summary: Cannot download android ndk in CI → Cannot download android ndk on bitbar CI worker

The severity field is not set for this bug.
:jmaher, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(jmaher)
Severity: -- → S2
Flags: needinfo?(jmaher)
Priority: -- → P1

:denispal, did you get some help? I saw you talking with :jcristau in Matrix #Firefox CI.

(In reply to Andrew Erickson [:aerickson] from comment #14)

:denispal, did you get some help? I saw you talking with :jcristau in Matrix #Firefox CI.

Yes, I seem to have it working for the moment by just repacking and uploading the simpleperf directory instead of the whole ndk.

So this isn't blocking me right now, but I still don't fully understand why the ndk fails to download and whether this will eventually happen to the simpleperf package too?

If it's just due to size, then I think the way these devices are hosted and/or the provider could be the issue. Retry logic/timeouts in tc-proxy/tc stack could be a contributing factor.

These phones are connected to Docker containers (8 per host). If 8 containers (times 6-10 docker hosts) are all trying to download 600MB of stuff, perhaps it overwhelms the hosts or networking.

Will you please post a treeherder link for a working task?

Here is the simpleperf repack I did a couple weeks ago which ended up working: https://treeherder.mozilla.org/jobs?repo=try&revision=523fb6ed241b22f1de3d9c5c225e05a9926b3028

Priority: P1 → P2

(In reply to Andrew Erickson [:aerickson] from comment #7)

numberOfTasksToRun:         1

This might not be helping the situation, usually this value should be 0, do you know if there is a reason it is set to 1? The value 1 is typically for when the worker is intended to be used for a single task and then thrown away.

Is this because the worker is run inside a docker container, which is discarded after running a single task? If that is the case, this may be fine.

Yeah, this makes sense as these workers run in a docker container that's recycled after every task.

You need to log in before you can comment on or make changes to this bug.