Skip to content
This repository was archived by the owner on Mar 10, 2023. It is now read-only.

Commit 39293c6

Browse files
Martin Dekov (VMware)alexellis
authored andcommitted
Add auditing for garbage-collect
Sending events to through auditEvent in the cases when: - deletion of funtions starts - function is not deleted/unable to delete - deletion of functions is finished Signed-off-by: Martin Dekov (VMware) <mdekov@vmware.com>
1 parent 435e2b8 commit 39293c6

3 files changed

Lines changed: 32 additions & 2 deletions

File tree

garbage-collect/Gopkg.lock

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

garbage-collect/handler.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import (
1515
"github.com/openfaas/openfaas-cloud/sdk"
1616
)
1717

18+
const Source = "garbage-collect"
19+
1820
// Handle a serverless request
1921
func Handle(req []byte) string {
2022
validateErr := validateRequest(req)
@@ -51,12 +53,24 @@ func Handle(req []byte) string {
5153

5254
err = deleteFunction(fn.Name, gatewayURL)
5355
if err != nil {
56+
auditEvent := sdk.AuditEvent{
57+
Message: fmt.Sprintf("Unable to delete function: `%s`", fn.Name),
58+
Source: Source,
59+
}
60+
sdk.PostAudit(auditEvent)
61+
5462
log.Println(err)
5563
}
5664
deleted = deleted + 1
5765
}
5866
}
5967

68+
auditEvent := sdk.AuditEvent{
69+
Message: fmt.Sprintf("Garbage collection ran for %s/%s - %d functions deleted.", garbageReq.Owner, garbageReq.Repo, deleted),
70+
Source: Source,
71+
}
72+
sdk.PostAudit(auditEvent)
73+
6074
return fmt.Sprintf("Garbage collection ran for %s/%s - %d functions deleted.", garbageReq.Owner, garbageReq.Repo, deleted)
6175
}
6276

garbage-collect/vendor/github.com/openfaas/openfaas-cloud/sdk/Gopkg.lock

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)