Skip to content
This repository has been archived by the owner on May 28, 2021. It is now read-only.

API Changes #123

Merged
merged 15 commits into from
Jun 13, 2018
Merged

API Changes #123

merged 15 commits into from
Jun 13, 2018

Conversation

prydie
Copy link

@prydie prydie commented Jun 4, 2018

Started work on making the API more idiomatic prior to v0.2 release. There are still a number of changes to make but feedback at this point would be great.

Includes:

  • Updating dependencies to Kubernetes 1.10.0
  • Regenerating all generated code incl. rename Mysql -> MySQL

Resolves: #119

@prydie prydie requested a review from jhorwit2 June 4, 2018 17:01
// SSLSecretRef allows a user to specify custom CA certificate, server certificate
// and server key for group replication SSL
// +optional
SSLSecretRef *corev1.LocalObjectReference `json:"sslSecretRef,omitempty"`
Copy link
Author

@prydie prydie Jun 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/SSLSecretRef/RootPasswordSecret/g?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/SSLSecretRef/SSLSecret/g but i'm guessing that's what you meant ;)


// ConfigRef allows a user to specify a custom configuration file for MySQL.
// +optional
ConfigRef *corev1.LocalObjectReference `json:"configRef,omitempty"`
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/ConfigRef/Config/g?

// If defined, we use this secret for configuring the MYSQL_ROOT_PASSWORD
// If it is not set we generate a secret dynamically
// +optional
SecretRef *corev1.LocalObjectReference `json:"secretRef,omitempty"`
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/SecretRef/RootPasswordSecret/?

// MultiMaster defines the mode of the MySQL cluster. If set to true,
// all instances will be R/W. If false (the default), only a single instance
// will be R/W and the rest will be R/O.
MultiMaster bool `json:"multiMaster,omitempty"`
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment and link to why multi-master is probably not what users want.

type ClusterStatus struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"`
Phase ClusterPhase `json:"phase"`
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace with conditions?

metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"`
Phase ClusterPhase `json:"phase"`
Errors []string `json:"errors"`
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove?

// The generation of the backup is configured in the Executor configuration.
type BackupStorageProvider struct {
// Name denotes the type of storage provider that will store and retrieve the backups,
// e.g. s3, oci-s3-compat, aws-s3, gce-s3, etc.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s3 only currently

Name string `json:"name"`
// SecretRef is a reference to the Kubernetes secret containing the configuration for uploading
// the backup to authenticated storage.
SecretRef *corev1.LocalObjectReference `json:"secretRef,omitempty"`
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/SecretRef/Secret/?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be AuthSecret or similar? Secret on it's own is a bit too generic in k8s world i'd say?

// BackupStatus captures the current status of a MySQL backup.
type BackupStatus struct {
// Phase is the current life-cycle phase of the Backup.
Phase BackupPhase `json:"phase"`
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace with conditions?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#typical-status-properties

Newer API types should use conditions instead.

You should avoid using phase as it's a deprecated pattern in core.

Outcome BackupOutcome `json:"outcome"`

// TimeStarted is the time at which the backup was started.
TimeStarted metav1.Time `json:"timeStarted"`
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These can be folded into conditions I think?

// ScheduleStatus captures the current state of a MySQL backup schedule.
type ScheduleStatus struct {
// Phase is the current phase of the MySQL backup schedule.
Phase BackupSchedulePhase `json:"phase"`
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace with conditions?

type RestoreSpec struct {
// ClusterRef is a refeference to the Cluster to which the Restore
// belongs.
ClusterRef *corev1.LocalObjectReference `json:"clusterRef"`
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/ClusterRef/Cluster/?

ClusterRef *corev1.LocalObjectReference `json:"clusterRef"`

// BackupRef is a reference to the Backup object to be restored.
BackupRef *corev1.LocalObjectReference `json:"backupRef"`
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/BackupRef/Backup/?

// RestoreStatus captures the current status of a MySQL restore.
type RestoreStatus struct {
// Phase is the current life-cycle phase of the Restore.
Phase RestorePhase `json:"phase"`
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace with conditions?


// If specified, affinity will define the pod's scheduling constraints
// +optional
Affinity *corev1.Affinity `json:"affinity,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Affinity breaks PVC/STS. You sure you want this prior to topology aware CSI?


// AgentScheduled is the agent hostname to run the backup on.
// TODO(apryde): ScheduledAgent (*corev1.LocalObjectReference)?
AgentScheduled string `json:"agentscheduled"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be

ScheduledAgent string json:"scheduledAgent"

// Name of the tool performing the backup, e.g. mysqldump.
Name string `json:"name"`
// Databases are the databases to backup.
Databases []string `json:"databases"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you ever see this needing more fields under database? Like the table? If so i'd recommend using a struct with a name field.

type BackupStorageProvider struct {
// Name denotes the type of storage provider that will store and retrieve the backups.
// Currently only supports "S3" denoting a S3 compatiable storage provider.
Name string `json:"name"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like it should be a const.

// BackupStatus captures the current status of a MySQL backup.
type BackupStatus struct {
// Phase is the current life-cycle phase of the Backup.
Phase BackupPhase `json:"phase"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#typical-status-properties

Newer API types should use conditions instead.

You should avoid using phase as it's a deprecated pattern in core.

Backup *corev1.LocalObjectReference `json:"backup"`

// AgentScheduled is the agent hostname to run the backup on
AgentScheduled string `json:"agentscheduled"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SheduledAgent looks more correct to me. Also camel case on the json field.

Or even AgentName

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about it Agent is an implementation detail. ScheduledMember maybe?

Version string `json:"version"`

// Replicas defines the number of running MySQL instances in a cluster
Replicas int32 `json:"replicas,omitempty"`
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Controversially (perhaps) I'd like to change this to Members. Replicas is semantically incorrect for the default and recommended deployment (i.e. single-primary mode). The MySQL documentation discusses cluster "members" and I think we should align with that.

//cc @owainlewis @garthy @jhorwit2

@prydie prydie changed the title WIP: API Changes API Changes Jun 8, 2018
@prydie prydie added this to the 0.2.0 milestone Jun 8, 2018
@@ -49,23 +47,23 @@ required = [

[[constraint]]
name = "k8s.io/api"
branch = "release-1.9"
version = "kubernetes-1.10.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dependencies need approvals.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

metadata:
name: example-mysql-cluster-with-volume
spec:
replicas: 1
secretRef:
mem : 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo => members

// TODO (owain) we need to remove this because it's not reasonable for us to maintain a list
// of all the potential MySQL versions that can be used and in reality, it shouldn't matter
// too much. The burden of this is not worth the benfit to a user
var validVersions = []string{
Copy link
Member

@owainlewis owainlewis Jun 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be removed based on the changes done for 0.1.1

@prydie
Copy link
Author

prydie commented Jun 12, 2018

@gianlucaborello I’d be very interested on your thoughts on these API changes if you have a moment to take a look at the updated type definitions.

@gianlucaborello
Copy link

Took a quick look (without trying it though) and all seems fine to me, overall minor changes from an API perspective. At the moment, as my RFC PRs hint at, my goal is to make sure the cluster membership management logic is as bullet proof as it can be.

Thanks.

@owainlewis owainlewis self-assigned this Jun 13, 2018
Copy link
Member

@owainlewis owainlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes approved.

@owainlewis owainlewis merged commit 2944c3d into master Jun 13, 2018
@prydie prydie deleted the ap/api-changes branch July 5, 2018 10:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants