Skip to content

Commit

Permalink
Remove Cluster field in Strategy
Browse files Browse the repository at this point in the history
Signed-off-by: Florent Poinsard <[email protected]>
  • Loading branch information
frouioui committed May 28, 2024
1 parent bc74ab4 commit b30aa09
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 37 deletions.
6 changes: 3 additions & 3 deletions deploy/crds/planetscale.com_vitessbackupschedules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ spec:
allowedMissedRun:
minimum: 0
type: integer
cluster:
type: string
concurrencyPolicy:
enum:
- Allow
Expand Down Expand Up @@ -97,8 +99,6 @@ spec:
strategies:
items:
properties:
cluster:
type: string
extraFlags:
additionalProperties:
type: string
Expand All @@ -116,7 +116,6 @@ spec:
example: '-'
type: string
required:
- cluster
- name
type: object
minItems: 1
Expand All @@ -128,6 +127,7 @@ spec:
suspend:
type: boolean
required:
- cluster
- name
- resources
- schedule
Expand Down
3 changes: 0 additions & 3 deletions deploy/crds/planetscale.com_vitessclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,6 @@ spec:
strategies:
items:
properties:
cluster:
type: string
extraFlags:
additionalProperties:
type: string
Expand All @@ -240,7 +238,6 @@ spec:
example: '-'
type: string
required:
- cluster
- name
type: object
minItems: 1
Expand Down
34 changes: 22 additions & 12 deletions docs/api/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2361,6 +2361,17 @@ <h3 id="planetscale.com/v2.VitessBackupSchedule">VitessBackupSchedule
</tr>
<tr>
<td>
<code>cluster</code></br>
<em>
string
</em>
</td>
<td>
<p>Cluster on which this schedule runs.</p>
</td>
</tr>
<tr>
<td>
<code>image</code></br>
<em>
string
Expand Down Expand Up @@ -2438,6 +2449,17 @@ <h3 id="planetscale.com/v2.VitessBackupScheduleSpec">VitessBackupScheduleSpec
</tr>
<tr>
<td>
<code>cluster</code></br>
<em>
string
</em>
</td>
<td>
<p>Cluster on which this schedule runs.</p>
</td>
</tr>
<tr>
<td>
<code>image</code></br>
<em>
string
Expand Down Expand Up @@ -2545,18 +2567,6 @@ <h3 id="planetscale.com/v2.VitessBackupScheduleStrategy">VitessBackupScheduleStr
</tr>
<tr>
<td>
<code>cluster</code></br>
<em>
string
</em>
</td>
<td>
<p>Cluster defines on which cluster you want to take the backup.
This field is mandatory regardless of the chosen strategy.</p>
</td>
</tr>
<tr>
<td>
<code>keyspace</code></br>
<em>
string
Expand Down
7 changes: 3 additions & 4 deletions pkg/apis/planetscale/v2/vitessbackupschedule_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ type VitessBackupScheduleSpec struct {
// These are the parts that are configurable through the VitessCluster CRD.
VitessBackupScheduleTemplate `json:",inline"`

// Cluster on which this schedule runs.
Cluster string `json:"cluster"`

// Image should be any image that already contains vtctldclient installed.
// The controller will re-use the vtctld image by default.
Image string `json:"image,omitempty"`
Expand Down Expand Up @@ -178,10 +181,6 @@ type VitessBackupScheduleStrategy struct {
// Name of the backup strategy.
Name BackupStrategyName `json:"name"`

// Cluster defines on which cluster you want to take the backup.
// This field is mandatory regardless of the chosen strategy.
Cluster string `json:"cluster"`

// 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ func (r *ReconcileVitessBackupsSchedule) createJobPod(ctx context.Context, vbsc
}

for i, strategy := range vbsc.Spec.Strategy {
vtctldclientServerArg, err := getVtctldServiceName(strategy.Cluster)
vtctldclientServerArg, err := getVtctldServiceName(vbsc.Spec.Cluster)
if err != nil {
return corev1.PodSpec{}, err
}
Expand All @@ -519,7 +519,7 @@ func (r *ReconcileVitessBackupsSchedule) createJobPod(ctx context.Context, vbsc
if strategy.Keyspace == "" {
return pod, fmt.Errorf("the Keyspace field is missing from VitessBackupScheduleStrategy %s", planetscalev2.BackupKeyspace)
}
shards, err := r.getAllShardsInKeyspace(ctx, vbsc.Namespace, strategy.Cluster, strategy.Keyspace)
shards, err := r.getAllShardsInKeyspace(ctx, vbsc.Namespace, vbsc.Spec.Cluster, strategy.Keyspace)
if err != nil {
return corev1.PodSpec{}, err
}
Expand All @@ -528,7 +528,7 @@ func (r *ReconcileVitessBackupsSchedule) createJobPod(ctx context.Context, vbsc
createVtctldClientCommand(&cmd, vtctldclientServerArg, strategy.ExtraFlags, strategy.Keyspace, shard)
}
case planetscalev2.BackupCluster:
keyspaces, err := r.getAllShardsInCluster(ctx, vbsc.Namespace, strategy.Cluster)
keyspaces, err := r.getAllShardsInCluster(ctx, vbsc.Namespace, vbsc.Spec.Cluster)
if err != nil {
return corev1.PodSpec{}, err
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/operator/vitessbackup/schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ func NewVitessBackupSchedule(key client.ObjectKey, vt *planetscalev2.VitessClust
// We simply re-apply the same template that was written by the user.
VitessBackupScheduleTemplate: *vbsc,

Cluster: vt.Name,

// To take backups we only care about having the vtctldclient installed in the container.
// For this reason, we re-use the vtctld Docker image and the same image pull policy.
Image: vt.Spec.Images.Vtctld,
Expand Down
9 changes: 3 additions & 6 deletions test/endtoend/operator/operator-latest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,8 @@ spec:
allowedMissedRun:
minimum: 0
type: integer
cluster:
type: string
concurrencyPolicy:
enum:
- Allow
Expand Down Expand Up @@ -477,8 +479,6 @@ spec:
strategies:
items:
properties:
cluster:
type: string
extraFlags:
additionalProperties:
type: string
Expand All @@ -496,7 +496,6 @@ spec:
example: '-'
type: string
required:
- cluster
- name
type: object
minItems: 1
Expand All @@ -508,6 +507,7 @@ spec:
suspend:
type: boolean
required:
- cluster
- name
- resources
- schedule
Expand Down Expand Up @@ -1704,8 +1704,6 @@ spec:
strategies:
items:
properties:
cluster:
type: string
extraFlags:
additionalProperties:
type: string
Expand All @@ -1723,7 +1721,6 @@ spec:
example: '-'
type: string
required:
- cluster
- name
type: object
minItems: 1
Expand Down
9 changes: 3 additions & 6 deletions test/endtoend/operator/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,8 @@ spec:
allowedMissedRun:
minimum: 0
type: integer
cluster:
type: string
concurrencyPolicy:
enum:
- Allow
Expand Down Expand Up @@ -477,8 +479,6 @@ spec:
strategies:
items:
properties:
cluster:
type: string
extraFlags:
additionalProperties:
type: string
Expand All @@ -496,7 +496,6 @@ spec:
example: '-'
type: string
required:
- cluster
- name
type: object
minItems: 1
Expand All @@ -508,6 +507,7 @@ spec:
suspend:
type: boolean
required:
- cluster
- name
- resources
- schedule
Expand Down Expand Up @@ -1704,8 +1704,6 @@ spec:
strategies:
items:
properties:
cluster:
type: string
extraFlags:
additionalProperties:
type: string
Expand All @@ -1723,7 +1721,6 @@ spec:
example: '-'
type: string
required:
- cluster
- name
type: object
minItems: 1
Expand Down

0 comments on commit b30aa09

Please sign in to comment.