diff --git a/bucket.go b/bucket.go index c347efecf0..2f0d5d2354 100644 --- a/bucket.go +++ b/bucket.go @@ -17,8 +17,10 @@ const ( BucketTypeUser = BucketType(0) // BucketTypeSystem is an internally created bucket that cannot be deleted/renamed. BucketTypeSystem = BucketType(1) - // SystemBucketRetention is the time we should retain system bucket information - SystemBucketRetention = time.Hour * 24 * 7 + // MonitoringSystemBucketRetention is the time we should retain monitoring system bucket information + MonitoringSystemBucketRetention = time.Hour * 24 * 7 + // TasksSystemBucketRetention is the time we should retain task system bucket information + TasksSystemBucketRetention = time.Hour * 24 * 3 ) // Bucket names constants @@ -162,7 +164,7 @@ func FindSystemBucket(ctx context.Context, bs BucketService, orgID ID, name stri ID: TasksSystemBucketID, Type: BucketTypeSystem, Name: TasksSystemBucketName, - RetentionPeriod: SystemBucketRetention, + RetentionPeriod: TasksSystemBucketRetention, Description: "System bucket for task logs", }, nil case MonitoringSystemBucketName: @@ -170,7 +172,7 @@ func FindSystemBucket(ctx context.Context, bs BucketService, orgID ID, name stri ID: MonitoringSystemBucketID, Type: BucketTypeSystem, Name: MonitoringSystemBucketName, - RetentionPeriod: SystemBucketRetention, + RetentionPeriod: MonitoringSystemBucketRetention, Description: "System bucket for monitoring logs", }, nil default: diff --git a/kv/bucket.go b/kv/bucket.go index d65e434e0d..a85fe40dc7 100644 --- a/kv/bucket.go +++ b/kv/bucket.go @@ -139,7 +139,7 @@ func (s *Service) createSystemBuckets(ctx context.Context, tx Tx, o *influxdb.Or OrgID: o.ID, Type: influxdb.BucketTypeSystem, Name: influxdb.TasksSystemBucketName, - RetentionPeriod: influxdb.SystemBucketRetention, + RetentionPeriod: influxdb.TasksSystemBucketRetention, Description: "System bucket for task logs", } @@ -151,7 +151,7 @@ func (s *Service) createSystemBuckets(ctx context.Context, tx Tx, o *influxdb.Or OrgID: o.ID, Type: influxdb.BucketTypeSystem, Name: influxdb.MonitoringSystemBucketName, - RetentionPeriod: influxdb.SystemBucketRetention, + RetentionPeriod: influxdb.MonitoringSystemBucketRetention, Description: "System bucket for monitoring logs", } @@ -337,7 +337,7 @@ func (s *Service) FindBuckets(ctx context.Context, filter influxdb.BucketFilter, ID: influxdb.TasksSystemBucketID, Type: influxdb.BucketTypeSystem, Name: influxdb.TasksSystemBucketName, - RetentionPeriod: influxdb.SystemBucketRetention, + RetentionPeriod: influxdb.TasksSystemBucketRetention, Description: "System bucket for task logs", } @@ -347,7 +347,7 @@ func (s *Service) FindBuckets(ctx context.Context, filter influxdb.BucketFilter, ID: influxdb.MonitoringSystemBucketID, Type: influxdb.BucketTypeSystem, Name: influxdb.MonitoringSystemBucketName, - RetentionPeriod: influxdb.SystemBucketRetention, + RetentionPeriod: influxdb.MonitoringSystemBucketRetention, Description: "System bucket for monitoring logs", } diff --git a/task/backend/analytical_storage.go b/task/backend/analytical_storage.go index 9285f2d93c..6190180e6c 100644 --- a/task/backend/analytical_storage.go +++ b/task/backend/analytical_storage.go @@ -247,7 +247,7 @@ func (as *AnalyticalStorage) FindRunByID(ctx context.Context, taskID, runID infl return run, err } - sb, err := influxdb.FindSystemBucket(ctx, as.BucketService, task.OrganizationID, "_tasks") + sb, err := influxdb.FindSystemBucket(ctx, as.BucketService, task.OrganizationID, influxdb.TasksSystemBucketName) if err != nil { return run, err } @@ -266,8 +266,9 @@ func (as *AnalyticalStorage) FindRunByID(ctx context.Context, taskID, runID infl // so we are faking a read only permission to the org's system bucket runSystemBucketID := sb.ID runAuth := &influxdb.Authorization{ - ID: sb.ID, - OrgID: task.OrganizationID, + ID: sb.ID, + Status: influxdb.Active, + OrgID: task.OrganizationID, Permissions: []influxdb.Permission{ influxdb.Permission{ Action: influxdb.ReadAction,