Commit Graph

227 Commits

Author SHA1 Message Date
Oliver Chang 28ba247ccf
Fix introspector scheduling exception. (#12640)
This was caused by a very old refactor, but we never deployed the
introspector scheduler since then so we didn't run into this until now.
2024-10-23 09:19:42 +11:00
Oliver Chang d288d1bc52
Fix typo (#12624) 2024-10-21 15:25:28 +11:00
Oliver Chang 4b20cd8564
Fix base builder exception. (#12623) 2024-10-21 15:00:54 +11:00
DavidKorczynski 9e9ed9bb7e
infra: build: introspector: upload artifacts in all cases (#12609)
Upload introspector report even when build fails. This is to ensure
artifacts from FI light is uploaded for each build.

---------

Signed-off-by: David Korczynski <david@adalogics.com>
2024-10-17 20:34:19 +01:00
Dongge Liu bc81d57248
Customize cloud build region (#12601)
Avoids hardcoding cloud build region to `us-central1`, so that users
(e.g., `target_experiment.py`) can define their own region.
2024-10-16 10:33:57 +11:00
DavidKorczynski d28f6e6f3e
infra: build: functions: add default empty list for tags (#12522)
This caused a regression for experiments in OFG.

```sh
2024-09-20 22:39:56.906 INFO models - do_generate: vertex_ai_gemini-1-5 generating response with config: {'temperature': 0.6, 'max_output_tokens': 8192}
2024-09-20 22:39:57.088 ERROR builder_runner - _run_with_retry_control: Failed to evaluate /experiment/results/output-htslib-hfile_list_plugins/fixed_targets/02.c on cloud, attempt 1:

Traceback (most recent call last):	  File "/tmp/tmp5dlnpp7z/infra/build/functions/target_experiment.py", line 339, in <module>	    main()	  File "/tmp/tmp5dlnpp7z/infra/build/functions/target_experiment.py", line 332, in main	    run_experiment(args.project, args.target, args.args, args.upload_output_log,	  File "/tmp/tmp5dlnpp7z/infra/build/functions/target_experiment.py", line 288, in run_experiment	    extra_tags=[experiment_name, project_name] + tags)	               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~	TypeError: can only concatenate list (not "NoneType") to list	
2024-09-20 22:39:57.088 INFO evaluator - log: Fixing /experiment/results/output-htslib-hfile_list_plugins/fixed_targets/02.c with vertex_ai_gemini-1-5, attempt 1.
2024-09-20 22:39:57.088 WARNING prompt_builder - _format_fixer_problem: Unexpected empty error message in fix prompt for error_desc: None
2024-09-20 22:39:57.089 INFO models - do_generate: vertex_ai_gemini-1-5 generating response with config: {'temperature': 0.46, 'max_output_tokens': 8192}
```

From https://github.com/google/oss-fuzz-gen/pull/636

Ref: https://github.com/google/oss-fuzz/pull/12520
2024-09-20 15:01:20 +01:00
Dongge Liu bf53d7f396
Add tags to cloud build from target_experiment.py (#12520)
This helps us to identify and debug cloud build from OFG.
2024-09-20 13:57:12 +10:00
jonathanmetzman 791e7d2f05
[trial_build] Fix handling of languages. (#12196)
Consider "ruby" a language before a project.
2024-07-10 12:02:48 -04:00
jonathanmetzman 94ef0c2e24
Build base ruby image. (#12181) 2024-07-09 12:41:19 -04:00
jonathanmetzman 23a76bdb3b
Format and lint (#12189) 2024-07-09 12:39:50 -04:00
jonathanmetzman 30c0bd918e
Remove unused import (#12188) 2024-07-09 12:23:21 -04:00
jonathanmetzman 9879155297
Fix linter complaints in build_lib (#12186) 2024-07-09 12:22:33 -04:00
DavidKorczynski ed2bfb5d27
Revert "Update Centipede" (#12160)
Reverts google/oss-fuzz#11151 as it breaks the base builder

Ref:
https://github.com/google/oss-fuzz/pull/11151#issuecomment-2208641953

---------

Signed-off-by: David Korczynski <david@adalogics.com>
2024-07-04 16:37:37 +01:00
jonathanmetzman 86a5bee369
Teach build infra about ruby (#12153)
https://github.com/google/oss-fuzz/issues/11967
2024-07-02 19:24:43 -04:00
Dongge Liu da925a6332
Add timeout for `target_experiment.py` (#11972)
Add a 3-hour timeout to `target_experiment.py`, which should be more
than enough given fuzzing timeout is 30 minutes and most successful
cloud builds finish in 2.5 hours empirically.
2024-05-20 11:38:03 +10:00
cjx10 090e0d6771
Add hint text when jcc err.log does not get created (#11822)
Some project (e.g.
[civetweb)](88dad2f6ef/Makefile (L84))
does not use jcc to build fuzz targets.
This pr:
1. Prevents cloud build fail at upload jcc err step.
2. Add hint text in err.log for uploading.

---------

Co-authored-by: Jim Choi <jimchoi@google.com>
2024-04-23 12:55:52 +10:00
cjx10 1204148100
Change JCC error log location and upload (#11789)
Upload `JCC`'s error log to assist `OSS-Fuzz-Gen` analyzing and
classifying build errors:
1. Change JCC `err.log` location, because`/out` was removed before
`compile` by default and `err.log` cannot be saved there.
2. Add a step in `target_experiment.py` to upload `err.log` to gcloud
bucket.

---------

Co-authored-by: Jim Choi <jimchoi@google.com>
2024-04-17 09:01:45 +10:00
Dongge Liu fc6b28d2ec
Reapply "target_experiment: don't use gcloud. (#11701)" (#11727) (#11732)
This reverts commit a80fd730e4.

The investigation shows that the slowness issues and `BrokenPipe` error
mentioned in
https://github.com/google/oss-fuzz/pull/11727#issue-2205034022 are not
caused by #11701, so this PR reverts #11727.

Queued cloud builds of a full experiment likely caused the slowness.
Specifically, some cloud builds' `BrokenPipe` error caused them to queue
forever, which blocks other cloud builds and causes the slowness.
This should have been solved by #11729, I will start another full
experiment shortly and verify that.
2024-03-26 11:49:49 +11:00
Dongge Liu a80fd730e4
Revert "target_experiment: don't use gcloud. (#11701)" (#11727)
This reverts commit 66bcb5af81 to help
investigate a recent slowness and errors in OSS-Fuzz-Gen.
Related: https://github.com/google/oss-fuzz-gen/pull/177.

Specially, here is [the
error](https://pantheon.corp.google.com/logs/query;cursorTimestamp=2024-03-25T06:45:55.502596773Z;duration=P7D;query=resource.type%3D%22k8s_container%22%0Aresource.labels.project_id%3D%22oss-fuzz%22%0Aresource.labels.location%3D%22us-central1-c%22%0Aresource.labels.cluster_name%3D%22llm-experiment%22%0Aresource.labels.namespace_name%3D%22default%22%0Alabels.k8s-pod%2Fbatch_kubernetes_io%2Fcontroller-uid%3D%226d6e5719-618b-4e3d-a161-065c116ccfc0%22%20severity%3E%3DDEFAULT%0A--Hide%20similar%20entries%0A-%2528textPayload%3D~%22WARNING:root:Missing%20result%20JSON%20of%20benchmark%20instance:%20%5B%5E%20%3D%5Ct%5Cn%5Cr%5Cf%5C%22%5C%2528%5C%2529%5C%5B%5C%5D%5C%7C'%5D%2B%20-%20%2528%2528%3F:%5Cd%5B,.%5D%3F%2529*%5Cd%2529%22%2529%0A--End%20of%20hide%20similar%20entries%0Atimestamp%3D%222024-03-25T06:45:55.502596773Z%22%0AinsertId%3D%22fw412us1tsys1vfh%22?project=oss-fuzz)
shown in recent experiments:
```json
{
  "textPayload": "Traceback (most recent call last):\t  File \"/tmp/tmpi8uy26ij/infra/build/functions/target_experiment.py\", line 296, in <module>\t    main()\t  File \"/tmp/tmpi8uy26ij/infra/build/functions/target_experiment.py\", line 289, in main\t    run_experiment(args.project, args.target, args.args, args.upload_output_log,\t  File \"/tmp/tmpi8uy26ij/infra/build/functions/target_experiment.py\", line 255, in run_experiment\t    build_lib.wait_for_build(build_id, credentials, 'oss-fuzz')\t  File \"/tmp/tmpi8uy26ij/infra/build/functions/build_lib.py\", line 627, in wait_for_build\t    id=build_id).execute()\t                 ^^^^^^^^^\t  File \"/tmp/tmpi8uy26ij/venv/lib/python3.11/site-packages/googleapiclient/_helpers.py\", line 134, in positional_wrapper\t    return wrapped(*args, **kwargs)\t           ^^^^^^^^^^^^^^^^^^^^^^^^\t  File \"/tmp/tmpi8uy26ij/venv/lib/python3.11/site-packages/googleapiclient/http.py\", line 892, in execute\t    resp, content = _retry_request(\t                    ^^^^^^^^^^^^^^^\t  File \"/tmp/tmpi8uy26ij/venv/lib/python3.11/site-packages/googleapiclient/http.py\", line 204, in _retry_request\t    raise exception\t  File \"/tmp/tmpi8uy26ij/venv/lib/python3.11/site-packages/googleapiclient/http.py\", line 177, in _retry_request\t    resp, content = http.request(uri, method, *args, **kwargs)\t                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\t  File \"/tmp/tmpi8uy26ij/venv/lib/python3.11/site-packages/google_auth_httplib2.py\", line 209, in request\t    self.credentials.before_request(self._request, method, uri, request_headers)\t  File \"/tmp/tmpi8uy26ij/venv/lib/python3.11/site-packages/google/auth/credentials.py\", line 133, in before_request\t    self.refresh(request)\t  File \"/tmp/tmpi8uy26ij/venv/lib/python3.11/site-packages/google/auth/compute_engine/credentials.py\", line 99, in refresh\t    self._retrieve_info(request)\t  File \"/tmp/tmpi8uy26ij/venv/lib/python3.11/site-packages/google/auth/compute_engine/credentials.py\", line 79, in _retrieve_info\t    info = _metadata.get_service_account_info(\t           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\t  File \"/tmp/tmpi8uy26ij/venv/lib/python3.11/site-packages/google/auth/compute_engine/_metadata.py\", line 227, in get_service_account_info\t    return get(\t           ^^^^\t  File \"/tmp/tmpi8uy26ij/venv/lib/python3.11/site-packages/google/auth/compute_engine/_metadata.py\", line 146, in get\t    response = request(url=url, method=\"GET\", headers=_METADATA_HEADERS)\t               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\t  File \"/tmp/tmpi8uy26ij/venv/lib/python3.11/site-packages/google_auth_httplib2.py\", line 119, in __call__\t    response, data = self.http.request(\t                     ^^^^^^^^^^^^^^^^^^\t  File \"/tmp/tmpi8uy26ij/venv/lib/python3.11/site-packages/httplib2/__init__.py\", line 1724, in request\t    (response, content) = self._request(\t                          ^^^^^^^^^^^^^^\t  File \"/tmp/tmpi8uy26ij/venv/lib/python3.11/site-packages/httplib2/__init__.py\", line 1444, in _request\t    (response, content) = self._conn_request(conn, request_uri, method, body, headers)\t                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\t  File \"/tmp/tmpi8uy26ij/venv/lib/python3.11/site-packages/httplib2/__init__.py\", line 1367, in _conn_request\t    conn.request(method, request_uri, body, headers)\t  File \"/usr/lib/python3.11/http/client.py\", line 1282, in request\t    self._send_request(method, url, body, headers, encode_chunked)\t  File \"/usr/lib/python3.11/http/client.py\", line 1328, in _send_request\t    self.endheaders(body, encode_chunked=encode_chunked)\t  File \"/usr/lib/python3.11/http/client.py\", line 1277, in endheaders\t    self._send_output(message_body, encode_chunked=encode_chunked)\t  File \"/usr/lib/python3.11/http/client.py\", line 1037, in _send_output\t    self.send(msg)\t  File \"/usr/lib/python3.11/http/client.py\", line 998, in send\t    self.sock.sendall(data)\tBrokenPipeError: [Errno 32] Broken pipe\t",
  "insertId": "fw412us1tsys1vfh",
  "resource": {
    "type": "k8s_container",
    "labels": {
      "location": "us-central1-c",
      "namespace_name": "default",
      "pod_name": "ofg-pr-177-dg-cxszc",
      "cluster_name": "llm-experiment",
      "container_name": "experiment",
      "project_id": "oss-fuzz"
    }
  },
  "timestamp": "2024-03-25T06:45:55.502596773Z",
  "severity": "ERROR",
  "labels": {
    "k8s-pod/batch_kubernetes_io/controller-uid": "6d6e5719-618b-4e3d-a161-065c116ccfc0",
    "k8s-pod/job-name": "ofg-pr-177-dg",
    "compute.googleapis.com/resource_name": "gke-llm-experiment-ofg-pr-exp-2621ef4f-sms5",
    "k8s-pod/batch_kubernetes_io/job-name": "ofg-pr-177-dg",
    "k8s-pod/controller-uid": "6d6e5719-618b-4e3d-a161-065c116ccfc0"
  },
  "logName": "projects/oss-fuzz/logs/stderr",
  "receiveTimestamp": "2024-03-25T06:45:57.681367653Z"
}
```
2024-03-25 23:39:11 +11:00
Oliver Chang d2d9728a9d
Handle BrokenPipeError in wait_for_build (#11729)
The GCE metadata server can be unresponsive sometimes, resulting in this
exception.

This should address the root cause of the stack trace pointed out in
https://github.com/google/oss-fuzz/pull/11727
2024-03-25 19:36:29 +11:00
Dongge Liu 153df7202e
Unify the bucket directory name for target binary in `target_experiment.py` (#11713)
Related: https://github.com/google/oss-fuzz-gen/pull/172, #11700.
This simplifies the link generation in benchmark `JSON`.
Previously, the binary directory name matches the binary name, now it is
always called `target_binary/`.
2024-03-20 15:29:59 +11:00
Dongge Liu 6bc246b980
`target_experiment.py` uploads reproducer and binary in target_experiment.py (#11700)
Helps https://github.com/google/oss-fuzz-gen/issues/156:

1. `target_experiment.py` takes a new parameter,
`upload_reproducer_path`.
2. `target_experiment.py` saves crash reproducer to
`local_artifect_path`.
3. `target_experiment.py` uploads the fuzz target binary and the crash
reproducer to bucket directory `upload_reproducer_path`.
2024-03-19 11:20:25 +00:00
Oliver Chang 66bcb5af81
target_experiment: don't use gcloud. (#11701)
Instead, tar up the project directory ourselves, upload this to GCS, and
create the Build ourselves.

This is also a lot more efficient, as we're excluding a lot of
unnecessary dirs from being uploaded.

Fixes: https://github.com/google/oss-fuzz-gen/issues/163
2024-03-18 12:02:52 +11:00
Oliver Chang 2e0110a1e3
target_experiment: Avoid rate limiting issues with cloudbuild get. (#11530)
Instead of relying on `gcloud builds submit` to poll the status of the
build for us, we poll ourselves.

This is because `gcloud builds submit` has a fixed poll interval of 1
second.
2024-01-23 16:46:31 +11:00
Dongge Liu 4b21830e20
Change to `WORKDIR` before running commands in cloud project experiments. (#10918)
Mitigates the known issue where we don't automatically change to the
`WORKDIR` defined in `Dockerfile` when running cloud experiments.

Question:
Would it be preferred if I introduce a flag for this?
(e.g., `--use_workdir` or `--workdir=/src/<project>`)
While this gives more flexibility, I feel `cd` to `WORKDIR` should
always be preferred if we want the cloud experiments to behave the same
as local ones.
2023-09-14 07:05:18 -04:00
jonathanmetzman 3a03d05357
Fix jcc path (#10878) 2023-08-23 16:31:02 -04:00
jonathanmetzman cac76d7045
Update target_experiment.py (#10877) 2023-08-23 16:15:18 -04:00
jonathanmetzman 7e4fde5042
Fix typo (#10876) 2023-08-23 15:56:33 -04:00
jonathanmetzman 45d49c8f84
Improve jcc (#10783)
1. Put it in a better location on disk.
2. Move it to its own directory.
3. Add tests.
4. Make jcc able to find missing headers.
2023-08-15 12:23:09 -04:00
Dongge Liu 40c2a8a4a3
Fix `project_experiment.py`: Support copying directories (#10812) 2023-08-09 05:10:26 +00:00
Oliver Chang 777176bba5
target_experiment: Upload raw coverage data. (#10774)
This makes them easier to manipulate.
2023-08-02 16:07:24 +10:00
Dongge Liu 94bb76ecd1
Bumping PyYAML to 6.0 (#10770) 2023-08-01 10:16:33 -04:00
Oliver Chang e213ae15d3
target_experiment: Print build logs. (#10763)
To make it more convenient to browse results on GCB.
2023-07-31 16:46:25 +10:00
Dongge Liu 9046b096a7
Minor fix `project_experiment.py` (#10754)
Copy the content in `/workspace/out/` only.
No need to copy the parent `out` directory level.
2023-07-28 01:02:44 +00:00
Oliver Chang a670bdf642
Add project_experiment.py (#10739)
This allows us to run arbitrary scripts inside project containers on
GCB.

All files in `/workspace/out` are upload to a specified GCS path at the
end.

Usage:
```bash
$ python project_experiment.py --project libxml2 --command 'python3 /workspace/hello.py' \
  --experiment_name test-ochang \
  --upload_output gs://BUCKET/to/upload/NAME
```

(Where /workspace is the OSS-Fuzz repository).
2023-07-24 15:45:47 +10:00
Oliver Chang bf04c203db
Support jcc for cloud experiments. (#10738) 2023-07-24 12:35:02 +10:00
jonathanmetzman f90bfa77f6
Fix experiment tagging (#10725) 2023-07-19 13:11:08 -04:00
jonathanmetzman 189073d2bf
Support named experiments (#10723)
Named experiments will be tagged: `branch-$EXPERIMENT_NAME`
2023-07-19 11:04:48 -04:00
Oliver Chang fa9f387bac
target_experiment: fixes. (#10697)
- Fix coverage report generation. The wrong corpus was being used.
- Delete the corpus.zip after we upload it.
2023-07-13 16:24:01 +10:00
Oliver Chang 479cd263f3
Use a separate buildpool for experiments. (#10676)
To avoid contention when production builds are running.
2023-07-10 03:12:10 +00:00
Oliver Chang 20112bf1fe
target_experiment: upload build log properly when the build failed. (#10652)
Previously the cloud build exited before we upload the logs. Now we
write a file to record build success and report the failure later after
uploading the log if there was one.
2023-07-07 09:42:43 +10:00
Oliver Chang edadf41dcd
Don't tee build logs. (#10647)
`tee` will override the compile return code.
2023-07-06 10:09:04 +10:00
Oliver Chang 5c2fcc0b5c
Upload corpus and coverage in target_experiment.py (#10646)
Also update build_project.Config to be a dataclass instead of
namedtuple.
2023-07-05 05:18:09 +00:00
Holly Gong dff23c9f39
Reformat trial build logs (#10549)
https://github.com/google/oss-fuzz/issues/8774
1. Lists all running builds and their public accessible logs.
2. Writes logs when a build fails instead of waiting for all builds to
finish.
3. Writes a summary to list all failed builds and their logs. 
4. Lists all ongoing builds every hour.
5. When timeout:
  - Lists projects that failed within the timeout.
  - Lists projects that timed out.
- Timeout example:
https://github.com/google/oss-fuzz/pull/10549/checks?check_run_id=14426868359
2023-06-23 11:22:16 +10:00
Oliver Chang 89901fae76
target_experiment.py: Don't let failed fuzzer runs block log uploading. (#10548) 2023-06-16 13:55:14 +10:00
Oliver Chang 21d3e3b39c
Add target experiment script. (#10544)
This launches a GCB build for a project, runs a specified fuzz target
with specified arguments, and uploads the output to a specified path.

e.g.

```
python infra/build/functions/target_experiment.py --project=libxml2 --target xml \
    --output_log gs://oss-fuzz-gcb-experiment-run-logs/output.log -- -max_total_time=30
```
2023-06-16 07:42:57 +10:00
jonathanmetzman a542551e36
Fail when no project is built (#10539) 2023-06-15 10:08:09 -04:00
jonathanmetzman ba2d05b222
[gcb] Support builds with local experimental projects (#10525) 2023-06-14 13:07:29 +10:00
Dongge Liu ed7a556402
Increase trial build timeout to 7 hours (#10433)
Addresses [@jonathanmetzman's
suggestion](https://github.com/google/oss-fuzz/pull/10409#issuecomment-1571166932).
2023-06-05 17:03:20 +10:00
jonathanmetzman b855610e9d
Simplify build infra (#10164) 2023-05-01 16:02:18 -04:00