Skip to content

time based retention for build log collector - #3560

Merged
vito merged 4 commits into
concourse:masterfrom
hprotzek:time-based-log-retention
May 14, 2019
Merged

vito merged 4 commits into
concourse:masterfrom
hprotzek:time-based-log-retention

Conversation

@hprotzek

Copy link
Copy Markdown
Contributor

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.

@vito vito left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sweet, this makes a lot of sense. Thanks for starting on it! 👍 Left some early feedback and one idea for the pipeline config.

Comment thread atc/atccmd/command.go Outdated
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"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The name here feels odd - how about default-days-to-retain-build-logs and max-days-to-retain-build-logs?

Comment thread atc/job_config.go Outdated
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"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What do you think of something like this?:

build_log_retention:
  builds: 10
  days: 5

We'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: 10

Whaddaya think?

@hprotzek

Copy link
Copy Markdown
Contributor Author

Thanks @vito I will look into it and implement your feedback.

@hprotzek
hprotzek force-pushed the time-based-log-retention branch from b3ba6fa to bdfd797 Compare May 10, 2019 08:30
@hprotzek
hprotzek force-pushed the time-based-log-retention branch 2 times, most recently from 997ce6c to 3b220b0 Compare May 10, 2019 08:33
Signed-off-by: Holger Protzek <[email protected]>
@hprotzek
hprotzek force-pushed the time-based-log-retention branch from 3b220b0 to 86f1fa8 Compare May 10, 2019 09:07
@hprotzek

Copy link
Copy Markdown
Contributor Author

Morning @vito finally I got time to add your suggestions. Build log retention can now be configured:

build_log_retention:
  builds: 10
  days: 5

The old build_logs_to_retain is still supported. When used both, a validation error will be thrown.

@vito vito left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sweet! I left a few minor suggestions. The new approach looks great. Thanks for coming back to it!

Comment thread atc/gc/build_log_collector.go Outdated
}

if daysToRetainBuildLogs > 0 {
if build.StartTime().AddDate(0, 0, daysToRetainBuildLogs).After(time.Now()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe this could return atc.BuildLogRetention? It's not clear which int is which, and we already have the handy struct for it.

Comment thread atc/validate.go Outdated
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"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
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]>
@hprotzek

Copy link
Copy Markdown
Contributor Author

Hi @vito ,I added your suggestions, thanks for the review.

@vito vito left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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: 2

This means "keep everything within the past 2 days, reap everything older".

build_log_retention:
  days: 2
  builds: 10

This 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!

@vito
vito merged commit a737aec into concourse:master May 14, 2019
@cirocosta cirocosta added the release/documented Documentation and release notes have been updated. label May 14, 2019
eyenx pushed a commit to eyenx/charts that referenced this pull request May 28, 2019
* [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]>
taylorsilva pushed a commit to taylorsilva/concourse-helm that referenced this pull request Oct 2, 2019
* [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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release/documented Documentation and release notes have been updated.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants