Skip to content

Adding support to external MariaDB server #1311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wfelipew
Copy link
Contributor

Adding support to external MariaDB server as requested on #199.

It supports:

  • Connections
  • Users
  • Grants
  • Databases
  • Backups
  • SQLJobs

@mmontes11
Copy link
Member

mmontes11 commented Jul 1, 2025

Thanks for raising this @wfelipew . Will take a closer look in the following weeks and let you know. Do you mind rebasing with main?

@wfelipew wfelipew force-pushed the external-mariadb branch from 9fa7ae3 to bd01bda Compare July 1, 2025 09:43
@mmontes11
Copy link
Member

Hey @wfelipew ! As we get close to the 25.08 release, I'm finally finding some time to review this. Would you mind resolving the conflicts and rebasing?

@wfelipew wfelipew force-pushed the external-mariadb branch 6 times, most recently from 4085384 to 59e9091 Compare July 16, 2025 19:47
@wfelipew
Copy link
Contributor Author

Hey @wfelipew ! As we get close to the 25.08 release, I'm finally finding some time to review this. Would you mind resolving the conflicts and rebasing?

done

@mmontes11 mmontes11 self-assigned this Jul 16, 2025
@mmontes11
Copy link
Member

Thanks for the effort @wfelipew ! Looks promising, will take a look tomorrow.

@mmontes11 mmontes11 self-requested a review July 17, 2025 15:46
Copy link
Member

@mmontes11 mmontes11 left a comment

Choose a reason for hiding this comment

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

Thank you very much for taking the initiative, I do appreciate the effort made here 🙏🏻

Whilst I believe you are on the right track, I think some adaptations are needed, specially around the new abstractions that we have created. Please see my comments, let me know what you think.

Comment on lines 1169 to 1170
// +kubebuilder:printcolumn:name="Primary",type="string",JSONPath=".status.currentPrimary"
// +kubebuilder:printcolumn:name="Updates",type="string",JSONPath=".spec.updateStrategy.type"
Copy link
Member

@mmontes11 mmontes11 Jul 17, 2025

Choose a reason for hiding this comment

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

These two annotations can be omitted for ExternalMariaDB: We don't know what the primary is nor we are handling updates.

Comment on lines 1200 to 1201
pp := corev1.PullIfNotPresent
return pp
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
pp := corev1.PullIfNotPresent
return pp
return corev1.PullIfNotPresent

We are returning a copy, it is safe to return corev1.PullIfNotPresent directly unless I am missing something


// Get image pull secrets
func (m *ExternalMariaDB) GetImagePullSecrets() []LocalObjectReference {
return nil
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return nil
return nil // ExternalMariaDB uses official MariaDB images (publicly available) for the Backups


// Get image
func (m *ExternalMariaDB) GetImage() string {
return fmt.Sprintf("mariadb:%s", m.Status.Version)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return fmt.Sprintf("mariadb:%s", m.Status.Version)
return fmt.Sprintf("mariadb:%s", m.Status.Version) // // ExternalMariaDB uses official MariaDB images (publicly available) for the Backups

Comment on lines 1216 to 1221
// if !m.IsTLSEnabled() {
// return false
// }
// tls := ptr.Deref(m.Spec.TLS, TLS{})
// return ptr.Deref(tls.Required, false)
return false
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// if !m.IsTLSEnabled() {
// return false
// }
// tls := ptr.Deref(m.Spec.TLS, TLS{})
// return ptr.Deref(tls.Required, false)
return false
return false // ExternalMariaDB does not make use of this, as it is a internal server setting

ObjectReference: mariadbv1alpha1.ObjectReference{
Name: opts.ExternalMariaDB.Name,
},
Kind: "ExternalMariaDB",
Copy link
Member

Choose a reason for hiding this comment

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

Could we create a constant for this along with the other kinds?

PhysicalBackupKind = "PhysicalBackup"

@@ -49,6 +60,15 @@ func (b *Builder) BuildConnection(opts ConnectionOpts, owner metav1.Object) (*ma
if opts.Template != nil {
conn.Spec.ConnectionTemplate = *opts.Template
}

if b == nil {
Copy link
Member

Choose a reason for hiding this comment

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

In which case gets b to be nil, if using the NewBuilder?

func NewBuilder(scheme *runtime.Scheme, env *environment.OperatorEnv, discovery *discovery.Discovery) *Builder {

@@ -34,6 +35,11 @@ type BackupOpts struct {
ExtraOpts []string
}

type ConnectionParamsAwareInterface interface {
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this defined under pkg/interfaces already?

}
return statefulset.ServiceFQDN(mariadb.ObjectMeta)
}
// func host(mariadb interfaces.MariaDBGenericInterface) string {
Copy link
Member

Choose a reason for hiding this comment

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

I think this is equivalent to GetHost, probably we can remove

TLSServerCertSecretKey() types.NamespacedName
}

type ReplicationAwareInterface interface {
Copy link
Member

@mmontes11 mmontes11 Jul 17, 2025

Choose a reason for hiding this comment

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

I think this interface can be removed, please see my previous comments

@wfelipew
Copy link
Contributor Author

Thank you very much for taking the initiative, I do appreciate the effort made here 🙏🏻

Whilst I believe you are on the right track, I think some adaptations are needed, specially around the new abstractions that we have created. Please see my comments, let me know what you think.

Thanks for the review, I'll working on it today

@wfelipew
Copy link
Contributor Author

@mmontes11 I believe I fixed everything except by this one -> #1311 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy