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

upgrade Audit api version to stable #65891

Merged
merged 4 commits into from
Aug 8, 2018

Conversation

CaoShuFeng
Copy link
Contributor

@CaoShuFeng CaoShuFeng commented Jul 6, 2018

Partial Fix: #65266

TODO:
use v1 version of advanced audit policy in kubeadm, gce script, kubemark

What this PR does / why we need it:

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Special notes for your reviewer:

Release note:

audit.k8s.io api group is upgraded from v1beta1 to v1.
Deprecated element metav1.ObjectMeta and Timestamp are removed from audit Events in v1 version.
Default value of option --audit-webhook-version and --audit-log-version will be changed from `audit.k8s.io/v1beta1` to `audit.k8s.io/v1` in release 1.13

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jul 6, 2018
@CaoShuFeng CaoShuFeng changed the title Audit v1 stable upgrade Audit api version to stable Jul 6, 2018
@CaoShuFeng CaoShuFeng force-pushed the audit_v1_stable branch 2 times, most recently from 9dcfe5a to 8418642 Compare July 6, 2018 10:12
Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

I left you some comments.

@@ -0,0 +1,23 @@
/*
Copyright 2017 The Kubernetes Authors.
Copy link
Contributor

Choose a reason for hiding this comment

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

2018

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

@@ -0,0 +1,58 @@
/*
Copyright 2017 The Kubernetes Authors.
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

@@ -0,0 +1,279 @@
/*
Copyright 2017 The Kubernetes Authors.
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -52,7 +52,7 @@ rules:
`

const policyDefV1beta1 = `
apiVersion: audit.k8s.io/v1beta1
apiVersion: audit.k8s.io/v1
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 do this like that, we need to ensure we're reading previous versions. You need to add policyDefV1 and ensure that the new and old ones are properly readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -120,8 +120,8 @@ var _ = SIGDescribe("Advanced Audit", func() {
},
[]auditEvent{
{
v1beta1.LevelRequestResponse,
v1beta1.StageResponseComplete,
auditv1.LevelRequestResponse,
Copy link
Contributor

Choose a reason for hiding this comment

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

Honestly, I'd still like to see both v1 and v1beta1 being tested for a while, at least partially.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now both v1 and v1beta1 are test in unit test.

But in e2e test we can test only one version. Other wise we need to reset the --audit-log-version option and restart kube-apiserver. Now the output version is audit.k8s.io/v1 by default.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have integration tests using k8s.io/kubernetes/cmd/kube-apiserver/app/testing/testserver.go? That way we could test different flags. Very similar to e2e in fact, with a real kube-apiserver. We have some of those tests in test/integration/master.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have some of those tests in test/integration/master.

Added an integration test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do I need to copy all testcases from e2e test into integration test?

Copy link
Contributor

Choose a reason for hiding this comment

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

The test you have now looks pretty good. @soltysh anything else you want to see for each version?

@neolit123
Copy link
Member

/cc @kubernetes/sig-api-machinery-pr-reviews

@k8s-ci-robot k8s-ci-robot added the sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label Jul 8, 2018
@fedebongio
Copy link
Contributor

/assign @tallclair

@tallclair
Copy link
Member

/assign @x13n

@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jul 10, 2018
return false, err
}

noneMissing := true
Copy link
Member

Choose a reason for hiding this comment

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

s/noneMissing/allFound/? Double negation is harder to read.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

}

expectedEvents := []auditEvent{}
for _, t := range testCases {
Copy link
Member

Choose a reason for hiding this comment

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

What's the point of iterating over 1 statically defined element? Especially since you're merging all expectedEvents together anyway?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@CaoShuFeng CaoShuFeng force-pushed the audit_v1_stable branch 2 times, most recently from 8cbc252 to 11b2e75 Compare July 11, 2018 02:26
@x13n
Copy link
Member

x13n commented Jul 11, 2018

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 11, 2018
@@ -108,17 +89,20 @@ var expectedPolicy = &audit.Policy{
}},
}

func TestParserV1alpha1(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

where did this go? Same for the beta variant.

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 merged three versions into a loop.

Copy link
Contributor

Choose a reason for hiding this comment

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

looks good 👍

@@ -139,7 +140,7 @@ func NewAuditOptions() *AuditOptions {
BatchConfig: pluginbuffered.NewDefaultBatchConfig(),
},
TruncateOptions: NewAuditTruncateOptions(),
GroupVersionString: "audit.k8s.io/v1beta1",
GroupVersionString: "audit.k8s.io/v1",
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this mean we call out using v1 objects by default after this? Do we have an upgrade policy for this kind of changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does this mean we call out using v1 objects by default after this?

Yes.

Do we have an upgrade policy for this kind of changes?

I remembered that we don't support group version when upgrade from alpha to beta.
Or we still use v1beta1 here, and use v1 in the next release?

Copy link
Contributor

Choose a reason for hiding this comment

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

Or we still use v1beta1 here, and use v1 in the next release?

Yes, this is what I had in mind.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 17, 2018
@CaoShuFeng CaoShuFeng force-pushed the audit_v1_stable branch 3 times, most recently from db72587 to 858e450 Compare July 31, 2018 03:09
@CaoShuFeng
Copy link
Contributor Author

/test pull-kubernetes-integration

@CaoShuFeng
Copy link
Contributor Author

/test pull-kubernetes-e2e-gce

@tallclair
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 31, 2018
@tallclair
Copy link
Member

/assign @sttts
For approval. I'll track down another top-level approver for the remaining packages.

@sttts
Copy link
Contributor

sttts commented Aug 8, 2018

/approve

@sttts
Copy link
Contributor

sttts commented Aug 8, 2018

Overriding approval as only the openapi BUILD file is changed.

@sttts sttts added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 8, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by: CaoShuFeng, sttts, tallclair, x13n

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit 28b2b21 into kubernetes:master Aug 8, 2018
k8s-github-robot pushed a commit that referenced this pull request Aug 10, 2018
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

use v1 version of advanced audit policy in kubeadm

audit api version has been updated to v1 #65891 

**Release note**:
```release-note
kubeadm uses audit policy v1 instead of v1beta1
```
@jimangel
Copy link
Member

@CaoShuFeng does this need docs for the 1.12 release? It looks like it's just a api version change in some of the configs, I'm not sure if v1beta1 / v1 is explicitly mentioned anywhere in related documentation.

@CaoShuFeng
Copy link
Contributor Author

@jimangel

All necessary information is contained in release note.

mfojtik pushed a commit to mfojtik/kubernetes that referenced this pull request Aug 21, 2018
…a1Tov1_kubemark

Automatic merge from submit-queue (batch tested with PRs 67332, 66737, 67281, 67173). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

use v1 version of advanced audit policy in kubemark

audit api version has been updated to v1 kubernetes#65891 

**Release note**:
```release-note
NONE
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Advanced Auditing 1.12 umbrella bug
10 participants