audit-logging: Add core.auditlog package #8138

Merged
merged 4 commits into from Nov 29, 2017

Conversation

Projects
None yet
3 participants
Member

babbageclunk commented Nov 27, 2017

Description of change

core.auditlog contains the AuditLogFile and Recorder, which will be used in the apiserver (in a subsequent PR) to write audit log information as API methods are called.

QA steps

No behaviour change - not integrated into apiserver yet.

This will need to land in develop branch now

core/auditlog/auditlog.go
+
+// FacadeResponse captures any errors coming back from the API in
+// response to a request.
+type FacadeResponse struct {
@wallyworld

wallyworld Nov 28, 2017

Owner

To make it clear this does not include any payload data (just errors), should it be called FacadeResponseErrors

core/auditlog/auditlog.go
+
+// ResponseArgs is the information about an API response to record in
+// the audit log.
+type ResponseArgs struct {
@wallyworld

wallyworld Nov 28, 2017

Owner

where are the args? the struct just has errors

@babbageclunk

babbageclunk Nov 28, 2017

Member

It's the args struct to make a Response - which will now be called a ResponseErrors, so this will be ResponseErrorsArgs.

+
+// AuditLog represents something that can store calls, requests and
+// responses somewhere.
+type AuditLog interface {
@wallyworld

wallyworld Nov 28, 2017

Owner

at this point I'm a little confused about the difference between a Call and a Request

+}
+
+// Recorder records method calls for a specific API connection.
+type Recorder struct {
@wallyworld

wallyworld Nov 28, 2017

Owner

does this need to be exported?

@babbageclunk

babbageclunk Nov 28, 2017

Member

Yes - this is what will be created by the API server when a new connection is made. It records the requests and responses for a specific (whatever we rename Call to).

core/auditlog/auditlog.go
+ return hex.EncodeToString(buf)
+}
+
+type AuditLogFile struct {
@wallyworld

wallyworld Nov 28, 2017

Owner

needs comment if exported but i don't think it needs to be

@babbageclunk

babbageclunk Nov 28, 2017

Member

No, you're right - it shouldn't be exported, NewLogFile should return an AuditLog which will get passed in to NewRecorder.

core/auditlog/auditlog.go
+ return &AuditLogFile{
+ fileLogger: &lumberjack.Logger{
+ Filename: logPath,
+ MaxSize: 300, // MB
@wallyworld

wallyworld Nov 28, 2017

Owner

todo - make these configurable?

@babbageclunk

babbageclunk Nov 28, 2017

Member

I'll make them parameters of NewLogFile.

@babbageclunk babbageclunk changed the base branch from state-controller-refactor to develop Nov 28, 2017

core/auditlog/auditlog.go
+}
+
+// Request represents a call to an API facade made as part of
+// executing a specific high-level command.
@wallyworld

wallyworld Nov 29, 2017

Owner

a specific conversation

Member

babbageclunk commented Nov 29, 2017

$$merge$$

Contributor

jujubot commented Nov 29, 2017

Status: merge request accepted. Url: http://ci.jujucharms.com/job/github-merge-juju

@jujubot jujubot merged commit fa60768 into juju:develop Nov 29, 2017

1 check was pending

continuous-integration/jenkins/pr-merge This commit is being built
Details

@babbageclunk babbageclunk deleted the babbageclunk:audit-log branch Dec 11, 2017

jujubot added a commit that referenced this pull request Dec 11, 2017

Merge pull request #8198 from babbageclunk/audit-log-2.3
audit-logging: Add core.auditlog package

## Description of change

core.auditlog contains the `AuditLogFile` and `Recorder`, which will be used in the apiserver (in a subsequent PR) to write audit log information as API methods are called.

## QA steps

No behaviour change - not integrated into apiserver yet.

(This is a backport of #8138 to the 2.3 branch.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment