-
Notifications
You must be signed in to change notification settings - Fork 31
K8SPS-400: custom options for xtrabackup, xbstream, xbcloud #986
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pooknull please add e2e test for it
return util.MergeEnvLists(b.Env, b.Args.Env()) | ||
} | ||
|
||
func (b *BackupContainerOptions) GetEnvVar(cluster *PerconaServerMySQL, storage *BackupStorageSpec) []corev1.EnvVar { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cluster option here is not used in the function, maybe we can remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return nil | ||
} | ||
|
||
return storage.ContainerOptions.GetEnvVar(nil, nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to understand the logic here. Essentially, the cluster argument is not needed. For nil storage, we call the same function, and we return essentially nil. Why not just
func (b *BackupContainerOptions) GetEnvVar(cluster *PerconaServerMySQL, storage *BackupStorageSpec) []corev1.EnvVar {
if b == nil {
return nil
}
return b.GetEnv()
}
Essentially I'm missing why storage is passed as an argument. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
fmt.Println("TEST", conf.ContainerOptions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to keep this println?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pkg/xtrabackup/xtrabackup.go
Outdated
} | ||
if backupContainerOptions.Args.Xtrabackup != nil { | ||
containerOptions.Args.Xtrabackup = backupContainerOptions.Args.Xtrabackup | ||
fmt.Println("TEST 2", containerOptions.Args.Xtrabackup) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can drop this prinln.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
if backupContainerOptions.Args.Xtrabackup != nil { | ||
containerOptions.Args.Xtrabackup = backupContainerOptions.Args.Xtrabackup | ||
fmt.Println("TEST 2", containerOptions.Args.Xtrabackup) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a leftover print that we can drop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pkg/util/env.go
Outdated
resultList := make([]corev1.EnvVar, 0) | ||
for _, list := range envLists { | ||
for _, env := range list { | ||
idx := FindEnvIndex(resultList, env.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not critical but we can use built-in slices.IndexFunc
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cmd/sidecar/main.go
Outdated
if backupConf.ContainerOptions != nil { | ||
for _, env := range backupConf.ContainerOptions.Env { | ||
if err := os.Setenv(env.Name, env.Value); err != nil { | ||
log.Error(err, "failed to set env") | ||
http.Error(w, "failed to set env", http.StatusInternalServerError) | ||
return | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't it be better to set these env vars for specific commands? like:
xtrabackup := exec.CommandContext(gCtx, "xtrabackup", xtrabackupArgs(string(backupUser), backupPass, &backupConf)...)
env := os.Environ()
for _, e := range backupConf.ContainerOptions.Env {
env = append(env, fmt.Sprintf("%s=%s", e.Name, e.Value)
}
xtrabackup.Env = env
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commit: 6517e4e |
https://perconadev.atlassian.net/browse/K8SPS-400
DESCRIPTION
Problem:
In our backups and restoration process we rely on
xtrabackup
,xbstream
andxbcloud
. Not always default options for these tools are optimal.Solution:
Add
containerOptions
section tops-backup
,ps-restore
andps
resources.If
containerOptions
specified in bothps-backup
/ps-restore
andps
, values fromps-backup
/ps-restore
will be used.Helm PR: percona/percona-helm-charts#612
CHECKLIST
Jira
Needs Doc
) and QA (Needs QA
)?Tests
Config/Logging/Testability