Skip to content

Commit

Permalink
Revert BackupKeyspace and BackupCluster
Browse files Browse the repository at this point in the history
Signed-off-by: Florent Poinsard <[email protected]>
  • Loading branch information
frouioui committed May 30, 2024
1 parent 5809cbd commit 70ba063
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 67 deletions.
4 changes: 2 additions & 2 deletions deploy/crds/planetscale.com_vitessbackupschedules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ spec:
name:
enum:
- BackupShard
- BackupKeyspace
- BackupCluster
type: string
shard:
example: '-'
type: string
required:
- keyspace
- name
- shard
type: object
minItems: 1
type: array
Expand Down
4 changes: 2 additions & 2 deletions deploy/crds/planetscale.com_vitessclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,14 @@ spec:
name:
enum:
- BackupShard
- BackupKeyspace
- BackupCluster
type: string
shard:
example: '-'
type: string
required:
- keyspace
- name
- shard
type: object
minItems: 1
type: array
Expand Down
10 changes: 2 additions & 8 deletions docs/api/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2573,10 +2573,7 @@ <h3 id="planetscale.com/v2.VitessBackupScheduleStrategy">VitessBackupScheduleStr
</em>
</td>
<td>
<em>(Optional)</em>
<p>Keyspace defines the keyspace on which we want to take the backup.
If we have chosen the strategy BackupKeyspace or BackupShard this field
is mandatory. In other cases, the field will be ignored.</p>
<p>Keyspace defines the keyspace on which we want to take the backup.</p>
</td>
</tr>
<tr>
Expand All @@ -2587,10 +2584,7 @@ <h3 id="planetscale.com/v2.VitessBackupScheduleStrategy">VitessBackupScheduleStr
</em>
</td>
<td>
<em>(Optional)</em>
<p>Shard defines the shard on which we want to take a backup. If we have
chosen the strategy BackupShard this field is mandatory, in other cases
the field will be ignored.</p>
<p>Shard defines the shard on which we want to take a backup.</p>
</td>
</tr>
<tr>
Expand Down
18 changes: 2 additions & 16 deletions pkg/apis/planetscale/v2/vitessbackupschedule_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,12 @@ const (

// BackupStrategyName describes the vtctldclient command that will be used to take a backup.
// When scheduling a backup, you must specify at least one strategy.
// +kubebuilder:validation:Enum=BackupShard;BackupKeyspace;BackupCluster
// +kubebuilder:validation:Enum=BackupShard
type BackupStrategyName string

const (
// BackupShard will use the "vtctldclient BackupShard" command to take a backup
BackupShard BackupStrategyName = "BackupShard"

// BackupKeyspace will use the "vtctldclient BackupShard" command multiple times
// to take a backup of all the shards in the given keyspace.
BackupKeyspace BackupStrategyName = "BackupKeyspace"

// BackupCluster will use the "vtctldclient BackupShard" command multiple times
// to take a backup of every shard in the entire Vitess cluster.
BackupCluster BackupStrategyName = "BackupCluster"
)

// VitessBackupSchedule is the Schema for the VitessBackupSchedule API.
Expand Down Expand Up @@ -194,16 +186,10 @@ type VitessBackupScheduleStrategy struct {
Name BackupStrategyName `json:"name"`

// Keyspace defines the keyspace on which we want to take the backup.
// If we have chosen the strategy BackupKeyspace or BackupShard this field
// is mandatory. In other cases, the field will be ignored.
// +optional
// +kubebuilder:example="commerce"
Keyspace string `json:"keyspace"`

// Shard defines the shard on which we want to take a backup. If we have
// chosen the strategy BackupShard this field is mandatory, in other cases
// the field will be ignored.
// +optional
// Shard defines the shard on which we want to take a backup.
// +kubebuilder:example="-"
Shard string `json:"shard"`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,38 +522,7 @@ func (r *ReconcileVitessBackupsSchedule) createJobPod(ctx context.Context, vbsc
addNewCmd(i)
switch strategy.Name {
case planetscalev2.BackupShard:
if strategy.Keyspace == "" {
return pod, fmt.Errorf("the Keyspace field is missing from VitessBackupScheduleStrategy %s", planetscalev2.BackupShard)
}
if strategy.Shard == "" {
return pod, fmt.Errorf("the Shard field is missing from VitessBackupScheduleStrategy %s", planetscalev2.BackupShard)
}
createVtctldClientCommand(&cmd, vtctldclientServerArg, strategy.ExtraFlags, strategy.Keyspace, strategy.Shard)
case planetscalev2.BackupKeyspace:
if strategy.Keyspace == "" {
return pod, fmt.Errorf("the Keyspace field is missing from VitessBackupScheduleStrategy %s", planetscalev2.BackupKeyspace)
}
shards, err := r.getAllShardsInKeyspace(ctx, vbsc.Namespace, vbsc.Spec.Cluster, strategy.Keyspace)
if err != nil {
return corev1.PodSpec{}, err
}
for j, shard := range shards {
addNewCmd(j)
createVtctldClientCommand(&cmd, vtctldclientServerArg, strategy.ExtraFlags, strategy.Keyspace, shard)
}
case planetscalev2.BackupCluster:
keyspaces, err := r.getAllShardsInCluster(ctx, vbsc.Namespace, vbsc.Spec.Cluster)
if err != nil {
return corev1.PodSpec{}, err
}
for ksIndex, ks := range keyspaces {
for shardIndex, shard := range ks.shards {
if shardIndex > 0 || ksIndex > 0 {
cmd.WriteString(" && ")
}
createVtctldClientCommand(&cmd, vtctldclientServerArg, strategy.ExtraFlags, ks.name, shard)
}
}
}

}
Expand Down
8 changes: 4 additions & 4 deletions test/endtoend/operator/operator-latest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -495,14 +495,14 @@ spec:
name:
enum:
- BackupShard
- BackupKeyspace
- BackupCluster
type: string
shard:
example: '-'
type: string
required:
- keyspace
- name
- shard
type: object
minItems: 1
type: array
Expand Down Expand Up @@ -1726,14 +1726,14 @@ spec:
name:
enum:
- BackupShard
- BackupKeyspace
- BackupCluster
type: string
shard:
example: '-'
type: string
required:
- keyspace
- name
- shard
type: object
minItems: 1
type: array
Expand Down
8 changes: 4 additions & 4 deletions test/endtoend/operator/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -495,14 +495,14 @@ spec:
name:
enum:
- BackupShard
- BackupKeyspace
- BackupCluster
type: string
shard:
example: '-'
type: string
required:
- keyspace
- name
- shard
type: object
minItems: 1
type: array
Expand Down Expand Up @@ -1726,14 +1726,14 @@ spec:
name:
enum:
- BackupShard
- BackupKeyspace
- BackupCluster
type: string
shard:
example: '-'
type: string
required:
- keyspace
- name
- shard
type: object
minItems: 1
type: array
Expand Down

0 comments on commit 70ba063

Please sign in to comment.