Jump to content

EditCheckHeadless

From Wikitech

Edit Check was originally formulated as a set of improvements for the VisualEditor to help new volunteers understand and follow some of the policies and guidelines necessary to make constructive changes to Wikipedia projects. Building on its success, to bring edit suggestions to more places, EditCheckHeadless is a way to run the browser-based check code on a server, with computation happening on a carefully sandboxed headless VisualEditor instance.

It is envisaged that EditCheckHeadless will run behind the Linked Artifacts Cache, acting as the “lambda function” to generate a set of edit suggestions on a given article revision.

Maintainance

Maintainers: Editing Team

Phabricator tags: #editing-team, #ve-suggestion-mode

Repo: https://gitlab.wikimedia.org/repos/mediawiki/services/editcheck-headless

Deployment

Runs on wikikube in the editcheck-headless namespace, deployed from helmfile.d/services/editcheck-headless using the generic python-webapp chart. Reachable from inside production at editcheck-headless.discovery.wmnet (staging: editcheck-headless.k8s-staging.discovery.wmnet) through the wikikube Istio ingress gateway. It takes no traffic from the public edge.

Ports:

PortProtocolPurpose
50051gRPCThe traffic port. Implements the Linked Artifacts Cache LambdaService contract. Envoy forwards to it over pod-local loopback.
4693gRPC over TLSThe mesh port, terminated by the pod's Envoy sidecar. The only port reachable from outside the pod.
3000HTTPProbes only, plus /check and /config for debugging over kubectl port-forward. Has no Service.
9102HTTPPrometheus metrics.
9361HTTPEnvoy sidecar telemetry.

Dependencies

Outbound

Similar to Proton: everything the service fetches leaves the cluster for the public edge, so that edge rewrites and caching apply. The egress NetworkPolicy allows only the five text-lb VIPs on port 443.

  • Sitematrix — meta.wikimedia.org/w/api.php?action=sitematrix, fetched once at startup to map dbnames to base URLs.
  • MediaWiki action API — <wiki>/w/api.php, to resolve a page id to a title.
  • Target wikis — the headless browser navigates to <wiki>/w/index.php?title=Special:EditCheckHeadless, and the page's own JavaScript then fetches Parsoid HTML and page properties from the same origin.

Unlike Proton it needs no upload-lb: the browser runs with --blink-settings=imagesEnabled=false and aborts image, stylesheet, font and media requests.

Inbound

  • Linked Artifacts Cache — the only consumer. Calls GetRevisionArtifact over gRPC. It speaks plaintext to its own Envoy sidecar, so the TLS hop is sidecar to sidecar.

Runtime

  • Chromium, installed unpinned by the image build and absent from any lockfile. No dependency scanner reports its version, which is why the service exports editcheck_headless_browser_info.

Known failure mode

If the startup sitematrix fetch fails, dbname resolution is unavailable, the pinned wikis in MW_WIKIS cannot be resolved, and the process exits. A pod that cannot reach meta.wikimedia.org will therefore CrashLoopBackOff rather than start degraded.

Health checks

EndpointKubernetes probeMeaning
GET /healthzliveness200 while the process can answer. Says nothing about the browsers.
GET /readyzreadiness200 when every session that has launched has a connected browser and an open page. 503 otherwise, naming the wiki whose session is broken.

Keeping the k8s probes matched up to those endpoints is important: the service restarts its browser every 100 requests (--restart-every-requests); during that restart the pod is alive but momentarily cannot serve. If liveness consulted the browsers, Kubernetes would kill the pod mid-restart. Requests arriving during a restart are held in the run queue rather than rejected, so only a session that launched and is now broken makes the pod unready.

The service::catalog entry uses a tcp probe rather than http. The catalog probe targets the shared ingress gateway, which routes every path to the gRPC port, so an HTTP probe cannot get a meaningful answer. The tcp probe confirms the gateway is listening and the TLS handshake succeeds; per-pod health is enforced by the readiness probe above, which removes unready pods from the Service endpoints.

Metrics

Prometheus scrapes port 9102. Because the pod declares more than one container port, the deployment sets monitoring.named_ports: true so that only the port named app-metrics is scraped. Envoy sidecar metrics are scraped separately on 9361.

MetricTypeLabelsNotes
editcheck_headless_requests_totalcountertransport, endpoint, statustransport is http or grpc. Health probes excluded.
editcheck_headless_check_duration_secondshistogramwiki, outcomeTime running, excluding queue wait and the periodic browser restart.
editcheck_headless_queue_wait_secondshistogramwiki, taskTime spent waiting for a session. The saturation signal.
editcheck_headless_queue_depthgaugewikiTasks queued or running on a session.
editcheck_headless_suggestions_totalcountercheckSuggestions per check type. The "*" total is not recorded, being the sum of the rest.
editcheck_headless_browser_restarts_totalcounterreasonscheduled or crashed.
editcheck_headless_browser_infogaugeengine, versionAlways 1; the labels carry the value. The only report of which Chromium build is running. Overlay it on browser_restarts_total to attribute a restart spike to an image rebuild.
editcheck_headless_session_upgaugewiki, pinned1 when a started session has a live browser.
editcheck_headless_browser_processesgaugeBrowser processes under this service.
editcheck_headless_browser_rss_bytesgaugeSummed across browser processes, so shared pages are counted once per process: an upper bound.
editcheck_headless_browser_cpu_seconds_totalcounterAccumulated between samples, so it stays monotonic across browser restarts.

Signals to watch

  • Saturation — queue_wait_seconds and queue_depth. A session runs one check at a time, so concurrency is bounded by the browser count rather than by cores. Latency arrives as queueing before it arrives as slow checks.
  • Memory — browser_rss_bytes. We're not sure about this limit, and are running the technical pilot (task T432286) partially to measure it. The container limit is 3Gi, the namespace limitrange maximum for a single container.
  • Stability — browser_restarts_total{reason="crashed"}, read alongside browser_info.

Note that wiki is bounded: only wikis given a dedicated session via MW_WIKIS get their own label value, and everything else is bucketed.

Dashboards and logs

Logs are ECS JSON on stdout, shipped by the node's rsyslog to the per-cluster Kafka topic and on to Logstash, enriched with namespace, pod and container.

See also