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

Switch to use upstream audit handler #11192

Merged
merged 4 commits into from
Oct 22, 2016
Merged

Conversation

soltysh
Copy link
Contributor

@soltysh soltysh commented Oct 3, 2016

Fixes #11037.

@sttts for the switch itself

@openshift/api-review for config changes

asgroups := "<lookup>"
requestedGroups := req.Header[authenticationapi.ImpersonateGroupHeader]
if len(requestedGroups) > 0 {
asgroups = strings.Join(requestedGroups, ", ")
Copy link
Contributor

Choose a reason for hiding this comment

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

this makes it impossible to determine whether a group name had a comma in it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can it? If so, how about just space?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to space.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to something like this: "'group 1', 'group 2'", according to @deads2k upstream comment.

@@ -325,6 +325,14 @@ type AuditConfig struct {
// If this flag is set, audit log will be printed in the logs.
// The logs contains, method, user and a requested URL.
Enabled bool
// All requests coming to the apiserver will be logged to this file.
Path string
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is a path to a file i would recommend making this AuditFilePath

// All requests coming to the apiserver will be logged to this file.
Path string
// Maximum number of days to retain old audit log files based on the timestamp encoded in their filename.
MaxAge int
Copy link
Contributor

Choose a reason for hiding this comment

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

MaximumAuditRetention* where * is the unit. I don't think Days is appropriate, pick seconds or minutes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have to stick to days for now, since the luberjack library supports just days.

// Maximum number of days to retain old audit log files based on the timestamp encoded in their filename.
MaxAge int
// Maximum number of old audit log files to retain.
MaxBackups int
Copy link
Contributor

Choose a reason for hiding this comment

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

MaximumRetainedAuditFiles

// Maximum number of old audit log files to retain.
MaxBackups int
// Maximum size in megabytes of the audit log file before it gets rotated. Defaults to 100MB.
MaxSize int
Copy link
Contributor

Choose a reason for hiding this comment

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

MaximumAuditFileSizeMegabytes (there's an example of this somewhere else, make it consistent with ordering)

Copy link
Contributor

@smarterclayton smarterclayton left a comment

Choose a reason for hiding this comment

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

See comments

@soltysh soltysh force-pushed the issue11037 branch 2 times, most recently from 03e7784 to be3768c Compare October 4, 2016 08:54
@soltysh
Copy link
Contributor Author

soltysh commented Oct 4, 2016

@smarterclayton updated with one exception, I stick to days for MaximumAuditRetention* since that's the only granularity I have when working with lumberjack log library. ptal

@soltysh
Copy link
Contributor Author

soltysh commented Oct 6, 2016

@smarterclayton are we good to go?

@soltysh
Copy link
Contributor Author

soltysh commented Oct 6, 2016

@smarterclayton updated

@smarterclayton
Copy link
Contributor

API approved

@soltysh
Copy link
Contributor Author

soltysh commented Oct 7, 2016

@sttts any objections for merging this in?

@deads2k
Copy link
Contributor

deads2k commented Oct 7, 2016

@sttts any objections for merging this in?

He's out next week too. I merged the upstream pull, right?

@@ -325,6 +325,14 @@ type AuditConfig struct {
// If this flag is set, audit log will be printed in the logs.
// The logs contains, method, user and a requested URL.
Enabled bool
// All requests coming to the apiserver will be logged to this file.
AuditFilePath string
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see validation on these fields and I don't see this path listed in the list of paths for resolution.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@deads2k what kind of validation you're thinking about? that the path field is non-empty and ints are >= 0? I don't see any value in that.

@deads2k
Copy link
Contributor

deads2k commented Oct 7, 2016

Need to handle backwards compatibility. Can you have it continue to come out in the old log if the filename isn't specified?

@soltysh
Copy link
Contributor Author

soltysh commented Oct 7, 2016

@deads2k comments addressed in the last commit, ptal

@@ -256,6 +256,10 @@ func GetMasterFileReferences(config *MasterConfig) []*string {
refs = append(refs, &config.ControllerConfig.ServiceServingCert.Signer.KeyFile)
}

if len(config.AuditConfig.AuditFilePath) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

don't think you need the len check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure I want to have empty file name here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I see all the places that use this are ignoring the empty file paths.


if len(config.AuditFilePath) == 0 {
// for backwards compatibility reasons we can't error this out
validationResults.AddWarnings(field.Required(fldPath.Child("auditFilePath"), ""))
Copy link
Contributor

Choose a reason for hiding this comment

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

use the reason field to describe the change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@@ -158,6 +159,17 @@ func (fn APIInstallFunc) InstallAPI(container *restful.Container) ([]string, err
return fn(container)
}

// auditGlogWriter is for backwards compatibility, where audit was logged
// to regular log file, instead of separate one like it's currently available.
type auditGlogWriter struct{}
Copy link
Contributor

Choose a reason for hiding this comment

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

@stevekuznetsov didn't you build this before?

Copy link
Contributor

Choose a reason for hiding this comment

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

I remember wrapping the glog writer somewhere ... can't remember where

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will look.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

here:

func NewGLogWriterV(level int) io.Writer {

@deads2k
Copy link
Contributor

deads2k commented Oct 7, 2016

Minor comments and the API change looks good to me.

@soltysh
Copy link
Contributor Author

soltysh commented Oct 7, 2016

Comments addressed. @deads2k ptal

@deads2k
Copy link
Contributor

deads2k commented Oct 10, 2016

lgtm [merge]

@openshift-bot
Copy link
Contributor

[Test]ing while waiting on the merge queue

@soltysh
Copy link
Contributor Author

soltysh commented Oct 17, 2016

Flake #8571

[merge]

@@ -179,7 +182,22 @@ func (c *MasterConfig) Run(protected []APIInstaller, unprotected []APIInstaller)
handler = c.authorizationFilter(handler)
handler = c.impersonationFilter(handler)
// audit handler must comes before the impersonationFilter to read the original user
handler = c.auditHandler(handler)
if c.Options.AuditConfig.Enabled {
Copy link
Contributor

Choose a reason for hiding this comment

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

Kind of ugly to have this code block here. Hopefully, we are able to get rid of this in a future rebase.

Copy link
Contributor Author

@soltysh soltysh Oct 18, 2016

Choose a reason for hiding this comment

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

We'll be able to move it where necessary, but the option will stay forever with us ;)

@@ -875,6 +893,23 @@ func (c *MasterConfig) getRequestContextMapper() kapi.RequestContextMapper {
return c.RequestContextMapper
}

// getRequestInfoResolver returns a request resolver.
func (c *MasterConfig) getRequestInfoResolver() *apiserver.RequestInfoResolver {
Copy link
Contributor

Choose a reason for hiding this comment

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

This will bite us in the next rebase. Upstream genericapiserver only knows about one APIPrefix and one APIGroupPrefix. Looks like we have to turn those into lists in order to support origin's setup. /cc @deads2k

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do hope the next rebase (I'm the lucky looser/winner) will straight this out.

Copy link
Contributor

Choose a reason for hiding this comment

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

WIP PR for multiple api group prefixes in genericapiserver: kubernetes/kubernetes#35021

Copy link
Contributor

Choose a reason for hiding this comment

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

Let me know when you start the master.go rebase. We have moved around so much stuff, hopefully to the better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I remember, we'll be in touch, definitely.

Copy link
Contributor

Choose a reason for hiding this comment

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

This will bite us in the next rebase. Upstream genericapiserver only knows about one APIPrefix and one APIGroupPrefix. Looks like we have to turn those into lists in order to support origin's setup. /cc @deads2k

Those are all legacy prefixes which I just made have a list upstream: https://github.com/kubernetes/kubernetes/blob/master/pkg/genericapiserver/config.go#L175

@soltysh
Copy link
Contributor Author

soltysh commented Oct 18, 2016

Fixed the test and rebased against latest head, hopefully to have a clean merge.

@soltysh
Copy link
Contributor Author

soltysh commented Oct 20, 2016

Fixed the remaining unit test.

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 59e59e3

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to 59e59e3

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/10294/) (Base Commit: 7405f17)

@openshift-bot
Copy link
Contributor

openshift-bot commented Oct 22, 2016

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/10459/) (Base Commit: 30bbfa2) (Image: devenv-rhel7_5221)

@openshift-bot openshift-bot merged commit 8a79d34 into openshift:master Oct 22, 2016
@soltysh soltysh deleted the issue11037 branch October 24, 2016 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants