iya-sts
    Preparing search index...

    The SPIFFE target-group reconcile (#323).

    Index
    • Returns SpiffeTargets

    failing: boolean = false

    True after a reconcile has failed, until one succeeds. The error code is logged on the transition, not on every retry.

    INTERVAL_MS: number = 15000

    How often the leader reconciles, in milliseconds. The groups' TCP health check is 10 seconds and unhealthy after 3, so a stale address is removed inside that window.

    JOB_ID: string = 'spiffe.target-reconcile'

    The scheduler's id. Dot-separated words, which is the id shape cluster/scheduler.ts accepts.

    METADATA_MAX: number = ...

    The most metadata that is read. A task document is a few kilobytes.

    METADATA_MS: number = 2000

    How long the task-metadata read waits. The address is link-local.

    STOP_MS: number = 3000

    How long a stop waits for its own address to be deregistered before the rest of shutdown continues. The deregistration delay on the group is 30 seconds and does not need this process to stay up.

    stopping: boolean = false

    Set by beginStop(). An in-flight reconcile does not register after this, and the job's off() answers so the scheduler does not start another.

    • The shutdown flag. Called before the scheduler stops, so a reconcile already inside reconcileGroups() sees it before the next mutating call.

      Returns void

    • Registers or deregisters. No availability zone: an IP target in this VPC does not take one, and sending one would be a different target.

      Parameters

      • client: any
      • sdk: any
      • arn: string
      • targets: TargetMember[]
      • register: boolean

      Returns Promise<unknown>

    • The two clients, constructed with the default credential chain. AWS_REGION is already set on the task (environment/ecs.tf). Nothing is called until a reconcile sends.

      Parameters

      • elbSdk: any
      • ecsSdk: any

      Returns CloudClients

    • The cluster name from a task's Cluster field: the ARN's last segment, or the field itself when it is already a name.

      Parameters

      • value: unknown

      Returns string

    • The private addresses of arns, a hundred at a time (DescribeTasks' limit). A task that is not a node's (isNodeTask()) or has no IPv4 address is skipped.

      Parameters

      • client: any
      • sdk: any
      • cluster: string
      • arns: string[]

      Returns Promise<TaskAddress[]>

    • Registers the job, once. Every process calls this (protocol_stack.ts); registering starts nothing. A narrow test with no scheduler is ignored.

      Parameters

      • scheduler: { job?: (id: string) => any; register?: (spec: any) => any }

      Returns void

    • The current members of one group. Health is ignored by the reconcile; it is returned so a caller can see it.

      Parameters

      • client: any
      • sdk: any
      • arn: string

      Returns Promise<TargetMember[]>

    • Whether a full reconcile must not mutate. A deregister-only stop is never halted: it is the call that removes this task.

      Parameters

      • deregisterOnly: boolean
      • opts: { stopping?: boolean | (() => boolean) }

      Returns boolean

    • The first private IPv4 address on a task, from an ECS attachment detail or a container network interface, or from the task-metadata document's Containers[].Networks[].IPv4Addresses.

      Parameters

      • task: any

      Returns string

      the address, or ''

    • Whether value is an IPv4 address with no leading zeros. A leading zero is rejected so a metadata field that is not an address cannot be registered.

      Parameters

      • value: unknown

      Returns boolean

    • Whether task was started by one of this cluster's node services. ECS names a service's tasks' group service:<service name>, and the node services are <cluster>-node-a, -node-b, ... (environment/ ecs.tf). Anything else RUNNING in the cluster — the suite runner and the cell conversion are run-task tasks here (family:...), and a service added later would be another name — is not a node, and its address in a SPIFFE target group would be a target nothing answers on (#674's review, #695).

      Parameters

      • task: any

        a DescribeTasks entry

      • cluster: string

        this cluster's name

      Returns boolean

    • Whether digits is a TCP port written without a leading zero.

      Parameters

      • digits: string

      Returns boolean

    • Whether name is one of prefix's SPIFFE target groups: <prefix>-sp- and a port, or a cell's <prefix>-s and a port. -sp- is tried first, so <prefix>-sp-8092 is not read as -s plus p-8092. <prefix>-https and the other four service groups match neither.

      Parameters

      • name: string

        the target group's name

      • prefix: string

        this cluster's name

      Returns boolean

    • Every page of DescribeTargetGroups. The action cannot be scoped to an ARN, so the caller filters by name.

      Parameters

      • client: any
      • sdk: any

      Returns Promise<TargetGroup[]>

    • The RUNNING tasks' ARNs in cluster. Paged.

      Parameters

      • client: any
      • sdk: any
      • cluster: string

      Returns Promise<string[]>

    • The AWS clients, or null when either package is not installed. Both are optional peers (package.json); an image that was not built with them records STS-CLUSTER-0027 rather than failing to load.

      Returns CloudClients

    • Logs STS-CLUSTER-0027 once per outage and returns the line, which the caller throws so the scheduler records the run as failed.

      Parameters

      • message: string

      Returns string

    • The front process, after its listeners are bound. A failure is caught: the service is already answering, and the next job retries.

      Returns void

    • Deregisters this task's address. Never rejects: shutdown is going on with or without the load balancer. opts.timeoutMs shortens the wait, which a test uses; a stop passes nothing and waits STOP_MS.

      The one-shot timer does not reschedule itself. The reconcile is the periodic work, and it is the scheduler's job.

      Parameters

      • Optionalopts: {
            clients?: CloudClients;
            loadClients?: () => CloudClients;
            metadataUri?: string;
            self?: { cluster?: string; ip?: string };
            tasks?: TaskAddress[];
            timeoutMs?: number;
        }

      Returns Promise<ReconcileSummary>

    • This task's cluster and address from base + /task.

      Parameters

      • base: string

        ECS_CONTAINER_METADATA_URI_V4

      Returns Promise<{ cluster: string; ip: string }>

    • Reads url over HTTP. The task-metadata address is http, and the socket timeout is the request's own timeout — a setTimeout call here would be a timer this module does not have.

      Parameters

      • url: string

      Returns Promise<string>

    • Compares opts.elb's SPIFFE groups with the running addresses.

      opts.tasks is the addresses ListTasks returned. opts.self.ip is unioned in, so a task the list does not have yet is still registered. opts.deregisterOnly removes opts.self.ip and registers nothing. opts.stopping true (or beginStop() having been called) makes a full reconcile leave the groups alone.

      Parameters

      • opts: {
            deregisterOnly?: boolean;
            elb?: ElbApi;
            self?: { cluster?: string; ip?: string };
            stopping?: boolean | (() => boolean);
            tasks?: (string | TaskAddress)[];
        }

      Returns Promise<ReconcileSummary>

    • Reconciles from task metadata and the AWS clients.

      With no metadata address this is a no-op and does not throw. opts.self, opts.clients, opts.tasks and opts.loadClients are how a test runs the same path without the network or the SDKs. A failure is logged once and thrown.

      Parameters

      • Optionalopts: {
            clients?: CloudClients;
            deregisterOnly?: boolean;
            loadClients?: () => CloudClients;
            metadataUri?: string;
            self?: { cluster?: string; ip?: string };
            tasks?: TaskAddress[];
        }

      Returns Promise<ReconcileSummary>

    • Clears the outage after a reconcile that succeeded.

      Returns void

    • This task's cluster and address from a metadata document.

      Parameters

      • body: any

      Returns { cluster: string; ip: string }

    • Why the job is off, or '' when it should run. The metadata address is set by ECS on a Fargate task and inherited by every process of it.

      Returns string