Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adjust log level for userspace authz #959

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions pkg/auth/rbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,20 @@
}

func (r *Rbac) Run(ctx context.Context, mapOfTuple, mapOfAuth *ebpf.Map) {
if r == nil || mapOfTuple == nil {
log.Error("r or mapOfTuple is nil")
if r == nil {
return

Check warning on line 102 in pkg/auth/rbac.go

View check run for this annotation

Codecov / codecov/patch

pkg/auth/rbac.go#L102

Added line #L102 was not covered by tests
}
if mapOfTuple == nil || mapOfAuth == nil {
log.Error("mapOfTuple or mapOfAuth is nil")

Check warning on line 105 in pkg/auth/rbac.go

View check run for this annotation

Codecov / codecov/patch

pkg/auth/rbac.go#L105

Added line #L105 was not covered by tests
return
}
reader, err := ringbuf.NewReader(mapOfTuple)
if err != nil {
log.Error("open ringbuf map FAILED, err: ", err)
log.Errorf("open mapOfTuple ringbuf err: %v", err)

Check warning on line 110 in pkg/auth/rbac.go

View check run for this annotation

Codecov / codecov/patch

pkg/auth/rbac.go#L110

Added line #L110 was not covered by tests
return
}
defer func() {
if err := reader.Close(); err != nil {
log.Error("reader Close FAILED, err: ", err)
}
_ = reader.Close()
}()

rec := ringbuf.Record{}
Expand All @@ -121,7 +122,7 @@
return
default:
if err = reader.ReadInto(&rec); err != nil {
log.Error("ringbuf reader FAILED to read, err: ", err)
log.Errorf("mapOfTuple read failed: %v", err)

Check warning on line 125 in pkg/auth/rbac.go

View check run for this annotation

Codecov / codecov/patch

pkg/auth/rbac.go#L125

Added line #L125 was not covered by tests
continue
}
if len(rec.RawSample) != MSG_LEN {
Expand All @@ -146,7 +147,7 @@
}

if !r.doRbac(&conn) {
log.Infof("Auth denied for connection: %+v", conn)
log.Debugf("Auth denied for connection: %+v", conn)
// If conn is denied, write tuples into XDP map, which includes source/destination IP/Port
if err = r.notifyFunc(mapOfAuth, msgType, tupleData); err != nil {
log.Error("authmap update FAILED, err: ", err)
Expand Down Expand Up @@ -179,7 +180,7 @@
dstWorkload := r.workloadCache.GetWorkloadByAddr(networkAddress)
// If no workload found, deny
if dstWorkload == nil {
Copy link
Member Author

Choose a reason for hiding this comment

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

@LiZhenCheng9527 I thought about this again, we cannot deny if src workload is not found. And also cannot simply allow if src not found,

Copy link
Collaborator

Choose a reason for hiding this comment

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

So we need to discuss different scenarios of source workload not found.
But how should we distinguish between these scenarios?

Copy link
Member Author

@hzxuzhonghu hzxuzhonghu Oct 15, 2024

Choose a reason for hiding this comment

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

not needed from here, auth should not care whether src workload exist or not if the auth policy is based on ip or port

#961 is the way to ignore kubelet probe traffic

log.Warnf("Auth denied for connection: %v because destination workload not found", conn.dstIp)
log.Debugf("denied for connection: %v because destination workload not found", conn)
return false
}

Expand Down
Loading