The canary window now counts from when a release is installed on the host (installed.json / installed_at in the update snapshot), not from the statement's issued_at, and 'release canary check' judges the release the canary actually runs via its exact-pin tag instead of the moving next tag. A newer release on next queues behind the one being judged instead of restarting the clock, so stable moves once per release. New subcommands: canary status (read-only state, signals, verdict), canary promote (promote now when hard checks pass), canary unpin (back to next), and start -force. A held/pinned canary is verified installable every check and a stranded pin fails the run red instead of looking green. Rollback pre-flight checks stable's zip and agent image digests before pinning. Relative signals are judged whenever both windows carry minimum data, so a breach rolls back mid-window; promote still needs the full window unless the operator promotes early (new promote.yml workflow_dispatch). The window is configurable via -window / CANARY_WINDOW. Also: dashboard canary status card (ui), and task canary:rehearse, a local end-to-end rehearsal of publish -> canary start -> status -> check -> promote against a throwaway registry and host. task check passes; rehearsal run green (REHEARSE_EXIT=0).
48 lines
1.7 KiB
Go
48 lines
1.7 KiB
Go
package releaseupdate
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
digest "github.com/opencontainers/go-digest"
|
|
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
|
"oras.land/oras-go/v2/registry"
|
|
|
|
"github.com/samcharles93/archie-core/internal/domain/distribution"
|
|
)
|
|
|
|
// Installable reports whether a release can still be installed from source:
|
|
// the zip blob its statement names must be present in the release repository
|
|
// and the agent image it pins must still resolve. A canary must never be
|
|
// pinned to a release whose artifacts are gone, or it would be stranded on a
|
|
// version it can never install again.
|
|
func Installable(ctx context.Context, source distribution.Source, release Release) error {
|
|
zipDigest, err := digest.Parse(release.Statement.Zip.Digest)
|
|
if err != nil {
|
|
return fmt.Errorf("zip digest %q: %w", release.Statement.Zip.Digest, err)
|
|
}
|
|
repo, err := pushRepository(source.Reference)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
exists, err := repo.Exists(ctx, ocispec.Descriptor{Digest: zipDigest})
|
|
if err != nil {
|
|
return fmt.Errorf("resolve zip blob %s in %s: %w", release.Statement.Zip.Digest, source.Reference, err)
|
|
}
|
|
if !exists {
|
|
return fmt.Errorf("zip blob %s (%s) is absent from %s", release.Statement.Zip.Digest, release.Statement.Zip.Name, source.Reference)
|
|
}
|
|
image, err := registry.ParseReference(release.Statement.AgentImage)
|
|
if err != nil {
|
|
return fmt.Errorf("agent image %q: %w", release.Statement.AgentImage, err)
|
|
}
|
|
imageRepo, err := pushRepository(image.Registry + "/" + image.Repository)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if _, err := imageRepo.Resolve(ctx, image.Reference); err != nil {
|
|
return fmt.Errorf("agent image %s: %w", release.Statement.AgentImage, err)
|
|
}
|
|
return nil
|
|
}
|