Skip to content
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

do not append timestamp to current log file #62

Closed
wants to merge 2 commits into from

Conversation

schmichael
Copy link
Member

This patch updates the file_sink to not append the timestamp on the current log file. The timestamp is only appended when the file is rotated.

This matches the behavior:

The following example configures a destination called "My Sink" which
stores audit events at the file /tmp/audit.json.

Nomad's documentation is a little vague but implies the prior behavior of always appending a timestamp.

While this is a backward incompatible change I think it's worth it for usability and matching Consul's documentation. Nomad's documentation can be fixed and a notice placed in the Upgrade Guide.

In a bid to try to win your support I labeled this PR a bug despite the tests and comments being very clear the old behavior (always append a timestamp) was intentional.

This patch updates the file_sink to *not* append the timestamp on the
current log file. The timestamp is only appended when the file is
rotated.

This matches the behavior:

- Implemented in Nomad v1.1.4 with hashicorp/nomad#11070
- Requested in hashicorp/nomad#11061
- Referenced in Consul's documentation:
  https://www.consul.io/docs/enterprise/audit-logging

> The following example configures a destination called "My Sink" which
> stores audit events at the file `/tmp/audit.json`.

Nomad's documentation is a little vague but implies the prior behavior
of always appending a timestamp.

While this is a *backward incompatible change* I think it's worth it for
usability and matching Consul's documentation. Nomad's documentation can
be fixed and a notice placed in the Upgrade Guide.
@schmichael schmichael added the bug Something isn't working label Aug 31, 2021
@schmichael schmichael requested a review from lgfa29 August 31, 2021 19:36
Fixes tests that now use os.ReadDir as well as matches go.mod
@schmichael schmichael marked this pull request as draft August 31, 2021 20:38
@schmichael
Copy link
Member Author

Converted to draft as Consul does not necessarily want this behavior, and I don't like the idea of (a) more configuration if it's not absolutely necessary and (b) skew between Nomad and Consul behavior.

schmichael added a commit that referenced this pull request Sep 16, 2021
Backward compatible version of #62 -- This version does *not* change the
default behavior. Users must opt in to new behavior.

This patch updates the file sink to allow *not* appending the timestamp
on the current log file. In this mode the timestamp is only appended
when the file is rotated.

This matches the behavior:

- Implemented in Nomad v1.1.4 with hashicorp/nomad#11070
- Requested in hashicorp/nomad#11061
- Referenced in Consul's documentation: https://www.consul.io/docs/enterprise/audit-logging

> The following example configures a destination called "My Sink" which
> stores audit events at the file `/tmp/audit.json`.

Nomad's documentation is a little vague but implies the prior behavior
of always appending a timestamp.

While this is a *backward incompatible change* I think it's worth it for
usability and matching Consul's documentation. Nomad's documentation can
be fixed and a notice placed in the Upgrade Guide.

In a bid to try to win your support I labeled this PR a bug despite the
tests and comments being very clear the old behavior (always append a
timestamp) *was* intentional.
schmichael added a commit that referenced this pull request Sep 16, 2021
Backward compatible version of #62 -- This version does *not* change the
default behavior. Users must opt in to new behavior.

This patch updates the file sink to allow *not* appending the timestamp
on the current log file. In this mode the timestamp is only appended
when the file is rotated.

This matches the behavior:

- Implemented in Nomad v1.1.4 with hashicorp/nomad#11070
- Requested in hashicorp/nomad#11061

> The following example configures a destination called "My Sink" which
> stores audit events at the file `/tmp/audit.json`.

Nomad's documentation is a little vague but implies the prior behavior
of always appending a timestamp.
schmichael added a commit that referenced this pull request Sep 17, 2021
* allow not appending timestamp to current log file

Backward compatible version of #62 -- This version does *not* change the
default behavior. Users must opt in to new behavior.

This patch updates the file sink to allow *not* appending the timestamp
on the current log file. In this mode the timestamp is only appended
when the file is rotated.

This matches the behavior:

- Implemented in Nomad v1.1.4 with hashicorp/nomad#11070
- Requested in hashicorp/nomad#11061

> The following example configures a destination called "My Sink" which
> stores audit events at the file `/tmp/audit.json`.

Nomad's documentation is a little vague but implies the prior behavior
of always appending a timestamp.

Also fixed one flaky test:

* time may be either the same of after

While Go compares time using a monotonic clock that only prevents time from
moving *backward,* it does *not* guarantee time will move forward
between subsequent calls to `time.Now()`. The After assertion failed in
a test run on Github because it is missing the `Equal` comparison on the
preceeding assertion.
@schmichael
Copy link
Member Author

Closing in favor of #64

@schmichael schmichael closed this Sep 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant