Skip to content

Conversation

@Piskoo
Copy link
Collaborator

@Piskoo Piskoo commented Dec 21, 2025

Adds support for configuring a fallback CAS backend that is automatically used when the default backend becomes unavailable.

Changes

  • Added fallback boolean field to CAS backends
  • A backend cannot be both default and fallback
  • Creating a new fallback backend automatically unsets the previous one
  • Fallback backends are included in periodic validation (every 30 minutes)
  • During attestation process cas backend is decided as follows:
    • Try default backend
    • If default invalid, try fallback backend
    • If fallback invalid or missing, return error
  • Added --fallback flag to all casbackend add commands.

Example

$ chainloop casbackend add oci --repo index.docker.io/repo --username name --password password  --name fallbacktest --fallback

┌───────────────┬────────────────────────┬──────────┬─────────────┬───────────────┬─────────┬──────────┬────────┐
│ NAME          │ LOCATION               │ PROVIDER │ DESCRIPTION │ LIMITS        │ DEFAULT │ FALLBACK │ STATUS │
├───────────────┼────────────────────────┼──────────┼─────────────┼───────────────┼─────────┼──────────┼────────┤
│ fallbacktest  │ index.docker.io/repo   │ OCI      │             │ MaxSize: 300M │ false   │ true     │ valid  │
└───────────────┴────────────────────────┴──────────┴─────────────┴───────────────┴─────────┴──────────┴────────┘

During attestation init cas backend is decided seamlessly, we will provide information on what cas backend was used in the attestation itself.

Signed-off-by: Sylwester Piskozub <[email protected]>
Signed-off-by: Sylwester Piskozub <[email protected]>
Signed-off-by: Sylwester Piskozub <[email protected]>
Signed-off-by: Sylwester Piskozub <[email protected]>
Signed-off-by: Sylwester Piskozub <[email protected]>
Signed-off-by: Sylwester Piskozub <[email protected]>
Signed-off-by: Sylwester Piskozub <[email protected]>
Signed-off-by: Sylwester Piskozub <[email protected]>
@Piskoo Piskoo requested review from jiparis and migmartri December 22, 2025 13:09
@Piskoo Piskoo marked this pull request as ready for review December 22, 2025 13:09
// Attempts to use the default backend first, if invalid it uses the fallback backend.
func (uc *CASBackendUseCase) FindDefaultOrFallbackBackend(ctx context.Context, orgID string) (*CASBackend, error) {
// Find the default backend
defaultBackend, err := uc.FindDefaultBackend(ctx, orgID)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can defaultBackend be nil?

backend, err := s.casUC.FindDefaultOrFallbackBackend(context.Background(), robotAccount.OrgID)
if err != nil {
if biz.IsNotFound(err) {
return nil, errors.NotFound("not found", "default CAS backend not found")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we might be able to use something called handle_errors?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this error message is not accurate, let's try to use handle_errors

if err != nil {
if biz.IsNotFound(err) {
return nil, errors.NotFound("not found", "default CAS backend not found")
} else if biz.IsErrValidation(err) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should return ErrorCasBackendErrorReasonInvalid no?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants