Bucket
Declare a Bucket and its prefixes, bind a prefix to a Function, and read and write its objects over S3 or through ctx.blob.
This page lists the spec and status fields of Bucket, each with its type, its limits and its description. The Platform page explains the concept, and the metadata of every kind is the same.
Bucket
apiVersion: funcd.io/v1alpha1
kind: Bucket
metadata:
name: media
namespace: default
resourceGroup: rg1
spec:
quota:
maxSize: 1Gi
prefixes:
- name: uploads
owner:
kind: Function
name: ingest
- name: thumbnails
owner:
kind: Function
name: resize| apiVersion | kind |
|---|---|
funcd.io/v1alpha1 | Bucket |
Bucket.spec
| Field | Type and limits | Description |
|---|---|---|
prefixes | array of Bucket.spec.prefixes[], required | The Bucket's prefixes, each a key space with its own owner and cap. Prefix names are unique within the Bucket. A Function or a Lake that binds a prefix the Bucket does not list waits, with the reason BucketNotFound. |
quota | object, Bucket.spec.quota | Caps on the Bucket's total size and on each object. While the Bucket has a size cap, funcd refuses to sign a presigned PUT URL for it, with 403. |
Bucket.spec.prefixes[]
| Field | Type and limits | Description |
|---|---|---|
name | string, required, a DNS-1123 label | The prefix's name, unique within the Bucket. Over S3, it is the first segment of each object's key. |
owner | object, Bucket.spec.prefixes[].owner | The one Function, Lake or Job that may write the prefix, named with its kind, besides the writers that a RolesAssignment names. In a Bucket that a Function, a Lake or a Job declares by name, an omitted owner is that workload. In a Workflow's buckets, a Function owner names a step and a Lake owner a lake that the Workflow declares. The prefix that a Site serves its bundle from must have no owner, since the Site writes its builds there; the prefixes of a Site's ingress rules may have one. |
quota | object, Bucket.spec.prefixes[].quota | A cap on the prefix's total size: a write into the prefix must fit both this cap and the Bucket's, and while it is set funcd refuses to sign a presigned PUT URL into the prefix, with 403. It also caps a Lake's files under the prefix, though not the Lake's catalog. |
Bucket.spec.prefixes[].owner
| Field | Type and limits | Description |
|---|---|---|
kind | string, required, one of Function, Lake, Job | The workload's kind. A Function, a Lake and a Job may share a name, so the kind says which one it is; each field names the kinds it accepts. |
name | string, required, a DNS-1123 label | The workload's name, in the object's namespace. |
Bucket.spec.prefixes[].quota
| Field | Type and limits | Description |
|---|---|---|
maxBytes | integer, at least 0 | The same cap as a number of bytes. Set maxSize or maxBytes, not both. |
maxSize | string, a size: 1 to 15 digits and an optional binary unit, Ki, Mi, Gi or Ti, with or without a B (512Ki, 2GiB) | The cap on the total size held, above zero. Set maxSize or maxBytes, not both; neither means no cap. A write that would pass the cap gets 507 in a KV store or a Bucket; a SQL execute call gets 507 once the database holds the cap. |
Bucket.spec.quota
| Field | Type and limits | Description |
|---|---|---|
maxBytes | integer, at least 0 | The same cap as a number of bytes. Set maxSize or maxBytes, not both. |
maxObjectBytes | integer, at least 0 | The largest object a write may store, in bytes. A larger write gets 413, or EntityTooLarge over S3, and while it is set funcd refuses to sign a presigned PUT URL for the Bucket, with 403. 0 sets no cap of the Bucket's own, so only funcd's upload limits apply, such as s3gateway.maxUploadBytes. |
maxSize | string, a size: 1 to 15 digits and an optional binary unit, Ki, Mi, Gi or Ti, with or without a B (512Ki, 2GiB) | The cap on the total size held, above zero. Set maxSize or maxBytes, not both; neither means no cap. A write that would pass the cap gets 507 in a KV store or a Bucket; a SQL execute call gets 507 once the database holds the cap. |
Bucket.status
| Field | Type and limits | Description |
|---|---|---|
conditions | array of Condition | The conditions that explain the phase. |
observedGeneration | integer | The generation of the spec that funcd last acted on. |
phase | string, one of Pending, Deploying, Ready, Idle, Degraded, Failed, Terminating | Where the object is in its lifecycle. |
Handler API
The methods a handler calls on its context's clients, in each language funcd ships a shim for.
ctx.blob
The Bucket prefixes that the function binds, by alias: read, write, delete and list their objects, whose keys are relative to the binding's prefix.
| Method | What it does |
|---|---|
get(binding: string, key: string): Promise<Uint8Array | null> | The object's content as bytes, or null when the object does not exist. |
put(binding: string, key: string, value: Uint8Array): Promise<void> | Writes the object, replacing any object with that key. The value is at most 64 MiB, and at most the Bucket's spec.quota.maxObjectBytes when that is set: a larger one fails with the HTTP status 413. Only the prefix's owner and the writers that a RolesAssignment names can write. |
del(binding: string, key: string): Promise<void> | Deletes the object, and fails with the HTTP status 404 when it does not exist. Only the prefix's owner and the writers that a RolesAssignment names can delete. |
list(binding: string, prefix?: string): Promise<string[]> | The keys that start with prefix; without a prefix, every key under the binding's prefix. |
signedUrl(binding: string, key: string, opts?: SignOptions): Promise<string> | A presigned URL that lets its holder send an opts.method request, GET by default, for the object until opts.expiry passes: a duration such as "10m" or "1h30m", in whole seconds from 1s to 168h, or 15 minutes when unset. Any other expiry, "" included, fails with the HTTP status 400. A PUT or DELETE URL needs permission to write the prefix, and a PUT URL fails with the HTTP status 403 when the Bucket sets maxObjectBytes or a size quota applies to the Bucket or the prefix, since funcd could not enforce it on the upload. No blob store that funcd opens signs URLs, so a call that passes these checks fails with the HTTP status 503. |
Each method here that calls funcd can also fail with the status 500 and the problem type urn:funcd:problem:internal, when funcd meets an error that it did not expect; funcd logs its cause.
When funcd refuses a call, the method fails with an error that holds funcd's status and problem type. This table gives them for each method, with when each happens and what to do.
| Method | Status | Problem type | When | What to do |
|---|---|---|---|---|
get | 400 | urn:funcd:problem:invalid | funcd's file store refuses the key: it ends in .attrs or .funcd-tmp or holds __0x, which the store reserves, or it has a . segment or a last segment of .., which the store would keep under another key's path. | Use another key. |
get | 400 | urn:funcd:problem:invalid | funcd's file store cannot hold the key: the key or one of its segments is longer than the file system takes, or the key needs the path of another object, as a/b does while a is an object. | Use another key, or delete the object whose path the key needs. |
get | 403 | urn:funcd:problem:forbidden | The calling Function no longer exists, so it binds no prefix. | Call from a Function that exists; a deleted Function's worker stops. |
get | 403 | urn:funcd:problem:forbidden | The Function's spec.bindings.blob has no entry for the alias. | Add the binding to spec.bindings.blob, or call an alias that the Function binds. |
get | 403 | urn:funcd:problem:forbidden | A Policy forbids the Function to read the prefix. | Change or remove the Policy that forbids s3::read on the prefix. |
put | 400 | urn:funcd:problem:invalid | funcd's file store refuses the key: it ends in .attrs or .funcd-tmp or holds __0x, which the store reserves, or it has a . segment or a last segment of .., which the store would keep under another key's path. | Use another key. |
put | 400 | urn:funcd:problem:invalid | funcd's file store cannot hold the key: the key or one of its segments is longer than the file system takes, or the key needs the path of another object, as a/b does while a is an object. | Use another key, or delete the object whose path the key needs. |
put | 403 | urn:funcd:problem:forbidden | The calling Function no longer exists, so it binds no prefix. | Call from a Function that exists; a deleted Function's worker stops. |
put | 403 | urn:funcd:problem:forbidden | The Function's spec.bindings.blob has no entry for the alias. | Add the binding to spec.bindings.blob, or call an alias that the Function binds. |
put | 403 | urn:funcd:problem:forbidden | The Function does not own the prefix, no RolesAssignment makes it a writer, a Policy forbids the write, or the Bucket does not exist. | Create the Bucket if it is missing; then write from the prefix's owner, or grant the Function s3::write with a RolesAssignment, such as the Blob Data Writer role. |
put | 413 | urn:funcd:problem:payload-too-large | The request's body is larger than the local API takes for the call. | Send a smaller body. |
put | 413 | urn:funcd:problem:payload-too-large | The object is larger than the Bucket's spec.quota.maxObjectBytes. | Write a smaller object, or raise the Bucket's spec.quota.maxObjectBytes. |
put | 503 | urn:funcd:problem:unavailable | funcd could not read the store's quota or measure what the store holds. | Retry the write. |
put | 507 | urn:funcd:problem:insufficient-storage | funcd's data filesystem is below storage.minFreeSize, or the write would take it there. | Free space on the data filesystem, then retry; reads and deletes still work. |
put | 507 | urn:funcd:problem:insufficient-storage | The write would take what a store or a prefix of a Bucket holds past its quota; the detail names which one. | Delete data to make room, or raise that quota: the store's spec.quota, or the quota of the prefix in its Bucket's spec.prefixes. |
del | 400 | urn:funcd:problem:invalid | funcd's file store refuses the key: it ends in .attrs or .funcd-tmp or holds __0x, which the store reserves, or it has a . segment or a last segment of .., which the store would keep under another key's path. | Use another key. |
del | 400 | urn:funcd:problem:invalid | funcd's file store cannot hold the key: the key or one of its segments is longer than the file system takes, or the key needs the path of another object, as a/b does while a is an object. | Use another key, or delete the object whose path the key needs. |
del | 403 | urn:funcd:problem:forbidden | The calling Function no longer exists, so it binds no prefix. | Call from a Function that exists; a deleted Function's worker stops. |
del | 403 | urn:funcd:problem:forbidden | The Function's spec.bindings.blob has no entry for the alias. | Add the binding to spec.bindings.blob, or call an alias that the Function binds. |
del | 403 | urn:funcd:problem:forbidden | The Function does not own the prefix, no RolesAssignment makes it a writer, a Policy forbids the write, or the Bucket does not exist. | Create the Bucket if it is missing; then write from the prefix's owner, or grant the Function s3::write with a RolesAssignment, such as the Blob Data Writer role. |
del | 404 | urn:funcd:problem:not-found | The object does not exist. | Write the object first, or handle its absence. |
list | 403 | urn:funcd:problem:forbidden | The calling Function no longer exists, so it binds no prefix. | Call from a Function that exists; a deleted Function's worker stops. |
list | 403 | urn:funcd:problem:forbidden | The Function's spec.bindings.blob has no entry for the alias. | Add the binding to spec.bindings.blob, or call an alias that the Function binds. |
list | 403 | urn:funcd:problem:forbidden | A Policy forbids the Function to read the prefix. | Change or remove the Policy that forbids s3::read on the prefix. |
list | 404 | urn:funcd:problem:not-found | The binding names a Bucket that does not exist. | Create the Bucket, or bind one that exists. |
signedUrl | 400 | urn:funcd:problem:invalid | The method of the presigned URL is not GET, PUT or DELETE. | Sign GET, PUT or DELETE. |
signedUrl | 400 | urn:funcd:problem:invalid | The expiry of the presigned URL is not a duration such as 10m or 1h30m in whole seconds from 1s to 168h. | Send an expiry in that range, or none for 15 minutes. |
signedUrl | 403 | urn:funcd:problem:forbidden | The calling Function no longer exists, so it binds no prefix. | Call from a Function that exists; a deleted Function's worker stops. |
signedUrl | 403 | urn:funcd:problem:forbidden | The Function's spec.bindings.blob has no entry for the alias. | Add the binding to spec.bindings.blob, or call an alias that the Function binds. |
signedUrl | 403 | urn:funcd:problem:forbidden | A Policy forbids the Function to read the prefix. | Change or remove the Policy that forbids s3::read on the prefix. |
signedUrl | 403 | urn:funcd:problem:forbidden | The Function does not own the prefix, no RolesAssignment makes it a writer, a Policy forbids the write, or the Bucket does not exist. | Create the Bucket if it is missing; then write from the prefix's owner, or grant the Function s3::write with a RolesAssignment, such as the Blob Data Writer role. |
signedUrl | 403 | urn:funcd:problem:forbidden | The Bucket sets maxObjectBytes or a size quota, or the prefix sets a size quota, which funcd could not enforce on the upload of a presigned PUT. | Write the object with put, or sign a GET or a DELETE. |
signedUrl | 404 | urn:funcd:problem:not-found | The binding names a Bucket that does not exist. | Create the Bucket, or bind one that exists. |
signedUrl | 503 | urn:funcd:problem:unavailable | The blob store that funcd runs with signs no URL, as no store that funcd opens does. | Read and write the object with get and put, or serve it from a Function. |
HTTP API
The table lists each described operation of these kinds, with its method and path. The operation's page in the API reference gives its parameters, its body, its authentication and every answer, with when it happens and what to do.
| Method | Path | Operation |
|---|---|---|
GET | /apis/funcd.io/v1alpha1/namespaces/{namespace}/buckets | List the Buckets of a namespace |
POST | /apis/funcd.io/v1alpha1/namespaces/{namespace}/buckets | Create a Bucket |
GET | /apis/funcd.io/v1alpha1/namespaces/{namespace}/buckets/{name} | Read a Bucket |
PUT | /apis/funcd.io/v1alpha1/namespaces/{namespace}/buckets/{name} | Replace a Bucket |
DELETE | /apis/funcd.io/v1alpha1/namespaces/{namespace}/buckets/{name} | Delete a Bucket |