Skip to content

Commit

Permalink
Merge #137766
Browse files Browse the repository at this point in the history
137766: rac2,kvflowcontrol: fix redaction safety for a few types r=sumeerbhola a=pav-kv

Part of #136526

Co-authored-by: Pavel Kalinnikov <[email protected]>
  • Loading branch information
craig[bot] and pav-kv committed Dec 19, 2024
2 parents 5bafc8a + acb087d commit e669985
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 42 deletions.
10 changes: 1 addition & 9 deletions pkg/kv/kvserver/kvflowcontrol/kvflowcontrolpb/kvflowcontrol.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,6 @@ func (a AdmittedRaftLogEntries) SafeFormat(w redact.SafePrinter, _ rune) {
a.RangeID, a.StoreID, admissionpb.WorkPriority(a.AdmissionPriority), a.UpToRaftLogPosition)
}

func (a AdmittedResponseForRange) String() string {
return redact.StringWithoutMarkers(a)
}

func (a AdmittedResponseForRange) SafeFormat(w redact.SafePrinter, _ rune) {
w.Printf("admitted-response (s%s r%s %s)", a.LeaderStoreID, a.RangeID, a.Msg.String())
}

func (a AdmittedState) String() string {
return redact.StringWithoutMarkers(a)
}
Expand All @@ -71,5 +63,5 @@ func (a PiggybackedAdmittedState) String() string {

func (a PiggybackedAdmittedState) SafeFormat(w redact.SafePrinter, _ rune) {
w.Printf("[r%s,s%s,%d->%d] %s",
a.RangeID, a.ToStoreID, a.FromReplicaID, a.ToReplicaID, a.Admitted.String())
a.RangeID, a.ToStoreID, a.FromReplicaID, a.ToReplicaID, a.Admitted)
}
22 changes: 0 additions & 22 deletions pkg/kv/kvserver/kvflowcontrol/kvflowcontrolpb/kvflowcontrol.proto
Original file line number Diff line number Diff line change
Expand Up @@ -125,28 +125,6 @@ message RaftLogPosition {
uint64 index = 2;
}

// AdmittedResponseForRange is only used in RACv2. It contains a MsgAppResp
// from a follower to a leader, that was generated to advance the admitted
// vector for that follower, maintained by the leader.
//
// TODO(pav-kv): remove this type and use PiggybackedAdmittedState.
message AdmittedResponseForRange {
option (gogoproto.goproto_stringer) = false;

// LeaderStoreID is used to route the request when this message is received
// at the leader node.
uint64 leader_store_id = 1 [(gogoproto.customname) = "LeaderStoreID",
(gogoproto.casttype) = "github.com/cockroachdb/cockroach/pkg/roachpb.StoreID"];

// RangeID of the raft group to which the MsgAppResp is directed. Used for
// routing at the leader node.
int64 range_id = 2 [(gogoproto.customname) = "RangeID",
(gogoproto.casttype) = "github.com/cockroachdb/cockroach/pkg/roachpb.RangeID"];

// Msg is the MsgAppResp containing the admitted vector.
raftpb.Message msg = 3 [(gogoproto.nullable) = false];
}

// AdmittedState communicates a replica's vector of admitted log indices at
// different priorities to the leader of a range.
//
Expand Down
6 changes: 3 additions & 3 deletions pkg/kv/kvserver/kvflowcontrol/rac2/log_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ func (av AdmittedVector) SafeFormat(w redact.SafePrinter, _ rune) {
buf.Printf("term:%d, admitted:[", av.Term)
for pri, index := range av.Admitted {
if pri > 0 {
buf.Printf(",")
buf.SafeRune(',')
}
buf.Printf("%s:%d", raftpb.Priority(pri), index)
}
buf.Printf("]")
w.Printf("%v", buf)
buf.SafeRune(']')
w.SafeString(redact.SafeString(buf.String()))
}

// LogTracker tracks the durable and logically admitted state of a raft log.
Expand Down
8 changes: 4 additions & 4 deletions pkg/raft/raftpb/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ func (p Priority) String() string {
func (p Priority) SafeFormat(w redact.SafePrinter, _ rune) {
switch p {
case LowPri:
w.Printf("LowPri")
w.SafeString("LowPri")
case NormalPri:
w.Printf("NormalPri")
w.SafeString("NormalPri")
case AboveNormalPri:
w.Printf("AboveNormalPri")
w.SafeString("AboveNormalPri")
case HighPri:
w.Printf("HighPri")
w.SafeString("HighPri")
default:
panic("invalid raft priority")
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/util/admission/admissionpb/admissionpb.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (w WorkPriority) String() string {
// SafeFormat implements the redact.SafeFormatter interface.
func (w WorkPriority) SafeFormat(p redact.SafePrinter, verb rune) {
if s, ok := WorkPriorityDict[w]; ok {
p.Print(s)
p.SafeString(redact.SafeString(s))
return
}
p.Printf("custom-pri=%d", int8(w))
Expand Down Expand Up @@ -232,11 +232,11 @@ func (w WorkClass) String() string {
func (w WorkClass) SafeFormat(p redact.SafePrinter, verb rune) {
switch w {
case RegularWorkClass:
p.Printf("regular")
p.SafeString("regular")
case ElasticWorkClass:
p.Printf("elastic")
p.SafeString("elastic")
default:
p.Printf("<unknown-class>")
p.SafeString("<unknown-class>")
}
}

Expand Down

0 comments on commit e669985

Please sign in to comment.