Skip to Content
Services

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
apiVersionkind
funcd.io/v1alpha1Bucket

Bucket.spec

FieldType and limitsDescription
prefixesarray of Bucket.spec.prefixes[], requiredThe 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.
quotaobject, Bucket.spec.quotaCaps 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[]

FieldType and limitsDescription
namestring, required, a DNS-1123 labelThe prefix's name, unique within the Bucket. Over S3, it is the first segment of each object's key.
ownerobject, Bucket.spec.prefixes[].ownerThe 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.
quotaobject, Bucket.spec.prefixes[].quotaA 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

FieldType and limitsDescription
kindstring, required, one of Function, Lake, JobThe 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.
namestring, required, a DNS-1123 labelThe workload's name, in the object's namespace.

Bucket.spec.prefixes[].quota

FieldType and limitsDescription
maxBytesinteger, at least 0The same cap as a number of bytes. Set maxSize or maxBytes, not both.
maxSizestring, 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

FieldType and limitsDescription
maxBytesinteger, at least 0The same cap as a number of bytes. Set maxSize or maxBytes, not both.
maxObjectBytesinteger, at least 0The 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.
maxSizestring, 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

FieldType and limitsDescription
conditionsarray of ConditionThe conditions that explain the phase.
observedGenerationintegerThe generation of the spec that funcd last acted on.
phasestring, one of Pending, Deploying, Ready, Idle, Degraded, Failed, TerminatingWhere 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.

MethodWhat 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.

MethodStatusProblem typeWhenWhat to do
get400urn:funcd:problem:invalidfuncd'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.
get400urn:funcd:problem:invalidfuncd'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.
get403urn:funcd:problem:forbiddenThe calling Function no longer exists, so it binds no prefix.Call from a Function that exists; a deleted Function's worker stops.
get403urn:funcd:problem:forbiddenThe 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.
get403urn:funcd:problem:forbiddenA Policy forbids the Function to read the prefix.Change or remove the Policy that forbids s3::read on the prefix.
put400urn:funcd:problem:invalidfuncd'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.
put400urn:funcd:problem:invalidfuncd'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.
put403urn:funcd:problem:forbiddenThe calling Function no longer exists, so it binds no prefix.Call from a Function that exists; a deleted Function's worker stops.
put403urn:funcd:problem:forbiddenThe 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.
put403urn:funcd:problem:forbiddenThe 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.
put413urn:funcd:problem:payload-too-largeThe request's body is larger than the local API takes for the call.Send a smaller body.
put413urn:funcd:problem:payload-too-largeThe object is larger than the Bucket's spec.quota.maxObjectBytes.Write a smaller object, or raise the Bucket's spec.quota.maxObjectBytes.
put503urn:funcd:problem:unavailablefuncd could not read the store's quota or measure what the store holds.Retry the write.
put507urn:funcd:problem:insufficient-storagefuncd'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.
put507urn:funcd:problem:insufficient-storageThe 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.
del400urn:funcd:problem:invalidfuncd'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.
del400urn:funcd:problem:invalidfuncd'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.
del403urn:funcd:problem:forbiddenThe calling Function no longer exists, so it binds no prefix.Call from a Function that exists; a deleted Function's worker stops.
del403urn:funcd:problem:forbiddenThe 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.
del403urn:funcd:problem:forbiddenThe 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.
del404urn:funcd:problem:not-foundThe object does not exist.Write the object first, or handle its absence.
list403urn:funcd:problem:forbiddenThe calling Function no longer exists, so it binds no prefix.Call from a Function that exists; a deleted Function's worker stops.
list403urn:funcd:problem:forbiddenThe 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.
list403urn:funcd:problem:forbiddenA Policy forbids the Function to read the prefix.Change or remove the Policy that forbids s3::read on the prefix.
list404urn:funcd:problem:not-foundThe binding names a Bucket that does not exist.Create the Bucket, or bind one that exists.
signedUrl400urn:funcd:problem:invalidThe method of the presigned URL is not GET, PUT or DELETE.Sign GET, PUT or DELETE.
signedUrl400urn:funcd:problem:invalidThe 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.
signedUrl403urn:funcd:problem:forbiddenThe calling Function no longer exists, so it binds no prefix.Call from a Function that exists; a deleted Function's worker stops.
signedUrl403urn:funcd:problem:forbiddenThe 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.
signedUrl403urn:funcd:problem:forbiddenA Policy forbids the Function to read the prefix.Change or remove the Policy that forbids s3::read on the prefix.
signedUrl403urn:funcd:problem:forbiddenThe 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.
signedUrl403urn:funcd:problem:forbiddenThe 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.
signedUrl404urn:funcd:problem:not-foundThe binding names a Bucket that does not exist.Create the Bucket, or bind one that exists.
signedUrl503urn:funcd:problem:unavailableThe 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.

MethodPathOperation
GET/apis/funcd.io/v1alpha1/namespaces/{namespace}/bucketsList the Buckets of a namespace
POST/apis/funcd.io/v1alpha1/namespaces/{namespace}/bucketsCreate 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

On this page