Skip to content

Commit

Permalink
Remove deprecated PVC from top-level MysqlCluster.spec.volumeSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
AMecea committed May 10, 2019
1 parent df80b28 commit d909ab9
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 84 deletions.
38 changes: 0 additions & 38 deletions config/crds/mysql_v1alpha1_mysqlcluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ spec:
type: string
backupURL:
description: Represents an URL to the location where to put backups.
This field is the same as backupUri.
type: string
image:
description: To specify the image that will be used for mysql server
Expand Down Expand Up @@ -161,23 +160,6 @@ spec:
volumeSpec:
description: PVC extra specifiaction
properties:
accessModes:
description: 'AccessModes contains the desired access modes the
volume should have. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1'
items:
type: string
type: array
dataSource:
description: This field requires the VolumeSnapshotDataSource alpha
feature gate to be enabled and currently VolumeSnapshot is the
only supported data source. If the provisioner can support VolumeSnapshot
data source, it will create a new volume and data will be restored
to the volume at the same time. If the provisioner does not support
VolumeSnapshot data source, volume will not be created and the
failure will be reported as an event. In the future, we plan to
support more data source types and the behavior of the provisioner
may change.
type: object
emptyDir:
description: EmptyDir to use as data volume for mysql. EmptyDir
represents a temporary directory that shares a pod's lifetime.
Expand All @@ -192,26 +174,6 @@ spec:
for mysql data. It has the highest level of precedence, followed
by HostPath and EmptyDir. And represents the PVC specification.
type: object
resources:
description: 'Resources represents the minimum resources the volume
should have. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources'
type: object
selector:
description: A label query over volumes to consider for binding.
type: object
storageClassName:
description: 'Name of the StorageClass required by the claim. More
info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1'
type: string
volumeMode:
description: volumeMode defines what type of volume is required
by the claim. Value of Filesystem is implied when not included
in claim spec. This is a beta feature.
type: string
volumeName:
description: VolumeName is the binding reference to the PersistentVolume
backing this claim.
type: string
type: object
required:
- secretName
Expand Down
6 changes: 1 addition & 5 deletions pkg/apis/mysql/v1alpha1/mysqlcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ type MysqlClusterSpec struct {
// +optional
BackupSchedule string `json:"backupSchedule,omitempty"`

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

Expand Down Expand Up @@ -129,10 +129,6 @@ type PodSpec struct {
// VolumeSpec is the desired spec for storing mysql data. Only one of its
// members may be specified.
type VolumeSpec struct {
// DEPRECATED: use `persistentVolumeCalim` field instead to set PVC
// specification
core.PersistentVolumeClaimSpec `json:",inline"`

// EmptyDir to use as data volume for mysql. EmptyDir represents a temporary
// directory that shares a pod's lifetime.
// +optional
Expand Down
1 change: 0 additions & 1 deletion pkg/apis/mysql/v1alpha1/zz_generated.deepcopy.go

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

33 changes: 0 additions & 33 deletions pkg/controller/mysqlcluster/mysqlcluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,6 @@ var _ = Describe("MysqlCluster controller", func() {
var (
expectedRequest reconcile.Request
cluster *mysqlcluster.MysqlCluster
clusterKey types.NamespacedName
secret *corev1.Secret
)

Expand All @@ -394,11 +393,6 @@ var _ = Describe("MysqlCluster controller", func() {
},
})

clusterKey = types.NamespacedName{
Name: cluster.Name,
Namespace: cluster.Namespace,
}

Expect(c.Create(context.TODO(), secret)).To(Succeed())
})

Expand All @@ -407,33 +401,6 @@ var _ = Describe("MysqlCluster controller", func() {
c.Delete(context.TODO(), cluster.Unwrap())
})

It("should update cluster new fields from the deprecated ones", func() {
backupURL := "gs://bucket/"
accessModes := []corev1.PersistentVolumeAccessMode{
corev1.ReadWriteOnce,
}

cluster.Spec.BackupURL = backupURL
cluster.Spec.VolumeSpec = api.VolumeSpec{
// old PVC field
PersistentVolumeClaimSpec: corev1.PersistentVolumeClaimSpec{
AccessModes: accessModes,
},
}

// crete cluster
Expect(c.Create(context.TODO(), cluster.Unwrap())).To(Succeed())
Eventually(requests, timeout).Should(Receive(Equal(expectedRequest)))
// one extra reconcile event because of spec updates
Eventually(requests, timeout).Should(Receive(Equal(expectedRequest)))
Eventually(requests, timeout).Should(Receive(Equal(expectedRequest)))

Expect(c.Get(context.TODO(), clusterKey, cluster.Unwrap())).To(Succeed())
Expect(cluster.Spec.VolumeSpec.PersistentVolumeClaim.AccessModes).To(
Equal(accessModes))
Expect(cluster.Spec.BackupURL).To(Equal(backupURL))
})

It("should set emptyDir as data volume", func() {
cluster.Spec.VolumeSpec = api.VolumeSpec{
EmptyDir: &corev1.EmptyDirVolumeSource{},
Expand Down
8 changes: 1 addition & 7 deletions pkg/internal/mysqlcluster/mysqlcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,5 @@ func (c *MysqlCluster) GetMysqlImage() string {

// UpdateSpec updates the cluster specs that need to be saved
func (c *MysqlCluster) UpdateSpec() {
// 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 {
// pvc, hostPath and emptyDir not specified then set pvc init from inline
c.Spec.VolumeSpec.PersistentVolumeClaim = &c.Spec.VolumeSpec.PersistentVolumeClaimSpec
}
}
// nothing to do
}

0 comments on commit d909ab9

Please sign in to comment.