Flow Agent
Flow Agent keeps an inventory of Flow pipelines for each configured target cluster and
periodically stores their status. It runs as the standalone yt/yt/flow/bin/flow_agent
binary. The agent discovers pipelines from the target cluster's snapshot export, polls
every discovered pipeline, and writes the results to a dynamic table. Read that table
directly to inspect the results.
Configuration
The agent reaches every cluster through an RPC proxy. Credentials come from the
YT_TOKEN environment variable (and optionally YT_USER) and are shared by all clusters.
Do not put the token into the configuration file.
The required state section names the state cluster and the state root that hold the state of
all target clusters; the required clusters section lists the target clusters:
{
state = {
rpc_proxy = {cluster_url = "state-cluster";};
root = "//home/flow-agent";
};
clusters = {
cluster_a = {};
cluster_b = {
rpc_proxy = {cluster_url = "cluster-b.example.com";};
agent = {poll_period = 60000;};
};
};
}
- The key of
clustersis the target cluster name.clusters.<name>.rpc_proxyis optional:
by default the agent connects to the cluster URL<name>. clusters.<name>.agentholds the polling options:snapshot_periodandpoll_period
(five minutes by default),scan_batch_size(500 rows per inventory page and per snapshot export batch), and
poll_concurrency(16 pipelines polled in parallel).clusters.<name>.election_managerholds the leader election options, exceptlock_path.- State-cluster operations: inventory reads and writes and leader election.
- Target-cluster operations: the snapshot export read, the per-pipeline
get #<id>, and
describe-pipeline. - All target clusters share one inventory table,
<root>/pipelines; each cluster's rows
carry its name in theclusterkey column. Each target cluster has its own lock
<root>/agent_leader_locks/<cluster>and leader, which reads and writes only the rows of
its cluster. Both paths are derived fromstate.root;election_manager.lock_pathmust
not be set. - A configured cluster name must match
//sys/@cluster_connection/cluster_nameof the
target cluster. A cluster that has not initialized yet is retried every
cluster_initialization_retry_period(five seconds by default) and does not block the
other clusters.
Inventory table
| Column | Type | Description |
|---|---|---|
cluster |
string, key |
Target cluster name, the key in clusters. |
pipeline_id |
string, key |
Cypress object ID of the pipeline. |
live_path |
string |
Current pipeline path. |
pipeline_format_version |
int64 |
Pipeline format marker. |
pipeline_name |
string |
Pipeline name, if known. |
summary |
any |
Last full result: status returned by describe-pipeline with status_only=%true. |
last_successful_poll_time |
int64 |
Time when summary was received, in microseconds. |
partial_summary |
any |
Last partial result; null after a full result. |
partial_poll_time |
int64 |
Time when partial_summary was received, in microseconds. |
poll_error |
any |
Last poll error; null after a full or partial result. |
poll_error_time |
int64 |
Time when poll_error was received, in microseconds. |
access_denied |
boolean |
Whether the agent's user lacks read permission on the pipeline. |
The leader reads every new export referenced by //sys/admin/snapshots/snapshot_exports/latest.
The export must contain the id, path, pipeline_format_version,
cypress_transaction_id, and orphaned columns. The pipeline_name column is
optional: if it is missing, the agent does not overwrite stored names. Every node with an
integer pipeline_format_version is a pipeline; an unsupported version shows up as a poll
error. Data freshness is bounded by the export period.
Each new export fully syncs the rows of its cluster: the leader upserts every exported
pipeline and deletes the cluster's rows absent from the export. After a leader change the
latest export is applied again, so the row of a pipeline deleted since that export may
reappear until the next poll.
The export is the standard master snapshot export produced by the YT cluster, not by the
agent: after each master snapshot, the cluster writes rows of Cypress nodes with a
whitelisted set of attributes under //sys/admin/snapshots/snapshot_exports, and latest
points to the newest export. The agent only reads it. The pipeline_format_version
attribute, and optionally pipeline_name, must be in the export attribute whitelist of the
target cluster; the cluster administrators configure it.
Polling deletes the row of a pipeline that no longer exists or no longer carries the
Flow pipeline marker. Each poll result goes to one of three layers:
- Full:
describe-pipelinereturns a complete description built from the controller's flow
view (partialis%falseor absent). The agent writessummaryand clears the partial and
error layers. - Partial: the controller responds with
partial=%truebecause it has no flow view yet, for
example right after a start, or
the agent reads the pipeline node, butdescribe-pipelinefails, for example because the
controller is stopped or unreachable. In the first case,partial_summaryis the
controller's response; in the second case, it is a map withlive_path,pipeline_name,
leader_controller_address(if the controller has published it), anddescribe_error. The
agent keepssummaryand clears the error layer. - Error: the agent cannot read the pipeline node,
readon it is denied, or the response is
malformed. The agent writespoll_errorand keepssummaryandpartial_summary.
Inaccessible pipelines
The agent's user may lack read permission on some pipelines. The agent keeps such
pipelines in the inventory and sets access_denied=%true. Their path and name come
from the snapshot export, and summary keeps its last known value. access_denied is set
only when the error denies read on the object itself. Other authorization errors, such
as a missing permission on an RPC proxy role, do not change access_denied. After
access is granted, the next successful get sets access_denied=%false.
Who can see the state
Anyone who can read the inventory table sees the paths, names, statuses, controller
messages and addresses, authentication data, and errors of all inventoried pipelines, regardless of the
target clusters' ACLs. Grant read on the state root only to a trusted group.
ACLs are inherited from the state root; the agent does not set them.
State initialization
Before the first start, a user with mount permission on the state root creates the
state. Each target cluster's agent creates its own lock node
<root>/agent_leader_locks/<cluster>, so the state does not depend on the list of target
clusters.
Create the following objects by hand, without setting ACLs:
- the
<root>/pipelinessorted dynamic table with the schema from the
Inventory table section: key columnsclusterandpipeline_id,
strict schema, unique keys; mount the table; - the
<root>/agent_leader_locksmap node.
The agent's user does not need mount, so after bundle maintenance the table is
remounted by a person.
Preconditions:
- the agent's user has
read,write, andremoveon the state root; - the agent's user has
useon the tablet cell bundle; - the account of the state root has tablet quota;
- the agent's user can read the snapshot export on every target cluster.
Diagnostics
The agent has no RPC API. Component status is published in Orchid on the monitoring HTTP
port under /orchid/clusters/<cluster>/{status,polling,snapshot_reconciliation}.