-
Notifications
You must be signed in to change notification settings - Fork 631
Add LoggingConfiguration struct for providing log path to pgbackrest … #4263
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
base: main
Are you sure you want to change the base?
Add LoggingConfiguration struct for providing log path to pgbackrest … #4263
Conversation
// Logging configuration for pgbackrest processes running in postgres instance pods. | ||
// +optional | ||
Log *LoggingConfiguration `json:"log,omitempty"` |
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 am open to other ideas for the placement of this LoggingConfiguration.
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 do wonder if there would be an even better place to put it, but not sure where, so: Seems reasonable to me for now.
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.
Hmm... Theoretically users could have multiple InstanceSets that have different additional volumes mounted, which would mean we'd need to allow different log paths per InstanceSet... So maybe the LoggingConfiguration should go on the PostgresInstanceSetSpec struct? 🤔
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.
But we mount the same pgbackrest config to every postgres pod, right?
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 was thinking that we had a different pgbackrest_instance.conf
file per InstanceSet, but it seems you are correct... Only one pgbackrest_instance.conf
regardless of the number of InstanceSets... Do we move the Volumes.Additional
out of the PostgresInstanceSetSpec
and into the PostgresClusterSpec
and mount them into all instances so the log paths can be consistent amongst instances? 🤔
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.
But then we'd be mounting the same PVC to all the different InstanceSet pods and having them all write to the same locations. (Which actually is the situation now if you have a single instanceSet with multiple replicas, so... it's already a fraught situation.)
Since we currently only allow people to bring their own volumes (rather than set up a template), people have to be a little careful about the pods-volumes connections. The safest scenario would probably be something like
- multiple instance sets
- each with only 1 replica
- each with the same name of additional volumes but different PVC claims
That way, the config remains the same without any worry about collisions/overwriting between processes (where does each pod log? to the PVC that only that pod is connected)
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.
In other words, I think this is (for now) going to be a lot of socialization and documentation.
) | ||
|
||
// PGBackRestArchive defines a pgBackRest archive configuration | ||
// +kubebuilder:validation:XValidation:rule=`!has(self.repoHost) || !has(self.repoHost.log) || !has(self.repoHost.log.path) || self.repoHost.volumes.additional.exists(x, self.repoHost.log.path.startsWith("/volumes/"+x.name))`,message=`log path is restricted to an existing additional volume` |
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.
Right now I just have it set to validate that the repoHost.log.path
isn't set or if it is, it's set to an additional volume configured in repoHost
... Not sure if we want to allow other paths or not... Thoughts?
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 believe the repohost (as it now exists) will always have a /tmp
directory and a /pgbackrest/repoN
directory. Is that right and if so, would we want to allow logging to those? (Though actually: if we let logging into /pgbackrest/repoN
, what subdirectories would we allow? Probably /pgbackrest/repoN/logs/pgbackrest
only?)
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.
Oh, but /pgbackrest/repoN/log
(or logs?) is our default, so... I suppose we could allow explicit setting of our default just to let people be explicit.
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 believe they all (instance for sidecar, repo host, and backup job) have /tmp
...
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.
Could enforce using /tmp/pgbackrest
subdir if logging to /tmp
acabe60
to
1312df1
Compare
69d7ce8
to
a8dceef
Compare
|
||
// LoggingConfiguration provides logging configuration for various components | ||
type LoggingConfiguration struct { | ||
// +kubebuilder:validation:MaxLength=4096 |
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.
Why 4096 as maxlength?
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 figured any limit was better than no limit and I read somewhere that 4096 is usually the character limit for a directory in linux. Can't imagine anyone ever getting close to this.
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.
Let's start smaller and go larger if anyone hits it. 🤔 256? 300?
📝 These are multiplied by 4x during cost estimation because UTF-8 characters can be up to 4 bytes.
internal/pgbackrest/config.go
Outdated
// If the user has set a log path in the spec, use it. Otherwise, | ||
// default to /pgbackrest/repo#/log where pgBackRest will log to the | ||
// first configured repo volume when commands are run on the pgBackRest | ||
// repo host. With our previous check in RepoHostVolumeDefined(), | ||
// we've already validated that at least one defined repo has a volume. | ||
if repoHost != nil && repoHost.Log != nil && repoHost.Log.Path != "" { | ||
global.Set("log-path", repoHost.Log.Path) | ||
} else { | ||
global.Set("log-path", fmt.Sprintf(naming.PGBackRestRepoLogPath, repo.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.
The logic here seems similar to generateRepoHostLogPath
, though I suppose it might be a little awkward to reuse that func (which loops through repos) here (in a loop of repos). I suppose you could simplify by pulling out the logic from ll 784-790 and reusing it -- but I wonder if there might be a way to keep this legible while reducing even more duplication. I mean: maybe we can pull this out of the repo loop?
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.
will push a refactor commit in a few
pkg/apis/postgres-operator.crunchydata.com/v1/pgbackrest_types.go
Outdated
Show resolved
Hide resolved
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.
LGTM, but still have that question about annotation & additional volumes
pkg/apis/postgres-operator.crunchydata.com/v1/pgbackrest_types.go
Outdated
Show resolved
Hide resolved
c382d94
to
9bb7e57
Compare
…processes. Add ability to send pgbackrest logs to additional volume for repo host processes.
Add maxlength to log path and optional tag to volumes.
Add validation tests for log path and additional volumes.
…l volume when attempting to log pgbackrest sidecar to /volumes. Add test cases.
9bb7e57
to
1cbac34
Compare
…processes.
Add ability to send pgbackrest logs to additional volume for repo host processes.
Checklist:
Type of Changes:
What is the current behavior (link to any open issues here)?
What is the new behavior (if this is a feature change)?
Other Information: