Merge pull request #48334 from CaoShuFeng/LevelMetadata

Automatic merge from submit-queue (batch tested with PRs 47784, 47793, 48334, 48435, 48354)

update events' ResponseStatus at Metadata level

ResponseStatus is populated in MetadataLevel, so we also update it in
MetadataLevel.

**Release note**:

```
NONE
```
pull/6/head
Kubernetes Submit Queue 2017-07-03 10:41:51 -07:00 committed by GitHub
commit cf9f110387
2 changed files with 6 additions and 4 deletions

View File

@ -100,8 +100,8 @@ type Event struct {
// +optional
ObjectRef *ObjectReference
// The response status, populated even when the ResponseObject is not a Status type.
// For successful responses, this will only include the Code and StatusSuccess.
// For non-status type error responses, this will be auto-populated with the error Message.
// For successful responses, this will only include the Code. For non-status type
// error responses, this will be auto-populated with the error Message.
// +optional
ResponseStatus *metav1.Status

View File

@ -170,14 +170,16 @@ func LogRequestPatch(ae *audit.Event, patch []byte) {
// LogResponseObject fills in the response object into an audit event. The passed runtime.Object
// will be converted to the given gv.
func LogResponseObject(ae *audit.Event, obj runtime.Object, gv schema.GroupVersion, s runtime.NegotiatedSerializer) {
if ae == nil || ae.Level.Less(audit.LevelRequestResponse) {
if ae == nil || ae.Level.Less(audit.LevelMetadata) {
return
}
if status, ok := obj.(*metav1.Status); ok {
ae.ResponseStatus = status
}
if ae.Level.Less(audit.LevelRequestResponse) {
return
}
// TODO(audit): hook into the serializer to avoid double conversion
var err error
ae.ResponseObject, err = encodeObject(obj, gv, s)