Skip to content

Plan ​

Plan and Change are declared in crates/api/src/plan.rs, the computation is PlanBetween::between in crates/kernel/src/plan.rs.

The plan is what reload does with every component when moving from the graph old to the graph new:

rust
pub enum Change {
    Added,
    Removed,
    Updated,                                    // the fingerprint changed
    DependencyChanged(BTreeSet<ComponentId>),   // own options are the same, something it depends on changed
}
pub struct Plan {
    pub changes: BTreeMap<ComponentId, Change>,
    pub unchanged: BTreeSet<ComponentId>,
}

Algorithm ​

  1. A component exists only in new — Added; exists in both with a different fingerprint — Updated.

  2. Exists only in old — Removed.

  3. For the remaining components of new, the reasons for DependencyChanged:

    • the symmetric difference of direct dependencies in old and new (a reference started pointing to another component, or the "default" changed);
    • transitive dependencies in new marked Added or Updated.

    No reasons — the component goes to unchanged.

A Removed dependency does not become a reason on its own: a component that referred to a removed one is caught by the edge difference.

Who reads the plan ​

  • Instance::build (crates/kernel/src/instance.rs) takes ready objects from the running configuration for the ids in plan.unchanged: outbounds, rule-sets, rules (route), inbounds. Everything else is built anew.
  • The DNS factory gets the plan and the previous Dns and decides itself what to reuse (DnsFactory, crates/api/src/module.rs).
  • Units get the plan in Build::plan (for example, ntp reuses the running client, Ntp::reusable).
  • check --diff prints the plan (app/ours/src/diff.rs) — see Reload.
  • Reloaded::plan is returned from Instance::reload; the binary logs the number of changed components.

The first configuration is built with an empty plan (Plan::default()), Build::reload == false.

GPL-3.0-or-later