Skip to content

Commit

Permalink
gateways to count (GET, PUT, DELETE) errors; skip logging
Browse files Browse the repository at this point in the history
* with authn enabled, 401/403 codes may be happening much more frequently
  - with the potential to quickly generate megabytes of log records
  - thus, making an exception
* on the related note, proxies must also count (GET, PUT, DELETE) errors

Signed-off-by: Alex Aizman <[email protected]>
  • Loading branch information
alex-aizman committed Sep 23, 2024
1 parent 7e928e5 commit 327bcc8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
8 changes: 8 additions & 0 deletions ais/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,7 @@ func (p *proxy) httpobjget(w http.ResponseWriter, r *http.Request, origURLBck ..
objName := apireq.items[1]
apiReqFree(apireq)
if err != nil {
p.statsT.IncErr(stats.ErrGetCount)
return
}

Expand All @@ -743,6 +744,7 @@ func (p *proxy) httpobjget(w http.ResponseWriter, r *http.Request, origURLBck ..
smap := p.owner.smap.get()
tsi, netPub, err := smap.HrwMultiHome(bck.MakeUname(objName))
if err != nil {
p.statsT.IncErr(stats.ErrGetCount)
p.writeErr(w, r, err)
return
}
Expand All @@ -761,6 +763,7 @@ func (p *proxy) httpobjget(w http.ResponseWriter, r *http.Request, origURLBck ..
func (p *proxy) httpobjput(w http.ResponseWriter, r *http.Request, apireq *apiRequest) {
var (
nodeID string
errcnt = stats.ErrPutCount
perms apc.AccessAttrs
)
// 1. request
Expand All @@ -772,6 +775,7 @@ func (p *proxy) httpobjput(w http.ResponseWriter, r *http.Request, apireq *apiRe
perms = apc.AcePUT
} else {
perms = apc.AceAPPEND
errcnt = stats.ErrAppendCount
if apireq.dpq.apnd.hdl != "" {
items, err := preParse(apireq.dpq.apnd.hdl) // apc.QparamAppendHandle
if err != nil {
Expand All @@ -795,6 +799,7 @@ func (p *proxy) httpobjput(w http.ResponseWriter, r *http.Request, apireq *apiRe
bck, err := bckArgs.initAndTry()
freeBctx(bckArgs)
if err != nil {
p.statsT.IncErr(errcnt)
return
}

Expand All @@ -809,11 +814,13 @@ func (p *proxy) httpobjput(w http.ResponseWriter, r *http.Request, apireq *apiRe
if nodeID == "" {
tsi, netPub, err = smap.HrwMultiHome(bck.MakeUname(objName))
if err != nil {
p.statsT.IncErr(errcnt)
p.writeErr(w, r, err)
return
}
} else {
if tsi = smap.GetTarget(nodeID); tsi == nil {
p.statsT.IncErr(errcnt)
err = &errNodeNotFound{"PUT failure:", nodeID, p.si, smap}
p.writeErr(w, r, err)
return
Expand Down Expand Up @@ -861,6 +868,7 @@ func (p *proxy) httpobjdelete(w http.ResponseWriter, r *http.Request) {
smap := p.owner.smap.get()
tsi, err := smap.HrwName2T(bck.MakeUname(objName))
if err != nil {
p.statsT.IncErr(stats.ErrDeleteCount)
p.writeErr(w, r, err)
return
}
Expand Down
13 changes: 10 additions & 3 deletions ais/prxbck.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (p *proxy) a2u(aliasOrUUID string) string {
}

// initialize bucket and check access permissions
func (bctx *bctx) init() (ecode int, err error) {
func (bctx *bctx) init() (_ int, err error) {
debug.Assert(bctx.bck != nil)

bck := bctx.bck
Expand Down Expand Up @@ -142,8 +142,7 @@ func (bctx *bctx) init() (ecode int, err error) {
}
bctx.perms = dtor.Access
}
ecode, err = bctx.accessAllowed(bck)
return
return bctx.accessAllowed(bck)
}

// returns true when operation requires the 'perm' type access
Expand Down Expand Up @@ -196,6 +195,14 @@ func (bctx *bctx) initAndTry() (bck *meta.Bck, err error) {
return
}
if ecode != http.StatusNotFound {
// user GET and PUT requests: making a _silent_ exception for assorted error codes
// (counting them via stats.IncErr though)
if bctx.perms == apc.AceGET || bctx.perms == apc.AcePUT {
if ecode == http.StatusUnauthorized || ecode == http.StatusForbidden {
bctx.p.writeErr(bctx.w, bctx.r, err, ecode, Silent)
return
}
}
bctx.p.writeErr(bctx.w, bctx.r, err, ecode)
return
}
Expand Down

0 comments on commit 327bcc8

Please sign in to comment.