Skip to content

Block registry

The block registry records every block currently running on any cluster in the network: which component it runs, where, with which settings and policies.

At a glance

Runs on: the management cluster, as blocks-db-svc (NodePort 30100).
Written by: the system, when blocks are created through the Parser (Block spec). You mostly read and search it.

Schema

const BlockSchema = new mongoose.Schema({
    // Unique block ID
    id: { type: String, required: true, unique: true },

    // URI of the component the block runs (from the component registry)
    componentUri: { type: String },

    // The full component record, copied from the component registry
    component: { type: mongoose.Schema.Types.Mixed },

    // componentUri + block ID
    blockUri: { type: String },

    // Metadata about the block (copied from the component)
    blockMetadata: { type: mongoose.Schema.Types.Mixed },

    // The block's policies
    policies: { type: mongoose.Schema.Types.Mixed },

    // The full cluster record, copied from the cluster registry
    cluster: { type: mongoose.Schema.Types.Mixed },

    // Start-up data
    blockInitData: { type: mongoose.Schema.Types.Mixed },

    // Start-up settings (environment variables, arguments, flags, ...)
    initSettings: { type: mongoose.Schema.Types.Mixed },

    // Runtime parameters
    parameters: { type: mongoose.Schema.Types.Mixed },

    // Minimum number of instances
    minInstances: { type: Number, required: false },

    // Maximum number of instances
    maxInstances: { type: Number, required: false },

    // Input format (copied from the component)
    inputProtocol: { type: mongoose.Schema.Types.Mixed },

    // Output format (copied from the component)
    outputProtocol: { type: mongoose.Schema.Types.Mixed }
});

Because each record contains the full component and cluster records, you can search blocks by component or cluster properties, for example cluster.reputation or component.metadata.algorithmType.

Example record
{
  "id": "block-object-detector-001",
  "componentUri": "",
  "component": {},
  "blockUri": "",
  "blockMetadata": {},
  "policies": {
        "resourceAllocator": {
            "policyRuleURI": "policies.resource_allocator.standard:latest",
            "parameters": {},
            "settings": {}
        },
        "loadBalancer": {
            "policyRuleURI": "policies.load_balancer.gateway.load_balancer_sep2:v0.0.1-beta",
            "parameters": {},
            "settings": {}
        },
        "loadBalancerMapper": {
            "policyRuleURI": "policies.load_balancer.mapper.loadbalancer_mapper_oct1:v1.2.0",
            "parameters": {},
            "settings": {}
        },
        "assignment": {
            "policyRuleURI": "policies.assignment.default_strategy:v1.0.3",
            "parameters": {},
            "settings": {}
        },
        "stabilityChecker": {
            "policyRuleURI": "policies.health.stability_checker:v0.1.0",
            "parameters": {},
            "settings": {}
        },
        "autoscaler": {
            "policyRuleURI": "policies.autoscaler.basic_auto_scaler:v0.3.5",
            "parameters": {},
            "settings": {}
        },
        "accessRulesPolicy": {
            "policyRuleURI": "policies.access.control.access_rules_policy:v2.0.0",
            "parameters": {},
            "settings": {}
        }
    },
  "cluster": {},
  "blockInitData": {},
  "initSettings": {},
  "parameters": {},
  "minInstances": 1,
  "maxInstances": 5,
  "inputProtocol": {},
  "outputProtocol": {}
}

APIs

Endpoint Method What it does
/blocks GET List all blocks.
/blocks/:id GET Get one block.
/blocks/:id PUT Update a block (MongoDB-style update).
/blocks/:id DELETE Delete a block's record.
/blocks/query POST Search with a MongoDB-style query, plus optional options (sort, limit, ...).
# List
curl -X GET http://<server-url>/blocks

# Get
curl -X GET http://<server-url>/blocks/block-object-detector-001

# Update
curl -X PUT http://<server-url>/blocks/block-object-detector-001 \
  -H "Content-Type: application/json" \
  -d '{
    "$set": {
      "blockMetadata.description": "Updated description for object detection block",
      "minInstances": 2
    }
  }'

# Delete
curl -X DELETE http://<server-url>/blocks/block-object-detector-001

# Search: blocks on clusters with reputation above 90 that have an auto-scaler policy
curl -X POST http://<server-url>/blocks/query \
  -H "Content-Type: application/json" \
  -d '{
    "query": {
      "cluster.reputation": { "$gt": 90 },
      "policies.autoscaler.policyRuleURI": { "$ne": "" }
    },
    "options": {
      "sort": { "id": 1 },
      "limit": 10
    }
  }'

Warning

These APIs work on the registry record. To remove a running block, go through the Cluster Controller Gateway, so that its infrastructure is cleaned up and the remove_block governance checks apply.