Skip to content

Add DB entity for task suite and agent#226

Open
un-lock-able wants to merge 11 commits into
devfrom
task-suite-entity
Open

Add DB entity for task suite and agent#226
un-lock-able wants to merge 11 commits into
devfrom
task-suite-entity

Conversation

@un-lock-able

Copy link
Copy Markdown

New entities

  • task_suites — a group-owned batch of tasks with priority, worker schedule, exec hooks, task counters, and a TaskSuiteState.
  • agents — durable identity of a registered machine instance (not deleted on offline); tracks tags/labels, heartbeat, assigned suite, and AgentState.
  • machines — physical machine code + metadata for an agent (1:1, Restrict).
  • suite_agent_jobs — one attempt of an agent running a suite; per-suite job number, task counters, SuiteJobState, failure reason.
  • hook_tasks — one provision/cleanup/background hook run in a job; has its own uuid, logs stored in shared artifacts.
  • task_suite_agent — links a suite to its candidate agents (how it was selected).
  • group_agent — group→agent ACL row with GroupAgentRole, mirroring group_worker.

New enums in state.rs / role.rs: TaskSuiteState, AgentState, SuiteJobState, HookExecState, HookType, SelectionType, GroupAgentRole.

Changes to existing rows

  • active_tasks / archived_tasks — add nullable task_suite_id (FK, SetNull), propagated through the active→archived conversion.
  • artifactstask_id now holds either a task uuid or a hook uuid.

Co-authored-by: BobAnkh <bobankhshen@gmail.com>
@un-lock-able un-lock-able requested a review from BobAnkh July 6, 2026 08:24
Comment thread netmito/src/migration/mod.rs Outdated
Comment thread netmito/src/entity/state.rs Outdated
Comment thread netmito/src/entity/state.rs Outdated
Comment thread netmito/src/entity/state.rs
Comment thread netmito/src/entity/state.rs Outdated
Comment thread netmito/src/entity/suite_agent_jobs.rs Outdated
Comment thread netmito/src/entity/suite_agent_jobs.rs Outdated
Comment thread netmito/src/entity/suite_agent_jobs.rs
Comment thread netmito/src/entity/task_suites.rs
Comment thread netmito/src/migration/m20260703_000000_create_task_suite_tables.rs
@un-lock-able un-lock-able requested a review from BobAnkh July 14, 2026 10:21
Comment thread netmito/src/entity/group_worker.rs
Comment thread netmito/src/entity/state.rs
Comment on lines +460 to +468
// Timeout lives in the exec spec; default to 600s if unset/unparseable.
let timeout_secs = serde_json::from_value::<ExecSpec>(task.spec.clone())
.ok()
.and_then(|s| s.timeout)
.map(|t| t.as_secs() as i64)
.unwrap_or(600);
// We allow a 60 seconds grace period
if TimeDateTimeWithTimeZone::now_utc() - task.updated_at
> time::Duration::seconds(task.timeout + 60)
> time::Duration::seconds(timeout_secs + 60)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use some database query to avoid the serialization on our side? Can we just select the necessary columns from the db?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The manual deserializing in this code is indeed redundent and the same functionality can be achieved using a sql query. However, this code mistakenly assumes that timeout is a int, which is not the actual case.

ExecSpec stores timeout as a humantime string, so the actual content is something that looks like {"timeout": "1m"}. If we were to keep using ExecSpec in both schema and database storage, we have to manually deserialize the time because sql cannot deserialize humantime strings into seconds.

Should I change this code to use humantime deserializing or shouldI create a struct different from ExecSpec in schema.rs that stores timeout as an int and store that into the database instead?

Comment on lines +972 to +979
// runner_uuid holds worker UUIDs, so map the worker ids to uuids.
let runner_uuid_subquery = Query::select()
.column((Worker::Entity, Worker::Column::WorkerId))
.from(Worker::Entity)
.and_where(
Worker::Column::Id.in_subquery(worker_filter_subquery.clone()),
)
.to_owned();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this??

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is copied from the impl-task-suite branch. Maybe we should discuss more on this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then you should understand and check what it is, to see if it is necessary in our current implementation. I don't know if it suits your current impl.

Comment thread netmito/src/migration/m20260703_000001_alter_tasks_link_suites.rs Outdated
Comment thread netmito/src/migration/m20260703_000001_alter_tasks_link_suites.rs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants