Skip to content
This repository has been archived by the owner on Mar 5, 2024. It is now read-only.

Record pod events for all server calls #122

Merged
merged 4 commits into from
Jul 16, 2018
Merged

Conversation

samb1729
Copy link
Contributor

Resolves #14

Copy link
Contributor

@pingles pingles left a comment

Choose a reason for hiding this comment

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

Thanks again!

I've made a few inline comments

@@ -96,15 +96,20 @@ func (k *KiamServer) GetPodCredentials(ctx context.Context, req *pb.GetPodCreden

if !decision.IsAllowed() {
logger.WithField("policy.explanation", decision.Explanation()).Errorf("pod denied by policy")
k.recordEvent(pod, v1.EventTypeWarning, "KiamRoleForbidden",
Copy link
Contributor

Choose a reason for hiding this comment

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

In this event we should also be able to use decision.Explanation() to include more information about why it was rejected.

return nil, err
}

k.recordEvent(pod, v1.EventTypeNormal, "KiamCredentialIssued", "issued credentials")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd want to check our metrics but I have a feeling this could get called a lot. Does the Event API already guard against logging the same message over and over? Don't want to do something that DDoS the API server/etcd :)

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 suppose neither of these Normal events is necessary now I think about it. The fact the pod is running without issue shows things are normal.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess if it's possible to only have credentials, or an error, then its safe to remove.

One upside to include is that if people don't see any errors, or successful messages they'll know that the annotation was misspelt/missing etc.


logger.WithField("pod.iam.role", role).Infof("found role")
k.eventRecorder.Event(ref, v1.EventTypeNormal, "KiamRoleFound",
fmt.Sprintf("Role: %q found for pod: %q", role, pod.Name))
k.recordEvent(pod, v1.EventTypeNormal, "KiamRoleFound",
Copy link
Contributor

Choose a reason for hiding this comment

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

As above, I'd want to know we could do this without risk of DDoS'ing the API server and etcd- I think these endpoints will get called a lot.

@codecov
Copy link

codecov bot commented Jul 16, 2018

Codecov Report

Merging #122 into master will increase coverage by 0.9%.
The diff coverage is 62.5%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #122     +/-   ##
=========================================
+ Coverage   37.42%   38.32%   +0.9%     
=========================================
  Files          21       21             
  Lines         799      801      +2     
=========================================
+ Hits          299      307      +8     
+ Misses        472      466      -6     
  Partials       28       28
Impacted Files Coverage Δ
pkg/server/server.go 18.97% <62.5%> (+3.42%) ⬆️
pkg/prefetch/manager.go 53.48% <0%> (+6.97%) ⬆️

@pingles
Copy link
Contributor

pingles commented Jul 16, 2018

Nice, thanks @Sambooo.

Could you update the RBAC configuration in /deploy/server-rbac.yaml please? It'll need additional permissions to write events.

@pingles
Copy link
Contributor

pingles commented Jul 16, 2018

Then I think we're in a place to merge and close #14, happy days!

@pingles pingles merged commit 5534bde into master Jul 16, 2018
@pingles pingles deleted the record-iam-errors-as-events branch July 16, 2018 15:42
mbarrien pushed a commit to mbarrien/helm-kiam that referenced this pull request Sep 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants