Files
madmin-go/table-maintenance.go

142 lines
6.6 KiB
Go

//
// Copyright (c) 2015-2026 MinIO, Inc.
//
// This file is part of MinIO Object Storage stack
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package madmin
import "encoding/json"
// Table maintenance type constants
const (
MaintenanceTypeIcebergSnapshotManagement = "icebergSnapshotManagement"
MaintenanceTypeIcebergCompaction = "icebergCompaction"
MaintenanceTypeIcebergUnreferencedFileRemoval = "icebergUnreferencedFileRemoval"
)
// IcebergSnapshotManagementSettings contains settings for Iceberg snapshot management.
// This configures automatic snapshot expiration based on age and retention policies.
type IcebergSnapshotManagementSettings struct {
// MaxSnapshotAgeHours specifies the maximum age in hours before snapshots are expired.
// Must be at least 1 if specified.
MaxSnapshotAgeHours *int `json:"maxSnapshotAgeHours,omitempty"`
// MinSnapshotsToKeep specifies the minimum number of snapshots to retain.
// Must be at least 1 if specified.
MinSnapshotsToKeep *int `json:"minSnapshotsToKeep,omitempty"`
// Interval overrides how often this runs, in minutes.
// Inherits: table -> warehouse -> server if nil.
// Must be >= 1.
Interval *int `json:"interval,omitempty"`
}
// IcebergCompactionSettings contains settings for Iceberg table compaction.
type IcebergCompactionSettings struct {
// TargetFileSizeMB is the target file size in MB for compacted files.
TargetFileSizeMB *int `json:"targetFileSizeMB,omitempty"`
// Interval overrides how often this runs, in minutes.
// Inherits: table -> warehouse -> server if nil.
// Must be >= 1.
Interval *int `json:"interval,omitempty"`
// Filter is an optional Iceberg expression, in the REST spec's JSON filter
// form, that scopes compaction to the data files it can match; matched files
// are rewritten in full so no rows are dropped. It is table-scoped only (it
// names a table's columns/partitions) and is rejected at the warehouse level.
Filter json.RawMessage `json:"filter,omitempty"`
}
// IcebergUnreferencedFileRemovalSettings contains settings for Iceberg unreferenced file removal.
// Files are eligible to be marked noncurrent when their age (anchored to creation time) exceeds
// UnreferencedDays. Once noncurrent, files are permanently deleted after NoncurrentDays.
type IcebergUnreferencedFileRemovalSettings struct {
UnreferencedDays *int `json:"unreferencedDays,omitempty"`
NoncurrentDays *int `json:"noncurrentDays,omitempty"`
// Interval overrides how often this runs, in minutes.
// Inherits: table -> warehouse -> server if nil.
// Must be >= 1.
Interval *int `json:"interval,omitempty"`
}
// TableMaintenanceSettings is a union type containing maintenance settings.
// Only one of the fields should be set at a time based on the maintenance type.
type TableMaintenanceSettings struct {
IcebergSnapshotManagement *IcebergSnapshotManagementSettings `json:"icebergSnapshotManagement,omitempty"`
IcebergCompaction *IcebergCompactionSettings `json:"icebergCompaction,omitempty"`
IcebergUnreferencedFileRemoval *IcebergUnreferencedFileRemovalSettings `json:"icebergUnreferencedFileRemoval,omitempty"`
}
// TableMaintenanceConfigurationValue represents a maintenance configuration with status.
type TableMaintenanceConfigurationValue struct {
Settings *TableMaintenanceSettings `json:"settings,omitempty"`
Status MaintenanceStatus `json:"status"`
// Override is true if Settings+Status came from the table's own
// maintenance override, false if inherited from the warehouse default.
Override bool `json:"override"`
}
// PutTableMaintenanceConfigurationRequest is the request body for PutTableMaintenanceConfiguration.
type PutTableMaintenanceConfigurationRequest struct {
Value TableMaintenanceConfigurationValue `json:"value"`
}
// GetTableMaintenanceConfigurationResponse is the response for GetTableMaintenanceConfiguration.
type GetTableMaintenanceConfigurationResponse struct {
Configuration map[string]TableMaintenanceConfigurationValue `json:"configuration"`
TableARN string `json:"tableARN"`
}
// MaintenanceJobStatus represents the outcome of a maintenance job's last run.
type MaintenanceJobStatus string
const (
MaintenanceJobStatusSuccessful MaintenanceJobStatus = "Successful"
MaintenanceJobStatusFailed MaintenanceJobStatus = "Failed"
MaintenanceJobStatusDisabled MaintenanceJobStatus = "Disabled"
MaintenanceJobStatusNotYetRun MaintenanceJobStatus = "Not_Yet_Run"
)
// TableMaintenanceJobTypeStatus is the per-type status entry in GetTableMaintenanceJobStatusResponse.
type TableMaintenanceJobTypeStatus struct {
Status MaintenanceJobStatus `json:"status"`
LastRunTimestamp *string `json:"lastRunTimestamp,omitempty"`
FailureMessage string `json:"failureMessage,omitempty"`
}
// GetTableMaintenanceJobStatusResponse is the response for GetTableMaintenanceJobStatus.
type GetTableMaintenanceJobStatusResponse struct {
TableARN string `json:"tableARN"`
Status map[string]TableMaintenanceJobTypeStatus `json:"status"`
}
// WarehouseMaintenanceConfigurationValue represents a maintenance configuration with status
// for a warehouse. It is structurally identical to TableMaintenanceConfigurationValue but
// scoped to a warehouse rather than an individual table.
type WarehouseMaintenanceConfigurationValue struct {
Settings *TableMaintenanceSettings `json:"settings,omitempty"`
Status MaintenanceStatus `json:"status"`
}
// PutWarehouseMaintenanceConfigurationRequest is the request body for PutWarehouseMaintenanceConfiguration.
type PutWarehouseMaintenanceConfigurationRequest struct {
Value WarehouseMaintenanceConfigurationValue `json:"value"`
}
// GetWarehouseMaintenanceConfigurationResponse is the response for GetWarehouseMaintenanceConfiguration.
type GetWarehouseMaintenanceConfigurationResponse struct {
Configuration map[string]WarehouseMaintenanceConfigurationValue `json:"configuration"`
WarehouseARN string `json:"warehouseARN"`
}