-
-
Notifications
You must be signed in to change notification settings - Fork 25
internal/ctlog: evict low priority entries from pool under load #56
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -118,7 +118,7 @@ func (l *Log) addPreChain(rw http.ResponseWriter, r *http.Request) { | |
|
|
||
| func (l *Log) addChainOrPreChain(ctx context.Context, reqBody io.ReadCloser, checkType func(*PendingLogEntry) error) (response []byte, code int, err error) { | ||
| labels := prometheus.Labels{"error": "", "issuer": "", "root": "", "reused": "", | ||
| "precert": "", "preissuer": "", "chain_len": "", "source": ""} | ||
| "precert": "", "preissuer": "", "chain_len": "", "low_priority": "", "source": ""} | ||
| defer func() { | ||
| if err != nil { | ||
| labels["error"] = errorCategory(err) | ||
|
|
@@ -147,9 +147,11 @@ func (l *Log) addChainOrPreChain(ctx context.Context, reqBody io.ReadCloser, che | |
| if err != nil { | ||
| return nil, http.StatusBadRequest, fmtErrorf("invalid chain: %w", err) | ||
| } | ||
| lowPriority := lowPriority(chain[0]) | ||
| labels["chain_len"] = fmt.Sprintf("%d", len(chain)) | ||
| labels["root"] = x509util.NameToString(chain[len(chain)-1].Subject) | ||
| labels["issuer"] = x509util.NameToString(chain[0].Issuer) | ||
| labels["low_priority"] = fmt.Sprintf("%v", lowPriority) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is printing a function value into a metric, should be converted to boolean 1/0 or a reason code (AlreadyHasSCT)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is adding a label which to the labels set with a value of the boolean lowPriority, which will get you a separate time series. The resulting metric looks like: Note the So this code is corrrect, though perhaps it's worth considering using a different variable name than the function name it will shadow There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I somehow thought that was a lookup in the pool map rather than recomputation of the low priority criteria |
||
|
|
||
| e := &PendingLogEntry{Certificate: chain[0].Raw} | ||
| for _, issuer := range chain[1:] { | ||
|
|
@@ -195,14 +197,17 @@ func (l *Log) addChainOrPreChain(ctx context.Context, reqBody io.ReadCloser, che | |
| return nil, http.StatusBadRequest, err | ||
| } | ||
|
|
||
| waitLeaf, source := l.addLeafToPool(ctx, e) | ||
| waitLeaf, source := l.addLeafToPool(ctx, e, lowPriority) | ||
| labels["source"] = source | ||
| waitTimer := prometheus.NewTimer(l.m.AddChainWait) | ||
| seq, err := waitLeaf(ctx) | ||
| if source == "sequencer" { | ||
| if source == "sequencer" && err != errEvicted { | ||
| waitTimer.ObserveDuration() | ||
| } | ||
| if err == errPoolFull { | ||
| if err == errEvicted { | ||
| labels["source"] = "evicted" | ||
| } | ||
| if err == errPoolFull || err == errEvicted { | ||
| return nil, http.StatusServiceUnavailable, err | ||
| } else if errors.As(err, new(SunsetLogError)) { | ||
| return nil, http.StatusGone, err | ||
|
|
@@ -236,6 +241,19 @@ func (l *Log) addChainOrPreChain(ctx context.Context, reqBody io.ReadCloser, che | |
| return rsp, http.StatusOK, nil | ||
| } | ||
|
|
||
| func lowPriority(c *x509.Certificate) bool { | ||
| if isPrecert, _ := ctfe.IsPrecertificate(c); isPrecert { | ||
| // The BRs allow at most 48 hours of backdating. A precertificate older | ||
| // than that can't turn into a valid certificate anymore, so it must be | ||
| // cross-posted. | ||
| return time.Since(c.NotBefore) >= 48*time.Hour | ||
| } | ||
| // If a certificate has SCTs, it's already been logged. It'd be better to | ||
| // verify the signatures, but this check is meant for when we are under load | ||
| // and need to prioritize. | ||
| return len(c.SCTList.SCTList) > 0 | ||
| } | ||
|
|
||
| func (l *Log) getRoots(rw http.ResponseWriter, r *http.Request) { | ||
| roots := l.rootPool().RawCertificates() | ||
| var res struct { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.