Skip to content

Commit

Permalink
Remove deprecated field bucketURI from backup and cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
AMecea committed May 10, 2019
1 parent c52b445 commit df80b28
Show file tree
Hide file tree
Showing 11 changed files with 8 additions and 78 deletions.
10 changes: 1 addition & 9 deletions config/crds/mysql_v1alpha1_mysqlbackup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ spec:
backupURL:
description: BackupURL represents the URL to the backup location, this
can be partially specifyied. Default is used the one specified in
the cluster. Is the same as backupURI.
type: string
backupUri:
description: Specify an URI where to put the backup. This is deprecated
and will be removed in future releases. Use BackupURL instead.
the cluster.
type: string
clusterName:
description: ClustterName represents the cluster for which to take backup
Expand All @@ -54,10 +50,6 @@ spec:
type: object
status:
properties:
backupUri:
description: BackupURI represent the fully uri to the backup location
This field is deprecated and will be removed in future releases.
type: string
completed:
description: Complete marks the backup in final state
type: boolean
Expand Down
4 changes: 0 additions & 4 deletions config/crds/mysql_v1alpha1_mysqlcluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ spec:
description: Represents an URL to the location where to put backups.
This field is the same as backupUri.
type: string
backupUri:
description: 'Represents the location where to put backups. DEPRECATED:
use BackupURL instead. This field will be dropped in next versions.'
type: string
image:
description: To specify the image that will be used for mysql server
container. If this is specified then the mysqlVersion is ignored.
Expand Down
11 changes: 0 additions & 11 deletions pkg/apis/mysql/v1alpha1/mysqlbackup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,8 @@ type MysqlBackupSpec struct {
// ClustterName represents the cluster for which to take backup
ClusterName string `json:"clusterName"`

// Specify an URI where to put the backup. This is deprecated and will be
// removed in future releases. Use BackupURL instead.
// +optional
BackupURI string `json:"backupUri,omitempty"`

// BackupURL represents the URL to the backup location, this can be
// partially specifyied. Default is used the one specified in the cluster.
// Is the same as backupURI.
// +optional
BackupURL string `json:"backupURL,omitempty"`

Expand Down Expand Up @@ -93,11 +87,6 @@ const (
type MysqlBackupStatus struct {
// Complete marks the backup in final state
Completed bool `json:"completed,omitempty"`

// BackupURI represent the fully uri to the backup location This field is
// deprecated and will be removed in future releases.
BackupURI string `json:"backupUri,omitempty"`

// Conditions represents the backup resource conditions list.
Conditions []BackupCondition `json:"conditions,omitempty"`
}
Expand Down
7 changes: 0 additions & 7 deletions pkg/apis/mysql/v1alpha1/mysqlcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,7 @@ type MysqlClusterSpec struct {
// +optional
BackupSchedule string `json:"backupSchedule,omitempty"`

// Represents the location where to put backups.
// DEPRECATED: use BackupURL instead. This field will be dropped in next
// versions.
// +optional
BackupURI string `json:"backupUri,omitempty"`

// Represents an URL to the location where to put backups. This field is the
// same as backupUri.
// +optional
BackupURL string `json:"backupURL,omitempty"`

Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/mysqlbackup/internal/syncer/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ func (s *jobSyncer) SyncFn(in runtime.Object) error {
}

if len(s.backup.GetBackupURL(s.cluster)) == 0 {
log.Info("can't get bucketURI", "cluster", s.cluster, "backup", s.backup)
return fmt.Errorf("can't get bucketURI")
log.Info("can't get backupURL", "cluster", s.cluster, "backup", s.backup)
return fmt.Errorf("can't get backupURL")
}

// check if job is already created an just update the status
Expand Down
7 changes: 0 additions & 7 deletions pkg/controller/mysqlbackup/mysqlbackup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,6 @@ func (r *ReconcileMysqlBackup) Reconcile(request reconcile.Request) (reconcile.R
// Set defaults on backup
r.scheme.Default(backup.Unwrap())

// migrate old backups to the new version
// TODO: remove this in version v0.3.0
if backup.Spec.BackupURL == "" && backup.Spec.BackupURI == "" && backup.Status.Completed && len(backup.Status.BackupURI) > 0 {
backup.Spec.BackupURL = backup.Status.BackupURI
return reconcile.Result{}, r.Update(context.TODO(), backup)
}

// save the backup for later check for diff
savedBackup := backup.Unwrap().DeepCopy()

Expand Down
16 changes: 0 additions & 16 deletions pkg/controller/mysqlbackup/mysqlbackup_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,22 +288,6 @@ var _ = Describe("MysqlBackup controller", func() {
AfterEach(func() {
Expect(c.Delete(context.TODO(), cluster.Unwrap())).To(Succeed())
})

It("should use backupURI as backupURL", func() {
backup.Spec.BackupURL = ""
backup.Spec.BackupURI = "gs://bucket/"
Expect(c.Create(context.TODO(), backup.Unwrap())).To(Succeed())
defer c.Delete(context.TODO(), backup.Unwrap())

// wait for a reconcile request
Eventually(requests, timeout).Should(Receive(Equal(expectedRequest)))

Eventually(refreshFn(c, backupKey)).Should(PointTo(MatchFields(IgnoreExtras, Fields{
"Spec": MatchFields(IgnoreExtras, Fields{
"BackupURL": ContainSubstring(backup.Spec.BackupURI),
}),
})))
})
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ var _ = Describe("MysqlCluster controller", func() {
corev1.ReadWriteOnce,
}

cluster.Spec.BackupURI = backupURL
cluster.Spec.BackupURL = backupURL
cluster.Spec.VolumeSpec = api.VolumeSpec{
// old PVC field
PersistentVolumeClaimSpec: corev1.PersistentVolumeClaimSpec{
Expand Down
6 changes: 0 additions & 6 deletions pkg/internal/mysqlbackup/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ import (

// SetDefaults sets default for backup
func (w *MysqlBackup) SetDefaults(cluster *mysqlcluster.MysqlCluster) {
// the source of truth is BackupURL if this is not set then use what is in
// BackupURI
if len(w.Spec.BackupURL) == 0 {
w.Spec.BackupURL = w.Spec.BackupURI
}

w.Spec.BackupURL = w.GetBackupURL(cluster)

if len(w.Spec.BackupSecretName) == 0 {
Expand Down
4 changes: 0 additions & 4 deletions pkg/internal/mysqlbackup/mysqlbackup.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ func (b *MysqlBackup) GetBackupURL(cluster *mysqlcluster.MysqlCluster) string {
return b.composeBackupURL(b.Spec.BackupURL)
}

if len(cluster.Spec.BackupURL) == 0 {
cluster.Spec.BackupURL = cluster.Spec.BackupURI
}

if len(cluster.Spec.BackupURL) == 0 {
return ""
}
Expand Down
15 changes: 4 additions & 11 deletions pkg/internal/mysqlcluster/mysqlcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ func (c *MysqlCluster) GetLabels() labels.Set {
}

labels := labels.Set{
// TODO: remove those labels at major release and update selector labels
"app": "mysql-operator",
"mysql_cluster": c.Name,

"mysql.presslabs.org/cluster": c.Name,
"app.kubernetes.io/name": "mysql",
"app.kubernetes.io/instance": instance,
"app.kubernetes.io/version": version,
Expand All @@ -83,8 +80,9 @@ func (c *MysqlCluster) GetLabels() labels.Set {
// GetSelectorLabels returns the labels that will be used as selector
func (c *MysqlCluster) GetSelectorLabels() labels.Set {
return labels.Set{
"app": "mysql-operator",
"mysql_cluster": c.Name,
"app.kubernetes.io/name": "mysql",
"mysql.presslabs.org/cluster": c.Name,
"app.kubernetes.io/managed-by": "mysql.presslabs.org",
}
}

Expand Down Expand Up @@ -169,11 +167,6 @@ func (c *MysqlCluster) GetMysqlImage() string {

// UpdateSpec updates the cluster specs that need to be saved
func (c *MysqlCluster) UpdateSpec() {
// TODO: when BackupURI is removed clear this
if len(c.Spec.BackupURL) == 0 {
c.Spec.BackupURL = c.Spec.BackupURI
}

// TODO: delete this when when inlined PVC is removed from spec.
if c.Spec.VolumeSpec.PersistentVolumeClaim == nil {
if c.Spec.VolumeSpec.HostPath == nil && c.Spec.VolumeSpec.EmptyDir == nil {
Expand Down

0 comments on commit df80b28

Please sign in to comment.