Add audit log for decommissioning (#14858)

This commit is contained in:
Anis Elleuch
2022-05-04 08:45:27 +01:00
committed by GitHub
parent 0a256053ee
commit 44a3b58e52
6 changed files with 68 additions and 21 deletions

View File

@@ -1019,12 +1019,14 @@ type AuditLogOptions struct {
APIName string
Status string
VersionID string
Error string
}
// sends audit logs for internal subsystem activity
func auditLogInternal(ctx context.Context, bucket, object string, opts AuditLogOptions) {
entry := audit.NewEntry(globalDeploymentID)
entry.Trigger = opts.Trigger
entry.Error = opts.Error
entry.API.Name = opts.APIName
entry.API.Bucket = bucket
entry.API.Object = object
@@ -1033,6 +1035,11 @@ func auditLogInternal(ctx context.Context, bucket, object string, opts AuditLogO
entry.ReqQuery[xhttp.VersionID] = opts.VersionID
}
entry.API.Status = opts.Status
// Merge tag information if found - this is currently needed for tags
// set during decommissioning.
if reqInfo := logger.GetReqInfo(ctx); reqInfo != nil {
entry.Tags = reqInfo.GetTagsMap()
}
ctx = logger.SetAuditEntry(ctx, &entry)
logger.AuditLog(ctx, nil, nil, nil)
}