Repository navigation
time based retention for build log collector - #3560
Conversation
vito
left a comment
There was a problem hiding this comment.
Sweet, this makes a lot of sense. Thanks for starting on it! 👍 Left some early feedback and one idea for the pipeline config.
| DefaultBuildLogsToRetain uint64 `long:"default-build-logs-to-retain" description:"Default build logs to retain, 0 means all"` | ||
| MaxBuildLogsToRetain uint64 `long:"max-build-logs-to-retain" description:"Maximum build logs to retain, 0 means not specified. Will override values configured in jobs"` | ||
|
|
||
| DefaultBuildLogsDaysToRetain uint64 `long:"default-build-logs-days-to-retain" description:"Default days to retain build logs. 0 means unlimited"` |
There was a problem hiding this comment.
The name here feels odd - how about default-days-to-retain-build-logs and max-days-to-retain-build-logs?
| SerialGroups []string `yaml:"serial_groups,omitempty" json:"serial_groups,omitempty" mapstructure:"serial_groups"` | ||
| RawMaxInFlight int `yaml:"max_in_flight,omitempty" json:"max_in_flight,omitempty" mapstructure:"max_in_flight"` | ||
| BuildLogsToRetain int `yaml:"build_logs_to_retain,omitempty" json:"build_logs_to_retain,omitempty" mapstructure:"build_logs_to_retain"` | ||
| BuildLogsDaysToRetain int `yaml:"build_logs_days_to_retain,omitempty" json:"build_logs_days_to_retain,omitempty" mapstructure:"build_logs_days_to_retain"` |
There was a problem hiding this comment.
What do you think of something like this?:
build_log_retention:
builds: 10
days: 5We'd have to keep build_logs_to_retain for backwards-compatibility, but this would make it easier to add more retention policies without polluting the toplevel configuration too much. I could see someone wanting something like this for example:
build_log_retention:
failed_builds: 1000
succeeded_builds: 10Whaddaya think?
|
Thanks @vito I will look into it and implement your feedback. |
b3ba6fa to
bdfd797
Compare
Signed-off-by: Holger Protzek <[email protected]>
Signed-off-by: Holger Protzek <[email protected]>
997ce6c to
3b220b0
Compare
Signed-off-by: Holger Protzek <[email protected]>
3b220b0 to
86f1fa8
Compare
|
Morning @vito finally I got time to add your suggestions. Build log retention can now be configured: The |
vito
left a comment
There was a problem hiding this comment.
Sweet! I left a few minor suggestions. The new approach looks great. Thanks for coming back to it!
| } | ||
|
|
||
| if daysToRetainBuildLogs > 0 { | ||
| if build.StartTime().AddDate(0, 0, daysToRetainBuildLogs).After(time.Now()) { |
There was a problem hiding this comment.
Should this be build.FinishTime()? It might matter for builds that take a very long time to run - if it runs for 2 days but I have a policy of 'reap after 1 day' I wouldn't want it to be immediately reaped.
| } | ||
|
|
||
| func (blrc *buildLogRetentionCalculator) BuildLogsToRetain(job db.Job) int { | ||
| func (blrc *buildLogRetentionCalculator) BuildLogsToRetain(job db.Job) (int, int) { |
There was a problem hiding this comment.
Maybe this could return atc.BuildLogRetention? It's not clear which int is which, and we already have the handy struct for it.
| if job.BuildLogRetention != nil && job.BuildLogsToRetain != 0 { | ||
| errorMessages = append( | ||
| errorMessages, | ||
| identifier+fmt.Sprintf(" can't use both build_log_retention and deprecated build_logs_to_retain"), |
There was a problem hiding this comment.
| identifier+fmt.Sprintf(" can't use both build_log_retention and deprecated build_logs_to_retain"), | |
| identifier+fmt.Sprintf(" can't use both build_log_retention and build_logs_to_retain"), |
We haven't deprecated it just yet - the validation makes sense but we haven't decided whether we want to deprecate the shorthand form. 🙂
calculate cut off time from EndTime removed deprecation from validation warning Signed-off-by: Holger Protzek <[email protected]>
|
Hi @vito ,I added your suggestions, thanks for the review. |
vito
left a comment
There was a problem hiding this comment.
Tried it out locally and it works!
For my own understanding, days: 2 doesn't mean 'reap after 2 days', it means 'keep anything within 2 days' and fall back on any configured build limit to further retain builds.
So if I have this:
build_log_retention:
days: 2This means "keep everything within the past 2 days, reap everything older".
build_log_retention:
days: 2
builds: 10This means "keep everything within the past 2 days, and keep the last 10 builds (regardless of age), reap everything else".
To be honest, I think this makes sense and is actually the most literal reading, but I do find it a bit hard to reason about. We'll have to be super clear in the documentation. 🤔
Thanks!
* [stable/concourse] Update flags for next Concourse release - Adds `CONCOURSE_CLUSTER_NAME` (concourse.web.clusterName) - https://github.com/concourse/concourse/pull/3736<Paste> Signed-off-by: Ciro S. Costa <[email protected]> * [stable/concourse] add generic secret configurations With the introduction generic caching, we no longer need the vault-specific cacheing flags, while at the same time, having the need of providing new ones (generic). concourse/concourse#3628 Signed-off-by: Ciro S. Costa <[email protected]> * [stable/concourse] add auditing flags With the introduction of auditing capabilities (see Auditor#3577 [1]), it's now possible to configure in a per-subsystem basis which API requests an installation should audit. This commit adds the necessary support for such flags. [1]: concourse/concourse#3577 Signed-off-by: Ciro S. Costa <[email protected]> * [stable/concourse] update image version to 5.2.0 Signed-off-by: Ciro S. Costa <[email protected]> Co-authored-by: Krishna Mannem <[email protected]> * [stable/concourse] Add time based build log retention flags concourse/concourse#3560 Signed-off-by: Ciro S. Costa <[email protected]> Co-authored-by: Krishna Mannem <[email protected]> * [stable/concourse] add support for externalGardenUrl With the addition of `external-garden-url` to the `concourse worker` command, one is now able to reference a non-embedded garden server to be used as the target for container creation. concourse/concourse#3806 Signed-off-by: Ciro S. Costa <[email protected]>
* [stable/concourse] Update flags for next Concourse release - Adds `CONCOURSE_CLUSTER_NAME` (concourse.web.clusterName) - https://github.com/concourse/concourse/pull/3736<Paste> Signed-off-by: Ciro S. Costa <[email protected]> * [stable/concourse] add generic secret configurations With the introduction generic caching, we no longer need the vault-specific cacheing flags, while at the same time, having the need of providing new ones (generic). concourse/concourse#3628 Signed-off-by: Ciro S. Costa <[email protected]> * [stable/concourse] add auditing flags With the introduction of auditing capabilities (see Auditor#3577 [1]), it's now possible to configure in a per-subsystem basis which API requests an installation should audit. This commit adds the necessary support for such flags. [1]: concourse/concourse#3577 Signed-off-by: Ciro S. Costa <[email protected]> * [stable/concourse] update image version to 5.2.0 Signed-off-by: Ciro S. Costa <[email protected]> Co-authored-by: Krishna Mannem <[email protected]> * [stable/concourse] Add time based build log retention flags concourse/concourse#3560 Signed-off-by: Ciro S. Costa <[email protected]> Co-authored-by: Krishna Mannem <[email protected]> * [stable/concourse] add support for externalGardenUrl With the addition of `external-garden-url` to the `concourse worker` command, one is now able to reference a non-embedded garden server to be used as the target for container creation. concourse/concourse#3806 Signed-off-by: Ciro S. Costa <[email protected]>
This adds a time based retention to the build log collector. So it's possible to configure retention count or time or both. If both are configured, the highest value wins: e.g. 10 builds, 1 day = will keep more then 10 builds if per day.