diff --git a/app/controlplane/cmd/main.go b/app/controlplane/cmd/main.go index c8091d8df..631c7c488 100644 --- a/app/controlplane/cmd/main.go +++ b/app/controlplane/cmd/main.go @@ -221,9 +221,6 @@ func workflowRunExpirerOpts(c *conf.Bootstrap) *biz.WorkflowRunExpirerOpts { if configured := c.GetAttestations().GetWorkflowRunExpirationCheckInterval(); configured != nil { opts.CheckInterval = configured.AsDuration() } - if configured := c.GetAttestations().GetWorkflowRunEventsRetention(); configured != nil { - opts.EventsRetention = configured.AsDuration() - } return opts } diff --git a/app/controlplane/cmd/main_test.go b/app/controlplane/cmd/main_test.go index 50ddb8391..bb106f661 100644 --- a/app/controlplane/cmd/main_test.go +++ b/app/controlplane/cmd/main_test.go @@ -36,7 +36,6 @@ func TestWorkflowRunExpirerOptsMapping(t *testing.T) { config *conf.Bootstrap want time.Duration wantCheckInterval time.Duration - wantRetention time.Duration }{ { name: "missing attestations configuration", @@ -56,12 +55,10 @@ func TestWorkflowRunExpirerOptsMapping(t *testing.T) { Attestations: &conf.Attestations{ WorkflowRunExpirationWindow: durationpb.New(2 * time.Hour), WorkflowRunExpirationCheckInterval: durationpb.New(30 * time.Second), - WorkflowRunEventsRetention: durationpb.New(24 * time.Hour), }, }, wantCheckInterval: 30 * time.Second, want: 2 * time.Hour, - wantRetention: 24 * time.Hour, }, } @@ -70,7 +67,6 @@ func TestWorkflowRunExpirerOptsMapping(t *testing.T) { opts := workflowRunExpirerOpts(tt.config) assert.Equal(t, tt.want, opts.ExpirationWindow) assert.Equal(t, tt.wantCheckInterval, opts.CheckInterval) - assert.Equal(t, tt.wantRetention, opts.EventsRetention) }) } } @@ -181,7 +177,6 @@ func TestHelmChartWorkflowRunExpirationDefaults(t *testing.T) { Attestations struct { WorkflowRunExpirationWindow string `json:"workflowRunExpirationWindow"` WorkflowRunExpirationCheckInterval string `json:"workflowRunExpirationCheckInterval"` - WorkflowRunEventsRetention string `json:"workflowRunEventsRetention"` } `json:"attestations"` } `json:"controlplane"` } @@ -192,8 +187,8 @@ func TestHelmChartWorkflowRunExpirationDefaults(t *testing.T) { attestations := values.Controlplane.Attestations // Same shape as templates/controlplane/configmap.yaml - rendered := fmt.Sprintf("attestations:\n workflow_run_expiration_window: %q\n workflow_run_expiration_check_interval: %q\n workflow_run_events_retention: %q\n", - attestations.WorkflowRunExpirationWindow, attestations.WorkflowRunExpirationCheckInterval, attestations.WorkflowRunEventsRetention) + rendered := fmt.Sprintf("attestations:\n workflow_run_expiration_window: %q\n workflow_run_expiration_check_interval: %q\n", + attestations.WorkflowRunExpirationWindow, attestations.WorkflowRunExpirationCheckInterval) configPath := filepath.Join(t.TempDir(), "config.yaml") require.NoError(t, os.WriteFile(configPath, []byte(rendered), 0o600)) @@ -202,7 +197,18 @@ func TestHelmChartWorkflowRunExpirationDefaults(t *testing.T) { require.NoError(t, err) assert.Equal(t, time.Hour, bootstrap.GetAttestations().GetWorkflowRunExpirationWindow().AsDuration()) assert.Equal(t, time.Minute, bootstrap.GetAttestations().GetWorkflowRunExpirationCheckInterval().AsDuration()) - assert.Equal(t, 90*24*time.Hour, bootstrap.GetAttestations().GetWorkflowRunEventsRetention().AsDuration()) +} + +// A configuration that still sets the removed run events retention loads, so that an +// upgrade does not break the control plane. The events are now kept for the life of the run. +func TestRemovedWorkflowRunEventsRetentionIsIgnored(t *testing.T) { + configPath := filepath.Join(t.TempDir(), "config.yaml") + rendered := "attestations:\n workflow_run_expiration_window: \"3600s\"\n workflow_run_events_retention: \"7776000s\"\n" + require.NoError(t, os.WriteFile(configPath, []byte(rendered), 0o600)) + + bootstrap, err := loadBootstrap(t, configPath) + require.NoError(t, err) + assert.Equal(t, time.Hour, bootstrap.GetAttestations().GetWorkflowRunExpirationWindow().AsDuration()) } // loadBootstrap loads a configuration file the same way as main. diff --git a/app/controlplane/cmd/wire_gen.go b/app/controlplane/cmd/wire_gen.go index d7d6c05c3..0e63be87a 100644 --- a/app/controlplane/cmd/wire_gen.go +++ b/app/controlplane/cmd/wire_gen.go @@ -405,7 +405,7 @@ func wireApp(contextContext context.Context, bootstrap *conf.Bootstrap, readerWr cleanup() return nil, nil, err } - workflowRunExpirerUseCase := biz.NewWorkflowRunExpirerUseCase(workflowRunRepo, prometheusUseCase, workflowRunEventUseCase, logger) + workflowRunExpirerUseCase := biz.NewWorkflowRunExpirerUseCase(workflowRunRepo, prometheusUseCase, logger) distributedLock := data.NewPostgresLock(dataData, logger) casBackendChecker := biz.NewCASBackendChecker(logger, casBackendRepo, casBackendUseCase, distributedLock) apiTokenStaleRevoker := biz.NewAPITokenStaleRevoker(organizationRepo, apiTokenRepo, apiTokenUseCase, logger) diff --git a/app/controlplane/internal/conf/controlplane/config/v1/conf.pb.go b/app/controlplane/internal/conf/controlplane/config/v1/conf.pb.go index 615a0d25b..2b690d52e 100644 --- a/app/controlplane/internal/conf/controlplane/config/v1/conf.pb.go +++ b/app/controlplane/internal/conf/controlplane/config/v1/conf.pb.go @@ -362,13 +362,8 @@ type Attestations struct { // also accept attestations signed with other methods, for example cosign keys // or KMS. When unset, it defaults to true. ForceVerification *bool `protobuf:"varint,5,opt,name=force_verification,json=forceVerification,proto3,oneof" json:"force_verification,omitempty"` - // Age after which the progress events of the workflow runs are deleted. The - // runs and their attestations stay. When unset, the control plane defaults - // to 90 days. - // In YAML configuration, use seconds with an "s" suffix, for example "7776000s". - WorkflowRunEventsRetention *durationpb.Duration `protobuf:"bytes,6,opt,name=workflow_run_events_retention,json=workflowRunEventsRetention,proto3" json:"workflow_run_events_retention,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Attestations) Reset() { @@ -436,13 +431,6 @@ func (x *Attestations) GetForceVerification() bool { return false } -func (x *Attestations) GetWorkflowRunEventsRetention() *durationpb.Duration { - if x != nil { - return x.WorkflowRunEventsRetention - } - return nil -} - type OperationAuthorizationProvider struct { state protoimpl.MessageState `protogen:"open.v1"` // URL of the authorization endpoint @@ -1957,15 +1945,14 @@ const file_controlplane_config_v1_conf_proto_rawDesc = "" + "\breplicas\x18\x03 \x01(\x05R\breplicasB\x10\n" + "\x0eauthenticationJ\x04\b\b\x10\tR\x15referrer_shared_index\"J\n" + "\x14PluginsNetworkPolicy\x122\n" + - "\x15block_private_targets\x18\x01 \x01(\bR\x13blockPrivateTargets\"\x9a\x04\n" + + "\x15block_private_targets\x18\x01 \x01(\bR\x13blockPrivateTargets\"\xd7\x03\n" + "\fAttestations\x12&\n" + "\x0fskip_db_storage\x18\x01 \x01(\bR\rskipDbStorage\x12L\n" + "#policy_evaluations_max_inline_bytes\x18\x02 \x01(\x03R\x1fpolicyEvaluationsMaxInlineBytes\x12h\n" + "\x1eworkflow_run_expiration_window\x18\x03 \x01(\v2\x19.google.protobuf.DurationB\b\xbaH\x05\xaa\x01\x02*\x00R\x1bworkflowRunExpirationWindow\x12w\n" + "&workflow_run_expiration_check_interval\x18\x04 \x01(\v2\x19.google.protobuf.DurationB\b\xbaH\x05\xaa\x01\x02*\x00R\"workflowRunExpirationCheckInterval\x122\n" + - "\x12force_verification\x18\x05 \x01(\bH\x00R\x11forceVerification\x88\x01\x01\x12f\n" + - "\x1dworkflow_run_events_retention\x18\x06 \x01(\v2\x19.google.protobuf.DurationB\b\xbaH\x05\xaa\x01\x02*\x00R\x1aworkflowRunEventsRetentionB\x15\n" + - "\x13_force_verification\"v\n" + + "\x12force_verification\x18\x05 \x01(\bH\x00R\x11forceVerification\x88\x01\x01B\x15\n" + + "\x13_force_verificationJ\x04\b\x06\x10\aR\x1dworkflow_run_events_retention\"v\n" + "\x1eOperationAuthorizationProvider\x12\x1a\n" + "\x03url\x18\x01 \x01(\tB\b\xbaH\x05r\x03\x88\x01\x01R\x03url\x12\x18\n" + "\aenabled\x18\x02 \x01(\bR\aenabled\x12\x1e\n" + @@ -2116,28 +2103,27 @@ var file_controlplane_config_v1_conf_proto_depIdxs = []int32{ 1, // 16: controlplane.config.v1.Bootstrap.plugins_network_policy:type_name -> controlplane.config.v1.PluginsNetworkPolicy 26, // 17: controlplane.config.v1.Attestations.workflow_run_expiration_window:type_name -> google.protobuf.Duration 26, // 18: controlplane.config.v1.Attestations.workflow_run_expiration_check_interval:type_name -> google.protobuf.Duration - 26, // 19: controlplane.config.v1.Attestations.workflow_run_events_retention:type_name -> google.protobuf.Duration - 17, // 20: controlplane.config.v1.Server.http:type_name -> controlplane.config.v1.Server.HTTP - 19, // 21: controlplane.config.v1.Server.grpc:type_name -> controlplane.config.v1.Server.GRPC - 17, // 22: controlplane.config.v1.Server.http_metrics:type_name -> controlplane.config.v1.Server.HTTP - 20, // 23: controlplane.config.v1.Data.database:type_name -> controlplane.config.v1.Data.Database - 27, // 24: controlplane.config.v1.Auth.allow_list:type_name -> controlplane.config.v1.AllowList - 21, // 25: controlplane.config.v1.Auth.oidc:type_name -> controlplane.config.v1.Auth.OIDC - 22, // 26: controlplane.config.v1.CA.file_ca:type_name -> controlplane.config.v1.CA.FileCA - 23, // 27: controlplane.config.v1.CA.ejbca_ca:type_name -> controlplane.config.v1.CA.EJBCA - 15, // 28: controlplane.config.v1.Bootstrap.Observability.sentry:type_name -> controlplane.config.v1.Bootstrap.Observability.Sentry - 16, // 29: controlplane.config.v1.Bootstrap.Observability.tracing:type_name -> controlplane.config.v1.Bootstrap.Observability.Tracing - 19, // 30: controlplane.config.v1.Bootstrap.CASServer.grpc:type_name -> controlplane.config.v1.Server.GRPC - 26, // 31: controlplane.config.v1.Server.HTTP.timeout:type_name -> google.protobuf.Duration - 18, // 32: controlplane.config.v1.Server.HTTP.tls_config:type_name -> controlplane.config.v1.Server.TLS - 26, // 33: controlplane.config.v1.Server.GRPC.timeout:type_name -> google.protobuf.Duration - 18, // 34: controlplane.config.v1.Server.GRPC.tls_config:type_name -> controlplane.config.v1.Server.TLS - 26, // 35: controlplane.config.v1.Data.Database.max_conn_idle_time:type_name -> google.protobuf.Duration - 36, // [36:36] is the sub-list for method output_type - 36, // [36:36] is the sub-list for method input_type - 36, // [36:36] is the sub-list for extension type_name - 36, // [36:36] is the sub-list for extension extendee - 0, // [0:36] is the sub-list for field type_name + 17, // 19: controlplane.config.v1.Server.http:type_name -> controlplane.config.v1.Server.HTTP + 19, // 20: controlplane.config.v1.Server.grpc:type_name -> controlplane.config.v1.Server.GRPC + 17, // 21: controlplane.config.v1.Server.http_metrics:type_name -> controlplane.config.v1.Server.HTTP + 20, // 22: controlplane.config.v1.Data.database:type_name -> controlplane.config.v1.Data.Database + 27, // 23: controlplane.config.v1.Auth.allow_list:type_name -> controlplane.config.v1.AllowList + 21, // 24: controlplane.config.v1.Auth.oidc:type_name -> controlplane.config.v1.Auth.OIDC + 22, // 25: controlplane.config.v1.CA.file_ca:type_name -> controlplane.config.v1.CA.FileCA + 23, // 26: controlplane.config.v1.CA.ejbca_ca:type_name -> controlplane.config.v1.CA.EJBCA + 15, // 27: controlplane.config.v1.Bootstrap.Observability.sentry:type_name -> controlplane.config.v1.Bootstrap.Observability.Sentry + 16, // 28: controlplane.config.v1.Bootstrap.Observability.tracing:type_name -> controlplane.config.v1.Bootstrap.Observability.Tracing + 19, // 29: controlplane.config.v1.Bootstrap.CASServer.grpc:type_name -> controlplane.config.v1.Server.GRPC + 26, // 30: controlplane.config.v1.Server.HTTP.timeout:type_name -> google.protobuf.Duration + 18, // 31: controlplane.config.v1.Server.HTTP.tls_config:type_name -> controlplane.config.v1.Server.TLS + 26, // 32: controlplane.config.v1.Server.GRPC.timeout:type_name -> google.protobuf.Duration + 18, // 33: controlplane.config.v1.Server.GRPC.tls_config:type_name -> controlplane.config.v1.Server.TLS + 26, // 34: controlplane.config.v1.Data.Database.max_conn_idle_time:type_name -> google.protobuf.Duration + 35, // [35:35] is the sub-list for method output_type + 35, // [35:35] is the sub-list for method input_type + 35, // [35:35] is the sub-list for extension type_name + 35, // [35:35] is the sub-list for extension extendee + 0, // [0:35] is the sub-list for field type_name } func init() { file_controlplane_config_v1_conf_proto_init() } diff --git a/app/controlplane/internal/conf/controlplane/config/v1/conf.proto b/app/controlplane/internal/conf/controlplane/config/v1/conf.proto index f804efed2..435f55dcf 100644 --- a/app/controlplane/internal/conf/controlplane/config/v1/conf.proto +++ b/app/controlplane/internal/conf/controlplane/config/v1/conf.proto @@ -185,11 +185,9 @@ message Attestations { // or KMS. When unset, it defaults to true. optional bool force_verification = 5; - // Age after which the progress events of the workflow runs are deleted. The - // runs and their attestations stay. When unset, the control plane defaults - // to 90 days. - // In YAML configuration, use seconds with an "s" suffix, for example "7776000s". - google.protobuf.Duration workflow_run_events_retention = 6 [(buf.validate.field).duration.gt = {}]; + // Workflow run events are kept for the life of the run + reserved 6; + reserved "workflow_run_events_retention"; } message OperationAuthorizationProvider { diff --git a/app/controlplane/pkg/biz/mocks/WorkflowRunEventRepo.go b/app/controlplane/pkg/biz/mocks/WorkflowRunEventRepo.go index 1fbb8af29..939c49be3 100644 --- a/app/controlplane/pkg/biz/mocks/WorkflowRunEventRepo.go +++ b/app/controlplane/pkg/biz/mocks/WorkflowRunEventRepo.go @@ -6,7 +6,6 @@ package mocks import ( "context" - "time" "github.com/chainloop-dev/chainloop/app/controlplane/pkg/biz" "github.com/google/uuid" @@ -123,78 +122,6 @@ func (_c *WorkflowRunEventRepo_Create_Call) RunAndReturn(run func(ctx context.Co return _c } -// DeleteOlderThan provides a mock function for the type WorkflowRunEventRepo -func (_mock *WorkflowRunEventRepo) DeleteOlderThan(ctx context.Context, t time.Time, limit int) (int, error) { - ret := _mock.Called(ctx, t, limit) - - if len(ret) == 0 { - panic("no return value specified for DeleteOlderThan") - } - - var r0 int - var r1 error - if returnFunc, ok := ret.Get(0).(func(context.Context, time.Time, int) (int, error)); ok { - return returnFunc(ctx, t, limit) - } - if returnFunc, ok := ret.Get(0).(func(context.Context, time.Time, int) int); ok { - r0 = returnFunc(ctx, t, limit) - } else { - r0 = ret.Get(0).(int) - } - if returnFunc, ok := ret.Get(1).(func(context.Context, time.Time, int) error); ok { - r1 = returnFunc(ctx, t, limit) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// WorkflowRunEventRepo_DeleteOlderThan_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteOlderThan' -type WorkflowRunEventRepo_DeleteOlderThan_Call struct { - *mock.Call -} - -// DeleteOlderThan is a helper method to define mock.On call -// - ctx context.Context -// - t time.Time -// - limit int -func (_e *WorkflowRunEventRepo_Expecter) DeleteOlderThan(ctx any, t any, limit any) *WorkflowRunEventRepo_DeleteOlderThan_Call { - return &WorkflowRunEventRepo_DeleteOlderThan_Call{Call: _e.mock.On("DeleteOlderThan", ctx, t, limit)} -} - -func (_c *WorkflowRunEventRepo_DeleteOlderThan_Call) Run(run func(ctx context.Context, t time.Time, limit int)) *WorkflowRunEventRepo_DeleteOlderThan_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 time.Time - if args[1] != nil { - arg1 = args[1].(time.Time) - } - var arg2 int - if args[2] != nil { - arg2 = args[2].(int) - } - run( - arg0, - arg1, - arg2, - ) - }) - return _c -} - -func (_c *WorkflowRunEventRepo_DeleteOlderThan_Call) Return(n int, err error) *WorkflowRunEventRepo_DeleteOlderThan_Call { - _c.Call.Return(n, err) - return _c -} - -func (_c *WorkflowRunEventRepo_DeleteOlderThan_Call) RunAndReturn(run func(ctx context.Context, t time.Time, limit int) (int, error)) *WorkflowRunEventRepo_DeleteOlderThan_Call { - _c.Call.Return(run) - return _c -} - // List provides a mock function for the type WorkflowRunEventRepo func (_mock *WorkflowRunEventRepo) List(ctx context.Context, runID uuid.UUID) ([]*biz.WorkflowRunEvent, error) { ret := _mock.Called(ctx, runID) diff --git a/app/controlplane/pkg/biz/workflowrun.go b/app/controlplane/pkg/biz/workflowrun.go index 53c163cbb..0c871a66a 100644 --- a/app/controlplane/pkg/biz/workflowrun.go +++ b/app/controlplane/pkg/biz/workflowrun.go @@ -178,16 +178,12 @@ type PromObservable interface { type WorkflowRunExpirerUseCase struct { wfRunRepo WorkflowRunRepo PromObservable PromObservable - runEvents *WorkflowRunEventUseCase logger *log.Helper } const ( defaultWorkflowRunExpirationWindow = time.Hour defaultWorkflowRunExpirationCheckInterval = time.Minute - defaultWorkflowRunEventsRetention = 90 * 24 * time.Hour - // number of old run events deleted in each batch of a sweep - workflowRunEventsDeleteBatchSize = 1000 ) type WorkflowRunExpirerOpts struct { @@ -195,20 +191,17 @@ type WorkflowRunExpirerOpts struct { ExpirationWindow time.Duration // Interval between expiration sweeps. Defaults to 1 minute. CheckInterval time.Duration - // Age after which the progress events of the runs are deleted. Defaults to 90 days. - EventsRetention time.Duration } -func NewWorkflowRunExpirerUseCase(wfrRepo WorkflowRunRepo, po PromObservable, runEvents *WorkflowRunEventUseCase, logger log.Logger) *WorkflowRunExpirerUseCase { +func NewWorkflowRunExpirerUseCase(wfrRepo WorkflowRunRepo, po PromObservable, logger log.Logger) *WorkflowRunExpirerUseCase { logger = log.With(logger, "component", "biz.WorkflowRunExpirer") - return &WorkflowRunExpirerUseCase{wfRunRepo: wfrRepo, PromObservable: po, runEvents: runEvents, logger: log.NewHelper(logger)} + return &WorkflowRunExpirerUseCase{wfRunRepo: wfrRepo, PromObservable: po, logger: log.NewHelper(logger)} } func resolveWorkflowRunExpirerOpts(opts *WorkflowRunExpirerOpts) WorkflowRunExpirerOpts { resolved := WorkflowRunExpirerOpts{ ExpirationWindow: defaultWorkflowRunExpirationWindow, CheckInterval: defaultWorkflowRunExpirationCheckInterval, - EventsRetention: defaultWorkflowRunEventsRetention, } if opts == nil { return resolved @@ -219,9 +212,6 @@ func resolveWorkflowRunExpirerOpts(opts *WorkflowRunExpirerOpts) WorkflowRunExpi if opts.CheckInterval > 0 { resolved.CheckInterval = opts.CheckInterval } - if opts.EventsRetention > 0 { - resolved.EventsRetention = opts.EventsRetention - } return resolved } @@ -242,38 +232,13 @@ func (uc *WorkflowRunExpirerUseCase) Run(ctx context.Context, opts *WorkflowRunE if err := uc.ExpirationSweep(ctx, threshold); err != nil { uc.logger.Error(err) } - - if err := uc.EventsRetentionSweep(ctx, time.Now().Add(-resolvedOpts.EventsRetention)); err != nil { - uc.logger.Error(err) - } } timer.Reset(resolvedOpts.CheckInterval) } }() - uc.logger.Infof("periodic check enabled. interval=%s, expirationWindow=%s, eventsRetention=%s", resolvedOpts.CheckInterval, resolvedOpts.ExpirationWindow, resolvedOpts.EventsRetention) -} - -// EventsRetentionSweep deletes the progress events created before olderThan. The runs stay. -func (uc *WorkflowRunExpirerUseCase) EventsRetentionSweep(ctx context.Context, olderThan time.Time) error { - ctx, span := otelx.Start(ctx, workflowRunTracer, "WorkflowRunExpirerUseCase.EventsRetentionSweep") - defer span.End() - - if uc.runEvents == nil { - return nil - } - - n, err := uc.runEvents.DeleteOlderThan(ctx, olderThan, workflowRunEventsDeleteBatchSize) - if err != nil { - return err - } - - if n > 0 { - uc.logger.Debugf("deleted %d workflow run events older than %s", n, olderThan.Format(time.RFC822)) - } - - return nil + uc.logger.Infof("periodic check enabled. interval=%s, expirationWindow=%s", resolvedOpts.CheckInterval, resolvedOpts.ExpirationWindow) } // ExpirationSweep looks for runs older than the provider time and marks them as expired diff --git a/app/controlplane/pkg/biz/workflowrun_options_test.go b/app/controlplane/pkg/biz/workflowrun_options_test.go index 732986dd2..5b108c43d 100644 --- a/app/controlplane/pkg/biz/workflowrun_options_test.go +++ b/app/controlplane/pkg/biz/workflowrun_options_test.go @@ -27,7 +27,6 @@ func TestResolveWorkflowRunExpirerOpts(t *testing.T) { opts *WorkflowRunExpirerOpts wantExpirationWindow time.Duration wantCheckInterval time.Duration - wantEventsRetention time.Duration }{ { name: "nil options use defaults", @@ -72,17 +71,9 @@ func TestResolveWorkflowRunExpirerOpts(t *testing.T) { opts: &WorkflowRunExpirerOpts{ ExpirationWindow: 2 * time.Hour, CheckInterval: 5 * time.Minute, - EventsRetention: 24 * time.Hour, }, wantExpirationWindow: 2 * time.Hour, wantCheckInterval: 5 * time.Minute, - wantEventsRetention: 24 * time.Hour, - }, - { - name: "non-positive events retention uses the default", - opts: &WorkflowRunExpirerOpts{EventsRetention: -time.Hour}, - wantExpirationWindow: time.Hour, - wantCheckInterval: time.Minute, }, } @@ -91,11 +82,6 @@ func TestResolveWorkflowRunExpirerOpts(t *testing.T) { got := resolveWorkflowRunExpirerOpts(tt.opts) assert.Equal(t, tt.wantExpirationWindow, got.ExpirationWindow) assert.Equal(t, tt.wantCheckInterval, got.CheckInterval) - wantRetention := tt.wantEventsRetention - if wantRetention == 0 { - wantRetention = 90 * 24 * time.Hour - } - assert.Equal(t, wantRetention, got.EventsRetention) }) } } diff --git a/app/controlplane/pkg/biz/workflowrun_test.go b/app/controlplane/pkg/biz/workflowrun_test.go index d38f8fc9b..c482f10ea 100644 --- a/app/controlplane/pkg/biz/workflowrun_test.go +++ b/app/controlplane/pkg/biz/workflowrun_test.go @@ -38,7 +38,6 @@ type workflowrunExpirerTestSuite struct { useCase *biz.WorkflowRunExpirerUseCase repo *repoM.WorkflowRunRepo prometheusRepo *repoM.PromObservable - eventRepo *repoM.WorkflowRunEventRepo ctx context.Context err error toExpire []*biz.WorkflowRun @@ -65,9 +64,8 @@ func (s *workflowrunExpirerTestSuite) SetupTest() { s.repo = repoM.NewWorkflowRunRepo(s.T()) s.prometheusRepo = repoM.NewPromObservable(s.T()) - s.eventRepo = repoM.NewWorkflowRunEventRepo(s.T()) logger := log.NewStdLogger(io.Discard) - s.useCase = biz.NewWorkflowRunExpirerUseCase(s.repo, s.prometheusRepo, biz.NewWorkflowRunEventUseCase(s.eventRepo, logger), logger) + s.useCase = biz.NewWorkflowRunExpirerUseCase(s.repo, s.prometheusRepo, logger) s.ctx = context.TODO() s.err = errors.New("an error") s.threshold = now @@ -117,23 +115,6 @@ func (s *workflowrunExpirerTestSuite) TestSweepSkipsRunFinishedDuringSweep() { s.prometheusRepo.AssertNotCalled(s.T(), "ObserveAttestationIfNeeded", mock.Anything, s.toExpire[0], biz.WorkflowRunExpired) } -// Only the events older than the retention period go, in batches until a short batch -func (s *workflowrunExpirerTestSuite) TestEventsRetentionSweep() { - olderThan := time.Now().Add(-90 * 24 * time.Hour) - - s.eventRepo.On("DeleteOlderThan", mock.Anything, olderThan, 1000).Return(1000, nil).Once() - s.eventRepo.On("DeleteOlderThan", mock.Anything, olderThan, 1000).Return(3, nil).Once() - - s.NoError(s.useCase.EventsRetentionSweep(s.ctx, olderThan)) -} - -func (s *workflowrunExpirerTestSuite) TestEventsRetentionSweepError() { - olderThan := time.Now().Add(-90 * 24 * time.Hour) - s.eventRepo.On("DeleteOlderThan", mock.Anything, olderThan, 1000).Return(0, s.err) - - s.ErrorIs(s.useCase.EventsRetentionSweep(s.ctx, olderThan), s.err) -} - func (s *workflowrunTestSuite) TestMarkAsFinished() { testCases := []struct { name string diff --git a/app/controlplane/pkg/biz/workflowrunevent.go b/app/controlplane/pkg/biz/workflowrunevent.go index 9852b3b9e..c7afe7fc7 100644 --- a/app/controlplane/pkg/biz/workflowrunevent.go +++ b/app/controlplane/pkg/biz/workflowrunevent.go @@ -168,8 +168,6 @@ type WorkflowRunEventRepo interface { Create(ctx context.Context, event *WorkflowRunEvent, maxEvents int) (*WorkflowRunEvent, error) // List returns the events of a run, oldest first List(ctx context.Context, runID uuid.UUID) ([]*WorkflowRunEvent, error) - // DeleteOlderThan deletes up to limit events created before t, and returns how many it deleted. - DeleteOlderThan(ctx context.Context, t time.Time, limit int) (int, error) } type WorkflowRunEventUseCase struct { @@ -292,26 +290,6 @@ func (uc *WorkflowRunEventUseCase) List(ctx context.Context, runID string) ([]*W return uc.repo.List(ctx, runUUID) } -// DeleteOlderThan deletes the events created before t, in batches of batchSize. -// It returns the number of deleted events. -func (uc *WorkflowRunEventUseCase) DeleteOlderThan(ctx context.Context, t time.Time, batchSize int) (int, error) { - ctx, span := otelx.Start(ctx, workflowRunEventTracer, "WorkflowRunEventUseCase.DeleteOlderThan") - defer span.End() - - var total int - for { - n, err := uc.repo.DeleteOlderThan(ctx, t, batchSize) - if err != nil { - return total, fmt.Errorf("deleting workflow run events: %w", err) - } - total += n - - if n < batchSize { - return total, nil - } - } -} - // ClosingWorkflowRunEvent returns the event that closes the timeline of a run when it // gets the given status. It returns nil for a status that does not finish the run. func ClosingWorkflowRunEvent(runID uuid.UUID, runStatus WorkflowRunStatus, reason, attestationDigest string) *WorkflowRunEvent { diff --git a/app/controlplane/pkg/data/ent/migrate/migrations/20261202203348.sql b/app/controlplane/pkg/data/ent/migrate/migrations/20261202203348.sql new file mode 100644 index 000000000..8539cd6b6 --- /dev/null +++ b/app/controlplane/pkg/data/ent/migrate/migrations/20261202203348.sql @@ -0,0 +1,4 @@ +-- atlas:txmode none + +-- Drop index "workflowrunevent_created_at" from table: "workflow_run_events" +DROP INDEX CONCURRENTLY "workflowrunevent_created_at"; diff --git a/app/controlplane/pkg/data/ent/migrate/migrations/atlas.sum b/app/controlplane/pkg/data/ent/migrate/migrations/atlas.sum index 5430b58e7..03ea51b78 100644 --- a/app/controlplane/pkg/data/ent/migrate/migrations/atlas.sum +++ b/app/controlplane/pkg/data/ent/migrate/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:NaN66TTuSxozRg1B/ARWWhfUSdFYVFDwoR6dmNaJAwc= +h1:DigGqFAgl0FJLX+iyKT/UPGDFD55/urgtPYLjHSnmug= 20230706165452_init-schema.sql h1:VvqbNFEQnCvUVyj2iDYVQQxDM0+sSXqocpt/5H64k8M= 20230710111950-cas-backend.sql h1:A8iBuSzZIEbdsv9ipBtscZQuaBp3V5/VMw7eZH6GX+g= 20230712094107-cas-backends-workflow-runs.sql h1:a5rzxpVGyd56nLRSsKrmCFc9sebg65RWzLghKHh5xvI= @@ -149,3 +149,4 @@ h1:NaN66TTuSxozRg1B/ARWWhfUSdFYVFDwoR6dmNaJAwc= 20261117162118.sql h1:kihy12JzE5ELo0Jy79LjMs8X4BBgmCjsh8Q1kpFp60c= 20261123100446.sql h1:m6G8YK7prIatRFKx10ZE1mL3qkL7W1pAcQm3vDwML24= 20261130191056.sql h1:pIT59TQwRU/ZBsSdBJjSEE4dOjbmclXbLWI4Upt7X+0= +20261202203348.sql h1:L/mdfquftw4+wozHjtyycIf9SIrO32gkNaI6dzIsAoM= diff --git a/app/controlplane/pkg/data/ent/migrate/schema.go b/app/controlplane/pkg/data/ent/migrate/schema.go index 43a03fc69..a31179367 100644 --- a/app/controlplane/pkg/data/ent/migrate/schema.go +++ b/app/controlplane/pkg/data/ent/migrate/schema.go @@ -1027,11 +1027,6 @@ var ( Unique: false, Columns: []*schema.Column{WorkflowRunEventsColumns[8], WorkflowRunEventsColumns[1]}, }, - { - Name: "workflowrunevent_created_at", - Unique: false, - Columns: []*schema.Column{WorkflowRunEventsColumns[1]}, - }, }, } // ReferrerWorkflowsColumns holds the columns for the "referrer_workflows" table. diff --git a/app/controlplane/pkg/data/ent/schema/workflowrunevent.go b/app/controlplane/pkg/data/ent/schema/workflowrunevent.go index f9d9a121f..fea2f1ba0 100644 --- a/app/controlplane/pkg/data/ent/schema/workflowrunevent.go +++ b/app/controlplane/pkg/data/ent/schema/workflowrunevent.go @@ -64,7 +64,5 @@ func (WorkflowRunEvent) Indexes() []ent.Index { return []ent.Index{ // Events of a run, oldest first index.Fields("workflow_run_id", "created_at"), - // Deletion of old events - index.Fields("created_at"), } } diff --git a/app/controlplane/pkg/data/workflowrunevent.go b/app/controlplane/pkg/data/workflowrunevent.go index 73b8432a1..cf7491710 100644 --- a/app/controlplane/pkg/data/workflowrunevent.go +++ b/app/controlplane/pkg/data/workflowrunevent.go @@ -18,9 +18,7 @@ package data import ( "context" "fmt" - "time" - "entgo.io/ent/dialect/sql" "github.com/chainloop-dev/chainloop/app/controlplane/pkg/biz" "github.com/chainloop-dev/chainloop/app/controlplane/pkg/data/ent" "github.com/chainloop-dev/chainloop/app/controlplane/pkg/data/ent/workflowrun" @@ -120,25 +118,6 @@ func (r *WorkflowRunEventRepo) List(ctx context.Context, runID uuid.UUID) ([]*bi return result, nil } -func (r *WorkflowRunEventRepo) DeleteOlderThan(ctx context.Context, t time.Time, limit int) (int, error) { - ctx, span := otelx.Start(ctx, workflowRunEventRepoTracer, "WorkflowRunEventRepo.DeleteOlderThan") - defer span.End() - - // One statement: delete a batch of the oldest rows that the created_at index finds - n, err := r.data.DB.WorkflowRunEvent.Delete().Where(func(s *sql.Selector) { - batch := sql.Select(workflowrunevent.FieldID). - From(sql.Table(workflowrunevent.Table)). - Where(sql.LT(workflowrunevent.FieldCreatedAt, t)). - Limit(limit) - s.Where(sql.In(s.C(workflowrunevent.FieldID), batch)) - }).Exec(ctx) - if err != nil { - return 0, fmt.Errorf("failed to delete old workflow run events: %w", err) - } - - return n, nil -} - func entWorkflowRunEventToBiz(e *ent.WorkflowRunEvent) *biz.WorkflowRunEvent { return &biz.WorkflowRunEvent{ ID: e.ID, diff --git a/app/controlplane/pkg/data/workflowrunevent_integration_test.go b/app/controlplane/pkg/data/workflowrunevent_integration_test.go index 27db60b0e..5b0844103 100644 --- a/app/controlplane/pkg/data/workflowrunevent_integration_test.go +++ b/app/controlplane/pkg/data/workflowrunevent_integration_test.go @@ -18,7 +18,6 @@ package data_test import ( "context" "testing" - "time" "github.com/chainloop-dev/chainloop/app/controlplane/pkg/biz" "github.com/chainloop-dev/chainloop/app/controlplane/pkg/biz/testhelpers" @@ -207,44 +206,6 @@ func (s *workflowRunEventIntegrationTestSuite) TestRunDeleteCascades() { s.Zero(n) } -func (s *workflowRunEventIntegrationTestSuite) TestDeleteOlderThan() { - ctx := context.Background() - runID := s.newRun() - now := time.Now() - - create := func(createdAt time.Time) uuid.UUID { - return s.Data.DB.WorkflowRunEvent.Create(). - SetWorkflowRunID(runID). - SetSource(biz.WorkflowRunEventSourceCLI). - SetType(biz.WorkflowRunEventTypeMaterial). - SetKey("chainloop.material.a"). - SetStatus(biz.WorkflowRunEventStatusSucceeded). - SetCreatedAt(createdAt). - SaveX(ctx).ID - } - - for range 3 { - create(now.Add(-100 * 24 * time.Hour)) - } - recent := create(now.Add(-time.Hour)) - - // batches of 2 delete the three old events - n, err := s.Repos.WorkflowRunEvent.DeleteOlderThan(ctx, now.Add(-90*24*time.Hour), 2) - s.Require().NoError(err) - s.Equal(2, n) - n, err = s.Repos.WorkflowRunEvent.DeleteOlderThan(ctx, now.Add(-90*24*time.Hour), 2) - s.Require().NoError(err) - s.Equal(1, n) - - left, err := s.Data.DB.WorkflowRunEvent.Query().IDs(ctx) - s.Require().NoError(err) - s.Equal([]uuid.UUID{recent}, left) - - // the run stays - _, err = s.Data.DB.WorkflowRun.Get(ctx, runID) - s.NoError(err) -} - // The run closes its timeline when it is stored, canceled, failed, or expired (R-006) func (s *workflowRunEventIntegrationTestSuite) TestClosingEvent() { ctx := context.Background() diff --git a/deployment/chainloop/Chart.yaml b/deployment/chainloop/Chart.yaml index 459548a0a..2c8c12f65 100644 --- a/deployment/chainloop/Chart.yaml +++ b/deployment/chainloop/Chart.yaml @@ -7,7 +7,7 @@ description: Chainloop is an open source software supply chain control plane, a type: application # Bump the patch (not minor, not major) version on each change in the Chart Source code -version: 1.496.0 +version: 1.496.1 # Do not update appVersion, this is handled automatically by the release process appVersion: v1.140.1 diff --git a/deployment/chainloop/README.md b/deployment/chainloop/README.md index d54f80c3a..c6441e003 100644 --- a/deployment/chainloop/README.md +++ b/deployment/chainloop/README.md @@ -706,7 +706,6 @@ Once done, you can access with [two predefined users](https://github.com/chainlo | `controlplane.attestations` | Attestation processing configuration | | | `controlplane.attestations.workflowRunExpirationWindow` | Maximum age of an unfinished workflow run before it is marked as expired. Use seconds with an "s" suffix, for example "3600s". Units such as "1h" are not supported | `3600s` | | `controlplane.attestations.workflowRunExpirationCheckInterval` | Interval between checks for unfinished workflow runs. Use seconds with an "s" suffix, for example "60s". Units such as "1m" are not supported | `60s` | -| `controlplane.attestations.workflowRunEventsRetention` | Age after which workflow run events are deleted. Use seconds with an "s" suffix, for example "7776000s" | `7776000s` | | `controlplane.containerPorts.http` | controlplane HTTP container port | `8000` | | `controlplane.containerPorts.grpc` | controlplane gRPC container port | `9000` | | `controlplane.containerPorts.metrics` | controlplane prometheus metrics container port | `5000` | diff --git a/deployment/chainloop/templates/controlplane/configmap.yaml b/deployment/chainloop/templates/controlplane/configmap.yaml index a78f9eea8..60f70cb4e 100644 --- a/deployment/chainloop/templates/controlplane/configmap.yaml +++ b/deployment/chainloop/templates/controlplane/configmap.yaml @@ -67,7 +67,6 @@ data: attestations: workflow_run_expiration_window: {{ .Values.controlplane.attestations.workflowRunExpirationWindow | quote }} workflow_run_expiration_check_interval: {{ .Values.controlplane.attestations.workflowRunExpirationCheckInterval | quote }} - workflow_run_events_retention: {{ .Values.controlplane.attestations.workflowRunEventsRetention | quote }} force_verification: {{ ne .Values.controlplane.keylessSigning.forceVerification false }} restrict_org_creation: {{ .Values.controlplane.restrictOrgCreation }} {{- if .Values.controlplane.uiDashboardURL }} diff --git a/deployment/chainloop/values.yaml b/deployment/chainloop/values.yaml index d32fd01e3..395542da9 100644 --- a/deployment/chainloop/values.yaml +++ b/deployment/chainloop/values.yaml @@ -151,11 +151,9 @@ controlplane: ## @extra controlplane.attestations Attestation processing configuration ## @param controlplane.attestations.workflowRunExpirationWindow Maximum age of an unfinished workflow run before it is marked as expired. Use seconds with an "s" suffix, for example "3600s". Units such as "1h" are not supported ## @param controlplane.attestations.workflowRunExpirationCheckInterval Interval between checks for unfinished workflow runs. Use seconds with an "s" suffix, for example "60s". Units such as "1m" are not supported - ## @param controlplane.attestations.workflowRunEventsRetention Age after which workflow run events are deleted. Use seconds with an "s" suffix, for example "7776000s" attestations: workflowRunExpirationWindow: "3600s" workflowRunExpirationCheckInterval: "60s" - workflowRunEventsRetention: "7776000s" ## @param controlplane.containerPorts.http controlplane HTTP container port ## @param controlplane.containerPorts.grpc controlplane gRPC container port diff --git a/docs/specs/issue-3825-attestation-progress-events.md b/docs/specs/issue-3825-attestation-progress-events.md index 6b36d331b..6b42e5a07 100644 --- a/docs/specs/issue-3825-attestation-progress-events.md +++ b/docs/specs/issue-3825-attestation-progress-events.md @@ -45,7 +45,7 @@ While an attestation is in progress, the control plane knows only that its workf - Non-goal: build the UI view. This spec describes what the UI shows. The UI is in a different repository. Follow-up: a ticket in the UI repository. - Non-goal: `chainloop attestation status` reads progress from the control plane. Remote state already lets the command run from a different machine or CI step. - Non-goal: expire runs on inactivity instead of on creation time. Expiry does not change. Follow-up: a ticket if a team asks for it. -- Non-goal: an audit-grade record of a run. Run events are unsigned, deletable after the retention period, and readable by run viewers. The signed attestation and the existing audit log stay the audit record. +- Non-goal: an audit-grade record of a run. Run events are unsigned, ~~deletable after the retention period,~~ kept for the life of the run (R-014), and readable by run viewers. The signed attestation and the existing audit log stay the audit record. - Non-goal: send run events to the audit log, the event bus, or a SIEM. The volume is high, and the ticket does not ask for it. - Non-goal: identify the caller on each event. The attestation already records who authenticated, and all events of a run come from the same attestation. - Non-goal: custom attributes on custom events. A custom event has a key, a status, and a message only. @@ -91,8 +91,10 @@ An automatic event MUST contain only names, types, statuses, counts, digests, ti The control plane MUST record the closing event of the attestation when it stores, cancels, or expires the run. The status is succeeded on store, with the attestation digest and no message. On `attestation reset`, it is canceled for a cancellation and failed for a failure, with the reset reason as the message, cut to 1 KB. It is failed on expiry, with the message "expired". The CLI never records it. It writes the event in the same place as the change of run status. It MUST accept new events for a run only while the run is in progress. - Done when: the last event of each finished run agrees with the status of the run, also for an expired run. -### R-007: Retention -The control plane MUST delete run events that are older than a retention period. The default is 90 days. An operator can change it in the control plane configuration. The age comes from the time of each event. The run and its attestation stay. A periodic job deletes the events, with the same pattern as the run expiry job. +### ~~R-007: Retention~~ +Superseded by R-014. + +~~The control plane MUST delete run events that are older than a retention period. The default is 90 days. An operator can change it in the control plane configuration. The age comes from the time of each event. The run and its attestation stay. A periodic job deletes the events, with the same pattern as the run expiry job.~~ ### R-008: Limits The control plane MUST reject an event that goes past a limit. The limits are 1,000 events for each run, 64 characters for a custom key, and 1 KB for a message. The CLI builds automatic keys from material names that the contract already accepts, so the custom key limit does not apply to them. Each field of an event also has a bound (D-010). Any key has at most 128 characters, and each attribute text at most 256 characters. Each list of policy names has at most 100 names of 256 characters. The CLI cuts a list of policy names to 100 before it sends it, and the policy counts stay complete. The CLI cuts a message to 1 KB before it sends it, so the error text of a failed action is not lost. When the control plane rejects an event, the CLI shows a warning and continues (R-002). @@ -123,6 +125,10 @@ Superseded by R-013. Supersedes R-012. `chainloop attestation event --name --status --message ` MUST record a custom event on the run of the attestation in progress. The command takes the key with the `--name` flag, not as a positional argument, as `chainloop attestation add --name` does. The status is started, succeeded, failed, canceled, or skipped. Skipped is a step that did not run, for example a scan with no target. Only custom events accept the skipped status (D-013). The command finds the run in the same way as the other attestation commands. A custom key MUST use the format of annotation names: letters, digits, `_`, and `-`. A custom key cannot hold a dot, so it never matches an automatic `chainloop.` key. When the command cannot record the event, it shows a warning and exits with success. This also applies to a wrong call, for example a missing `--name`, and to an older control plane. A progress signal never breaks a pipeline. - Done when: `chainloop attestation event --name sast-scan --status started` between `init` and `push` shows the step in `describe`. `chainloop attestation event --name dast-scan --status skipped` shows the step as skipped in `describe`. Each failure shows a warning, and the command exits with 0. +### R-014: Run events are kept for the life of the run +Supersedes R-007. The control plane MUST keep the events of a run for as long as it keeps the run. It deletes the events only when it deletes the run. No periodic job deletes events, and the control plane configuration has no retention setting (D-014). A configuration that still sets the removed `workflow_run_events_retention` MUST load, so that an upgrade does not break the control plane. +- Done when: the events of a run that finished more than 90 days ago are still returned by the read call (R-011). A control plane with `workflow_run_events_retention` in its configuration starts. + ## Constraints - Open source: the feature works in the control plane and the CLI alone. It does not need the event bus or any commercial component. @@ -148,7 +154,7 @@ The key groups events into a step. `chainloop.attestation` runs from `init` to t **CLI.** The attestation commands record events through the new write call of the attestation API. That API already holds the run-scoped authentication of the CI token. Each call is best effort (R-002). The CLI sends each event when the action happens. It does not batch events, so the receive time stays close to the action time. ~~`chainloop workflow run describe` reads the run, its contract, and its events. It builds the list of provided and missing materials from the contract (the run view already returns it) and the material events. So the events are the only new data.~~ `chainloop workflow run describe` shows the progress and the events that the new read call returns (D-012). -**Control plane.** The control plane stores events with the run, in its own database (D-002). It closes the timeline (R-006), deletes old events (R-007), and ~~returns events through a new read call (R-003, D-007).~~ It builds the progress of a run in progress and returns it with the events through a new read call (R-011, D-012). +**Control plane.** The control plane stores events with the run, in its own database (D-002). It closes the timeline (R-006), ~~deletes old events (R-007),~~ keeps the events for the life of the run (R-014, D-014), and ~~returns events through a new read call (R-003, D-007).~~ It builds the progress of a run in progress and returns it with the events through a new read call (R-011, D-012). **UI (described, built in a follow-up).** The run page shows the same data as `describe` in place of its spinner. It polls the read call while the run is in progress. @@ -184,7 +190,7 @@ Progress is a new list of run events with their own write call. It does not reus ### D-002: Store events with the run, not in the audit log The control plane stores run events with the run, in the open source control plane. -- Why: the audit log is available only in the commercial platform, and only organization admins can read it. No client can write to it, its delivery can lose events, and it has no retention. Run viewers must read run events, the CI token must write them, and a job must delete them after a period. +- Why: the audit log is available only in the commercial platform, and only organization admins can read it. No client can write to it, its delivery can lose events, and it has no retention. Run viewers must read run events, the CI token must write them, and ~~a job must delete them after a period.~~ they must stay with the run and go when it is deleted (R-014, D-014). - Alternatives considered: - Add a run target and client events to the audit log: wrong readers, platform only, and CI volume in a log for compliance. - Source: drafting @@ -273,13 +279,22 @@ A custom event can have the status skipped (R-013). The control plane rejects an - Accept skipped for every event type: no automatic event needs it, and the progress logic of the materials would have to handle it. - Source: implementation of skipped custom events +### D-014: Keep run events for the life of the run +Run events have no retention period. They stay with the run, and they go only when the run goes (R-014). The control plane drops the retention job, its setting, and the `created_at` index that only the job used. +- Why: the timeline of a run, with its failed `add` actions, custom steps, and closing event, is important data about how the run went. It is not only a live progress signal. When the events go after 90 days, the history of a finished run loses its timeline, while the run and its attestation stay. +- Alternatives considered: + - Keep the retention, with a longer default: the timeline still goes, only later. + - Keep the retention setting, but turn it off by default: a setting and a job that no deployment needs. + - A total quota of events, or a policy that deletes old runs: a new mechanism for a growth that runs and attestations already have. The limit for each run (R-008) bounds a run to 1,000 client events, plus the closing event of the control plane (R-006). The events of all runs grow with the number of runs, and this is accepted. +- Source: product decision after #3865 + ## Open Questions None. ## Milestones -1. **Automatic progress.** Automatic events (R-001, R-002, R-005, R-006), the read call (R-003), `describe` for runs in progress (R-004), retention (R-007), and limits (R-008). R-010 supersedes R-001, and R-011 supersedes R-003. +1. **Automatic progress.** Automatic events (R-001, R-002, R-005, R-006), the read call (R-003), `describe` for runs in progress (R-004), retention (R-007), and limits (R-008). R-010 supersedes R-001, R-011 supersedes R-003, and R-014 supersedes R-007. 2. **Custom events.** `chainloop attestation event` (R-009). R-012 supersedes R-009. ## Risks @@ -287,9 +302,9 @@ None. | Risk | Mitigation | |------|------------| | A failed send leaves a gap, so `describe` shows a material as missing that is in the attestation state. | `describe` labels the data as reported progress. After the run is stored, the signed attestation is the source (D-003). | -| Material values stay in events of runs that never finish. Today the control plane clears their state. | Values are cut to 256 characters and deleted after the retention period. Run viewers can already read the same values in stored attestations. | +| Material values stay in events of runs that never finish. Today the control plane clears their state. | Values are cut to 256 characters ~~and deleted after the retention period~~ and kept with the run, and deleted when the run is deleted (R-014). Run viewers can already read the same values in stored attestations. | | The error text of a failed `add` quotes part of a file. | The 1 KB message limit (D-009). | -| Event volume grows the database. | The limit for each run and the retention period. | +| Event volume grows the database. | The limit for each run ~~and the retention period~~. Accepted (D-014): with no retention period, the events grow with the number of runs, at most 1,000 client events and the closing event for each run, as the runs and their attestations already do. | | A run with about 1,000 separate `add` commands fills the limit of 1,000 events. The control plane then rejects the later events~~, also the push event~~, and the CLI shows a warning (D-011). | Accepted. The limit applies only to the events of the client. The store and the closing event of the control plane do not depend on events. | | The start event comes at the end of `init`, so its time is a few seconds after the start of the run. | The run keeps its exact creation time. | | Superseded by D-011. ~~The push event shows the gate result, not the store result. A retry of the push records it again. A store that fails leaves a succeeded push event on a run in progress.~~ | ~~`describe` uses the latest push event. The closing event of the control plane shows the store (R-006).~~ |