Skip to content

Commit

Permalink
Merge pull request scylladb#2142 from rzetelskik/manager-task-update-fix
Browse files Browse the repository at this point in the history
Set managed hash labels in manager tasks and only update tasks when managed hash changes
  • Loading branch information
scylla-operator-bot[bot] authored Oct 14, 2024
2 parents 1eb0336 + e6eaa65 commit 04a5ae3
Show file tree
Hide file tree
Showing 11 changed files with 482 additions and 331 deletions.
10 changes: 10 additions & 0 deletions deploy/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3221,6 +3221,11 @@ spec:
items:
type: string
type: array
labels:
additionalProperties:
type: string
description: labels reflects the labels of a task.
type: object
location:
description: location reflects a list of backup locations in the format [<dc>:]<provider>:<name> ex. s3:my-bucket.
items:
Expand Down Expand Up @@ -3405,6 +3410,11 @@ spec:
items:
type: string
type: array
labels:
additionalProperties:
type: string
description: labels reflects the labels of a task.
type: object
name:
description: name reflects the name of a task.
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4801,6 +4801,9 @@ object
* - keyspace
- array (string)
- keyspace reflects a list of keyspace/tables glob patterns, e.g. 'keyspace,!keyspace.table_prefix_*' used to include or exclude keyspaces from repair.
* - :ref:`labels<api-scylla.scylladb.com-scyllaclusters-v1-.status.backups[].labels>`
- object
- labels reflects the labels of a task.
* - location
- array (string)
- location reflects a list of backup locations in the format [<dc>:]<provider>:<name> ex. s3:my-bucket.
Expand Down Expand Up @@ -4829,6 +4832,20 @@ object
- array (string)
- uploadParallel reflects a list of upload parallelism limits in the format [<dc>:]<limit>.

.. _api-scylla.scylladb.com-scyllaclusters-v1-.status.backups[].labels:

.status.backups[].labels
^^^^^^^^^^^^^^^^^^^^^^^^

Description
"""""""""""
labels reflects the labels of a task.

Type
""""
object


.. _api-scylla.scylladb.com-scyllaclusters-v1-.status.conditions[]:

.status.conditions[]
Expand Down Expand Up @@ -4933,6 +4950,9 @@ object
* - keyspace
- array (string)
- keyspace reflects a list of keyspace/tables glob patterns, e.g. 'keyspace,!keyspace.table_prefix_*' used to include or exclude keyspaces from repair.
* - :ref:`labels<api-scylla.scylladb.com-scyllaclusters-v1-.status.repairs[].labels>`
- object
- labels reflects the labels of a task.
* - name
- string
- name reflects the name of a task.
Expand All @@ -4952,6 +4972,20 @@ object
- string
- timezone reflects the timezone of cron field.

.. _api-scylla.scylladb.com-scyllaclusters-v1-.status.repairs[].labels:

.status.repairs[].labels
^^^^^^^^^^^^^^^^^^^^^^^^

Description
"""""""""""
labels reflects the labels of a task.

Type
""""
object


.. _api-scylla.scylladb.com-scyllaclusters-v1-.status.upgrade:

.status.upgrade
Expand Down
10 changes: 10 additions & 0 deletions pkg/api/scylla/v1/scylla.scylladb.com_scyllaclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2180,6 +2180,11 @@ spec:
items:
type: string
type: array
labels:
additionalProperties:
type: string
description: labels reflects the labels of a task.
type: object
location:
description: location reflects a list of backup locations in the format [<dc>:]<provider>:<name> ex. s3:my-bucket.
items:
Expand Down Expand Up @@ -2364,6 +2369,11 @@ spec:
items:
type: string
type: array
labels:
additionalProperties:
type: string
description: labels reflects the labels of a task.
type: object
name:
description: name reflects the name of a task.
type: string
Expand Down
4 changes: 4 additions & 0 deletions pkg/api/scylla/v1/types_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,10 @@ type TaskStatus struct {
// +optional
ID *string `json:"id,omitempty"`

// labels reflects the labels of a task.
// +optional
Labels map[string]string `json:"labels,omitempty"`

// error holds the task error, if any.
// +optional
Error *string `json:"error,omitempty"`
Expand Down
7 changes: 7 additions & 0 deletions pkg/api/scylla/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/controller/manager/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (c *Controller) calculateStatus(sc *scyllav1.ScyllaCluster, managerState *s

managerTaskStatus, isInManagerState := managerState.RepairTasks[rt.Name]
if isInManagerState {
repairTaskStatus = scyllav1.RepairTaskStatus(managerTaskStatus)
repairTaskStatus = managerTaskStatus
} else {
// Retain the error from client.
err, hasClientError := repairTaskClientErrorMap[rt.Name]
Expand Down Expand Up @@ -62,7 +62,7 @@ func (c *Controller) calculateStatus(sc *scyllav1.ScyllaCluster, managerState *s

managerTaskStatus, isInManagerState := managerState.BackupTasks[bt.Name]
if isInManagerState {
backupTaskStatus = scyllav1.BackupTaskStatus(managerTaskStatus)
backupTaskStatus = managerTaskStatus
} else {
// Retain the error from client.
err, hasClientError := backupTaskClientErrorMap[bt.Name]
Expand Down
8 changes: 4 additions & 4 deletions pkg/controller/manager/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ func (c *Controller) getManagerState(ctx context.Context, clusterID string) (*st
return nil, err
}
var (
repairTasks map[string]RepairTaskStatus
backupTasks map[string]BackupTaskStatus
repairTasks map[string]scyllav1.RepairTaskStatus
backupTasks map[string]scyllav1.BackupTaskStatus
)

if clusterID != "" {
Expand All @@ -48,7 +48,7 @@ func (c *Controller) getManagerState(ctx context.Context, clusterID string) (*st
return nil, err
}

repairTasks = make(map[string]RepairTaskStatus, len(managerRepairTasks.TaskListItemSlice))
repairTasks = make(map[string]scyllav1.RepairTaskStatus, len(managerRepairTasks.TaskListItemSlice))
for _, managerRepairTask := range managerRepairTasks.TaskListItemSlice {
rts, err := NewRepairStatusFromManager(managerRepairTask)
if err != nil {
Expand All @@ -62,7 +62,7 @@ func (c *Controller) getManagerState(ctx context.Context, clusterID string) (*st
return nil, err
}

backupTasks = make(map[string]BackupTaskStatus, len(managerBackupTasks.TaskListItemSlice))
backupTasks = make(map[string]scyllav1.BackupTaskStatus, len(managerBackupTasks.TaskListItemSlice))
for _, managerBackupTask := range managerBackupTasks.TaskListItemSlice {
bts, err := NewBackupStatusFromManager(managerBackupTask)
if err != nil {
Expand Down
Loading

0 comments on commit 04a5ae3

Please sign in to comment.