Skip to content

Commit 6b60a3f

Browse files
Merge pull request #2443 from ricardomaraschini/OCPBUGS-56594
OCPBUGS-56594: UPSTREAM: <carry>: backporting fix for concurrent map iteration and write
2 parents bc561b2 + f96a151 commit 6b60a3f

File tree

20 files changed

+1023
-317
lines changed

20 files changed

+1023
-317
lines changed

pkg/registry/core/serviceaccount/storage/storage_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func TestCreate_Token_SetsCredentialIDAuditAnnotation(t *testing.T) {
144144
}
145145

146146
auditContext := audit.AuditContextFrom(ctx)
147-
issuedCredentialID, ok := auditContext.Event.Annotations["authentication.kubernetes.io/issued-credential-id"]
147+
issuedCredentialID, ok := auditContext.GetEventAnnotation("authentication.kubernetes.io/issued-credential-id")
148148
if !ok || len(issuedCredentialID) == 0 {
149149
t.Errorf("did not find issued-credential-id in audit event annotations")
150150
}

staging/src/k8s.io/apiserver/pkg/admission/audit.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,17 @@ func ensureAnnotationGetter(a Attributes) error {
8383
}
8484

8585
func (handler *auditHandler) logAnnotations(ctx context.Context, a Attributes) {
86-
ae := audit.AuditEventFrom(ctx)
86+
ae := audit.AuditContextFrom(ctx)
8787
if ae == nil {
8888
return
8989
}
9090

9191
var annotations map[string]string
9292
switch a := a.(type) {
9393
case privateAnnotationsGetter:
94-
annotations = a.getAnnotations(ae.Level)
94+
annotations = a.getAnnotations(ae.GetEventLevel())
9595
case AnnotationsGetter:
96-
annotations = a.GetAnnotations(ae.Level)
96+
annotations = a.GetAnnotations(ae.GetEventLevel())
9797
default:
9898
// this will never happen, because we have already checked it in ensureAnnotationGetter
9999
}

staging/src/k8s.io/apiserver/pkg/admission/audit_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,10 @@ func TestWithAudit(t *testing.T) {
144144
var handler Interface = fakeHandler{tc.admit, tc.admitAnnotations, tc.validate, tc.validateAnnotations, tc.handles}
145145
ctx := audit.WithAuditContext(context.Background())
146146
ac := audit.AuditContextFrom(ctx)
147-
ae := &ac.Event
148-
ae.Level = auditinternal.LevelMetadata
147+
if err := ac.Init(audit.RequestAuditConfig{Level: auditinternal.LevelMetadata}, nil); err != nil {
148+
t.Fatal(err)
149+
}
150+
149151
auditHandler := WithAudit(handler)
150152
a := attributes()
151153

@@ -171,9 +173,9 @@ func TestWithAudit(t *testing.T) {
171173
annotations[k] = v
172174
}
173175
if len(annotations) == 0 {
174-
assert.Nil(t, ae.Annotations, tcName+": unexptected annotations set in audit event")
176+
assert.Nil(t, ac.GetEventAnnotations(), tcName+": unexptected annotations set in audit event")
175177
} else {
176-
assert.Equal(t, annotations, ae.Annotations, tcName+": unexptected annotations set in audit event")
178+
assert.Equal(t, annotations, ac.GetEventAnnotations(), tcName+": unexptected annotations set in audit event")
177179
}
178180
}
179181
}
@@ -187,8 +189,6 @@ func TestWithAuditConcurrency(t *testing.T) {
187189
}
188190
var handler Interface = fakeHandler{admitAnnotations: admitAnnotations, handles: true}
189191
ctx := audit.WithAuditContext(context.Background())
190-
ac := audit.AuditContextFrom(ctx)
191-
ac.Event.Level = auditinternal.LevelMetadata
192192
auditHandler := WithAudit(handler)
193193
a := attributes()
194194

0 commit comments

Comments
 (0)