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

canary for equals-fold jwt changes #5949

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/google/go-tpm v0.9.0
github.com/klauspost/compress v1.17.10
github.com/minio/highwayhash v1.0.3
github.com/nats-io/jwt/v2 v2.6.0
github.com/nats-io/jwt/v2 v2.7.1-0.20241001165941-a8b5dfe63b01
github.com/nats-io/nats.go v1.36.0
github.com/nats-io/nkeys v0.4.7
github.com/nats-io/nuid v1.0.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ github.com/klauspost/compress v1.17.10 h1:oXAz+Vh0PMUvJczoi+flxpnBEPxoER1IaAnU/N
github.com/klauspost/compress v1.17.10/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
github.com/minio/highwayhash v1.0.3 h1:kbnuUMoHYyVl7szWjSxJnxw11k2U709jqFPPmIUyD6Q=
github.com/minio/highwayhash v1.0.3/go.mod h1:GGYsuwP/fPD6Y9hMiXuapVvlIUEhFhMTh0rxU3ik1LQ=
github.com/nats-io/jwt/v2 v2.6.0 h1:yXoBTdEotZw3NujMT+Nnu1UPNlFWdKQ3d0JJF/+pJag=
github.com/nats-io/jwt/v2 v2.6.0/go.mod h1:ZdWS1nZa6WMZfFwwgpEaqBV8EPGVgOTDHN/wTbz0Y5A=
github.com/nats-io/jwt/v2 v2.7.1-0.20241001165941-a8b5dfe63b01 h1:49bog2/jTEFtkzt3T4nXVGV5ZgTQ7Z9Pn9hWbj8IoM0=
github.com/nats-io/jwt/v2 v2.7.1-0.20241001165941-a8b5dfe63b01/go.mod h1:ZdWS1nZa6WMZfFwwgpEaqBV8EPGVgOTDHN/wTbz0Y5A=
github.com/nats-io/nats.go v1.36.0 h1:suEUPuWzTSse/XhESwqLxXGuj8vGRuPRoG7MoRN/qyU=
github.com/nats-io/nats.go v1.36.0/go.mod h1:Ubdu4Nh9exXdSz0RVWRFBbRfrbSxOYd26oF0wkWclB8=
github.com/nats-io/nkeys v0.4.7 h1:RwNJbbIdYCoClSDNY7QVKZlyb/wfT6ugvFCiKy6vDvI=
Expand Down
2 changes: 1 addition & 1 deletion server/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -1965,7 +1965,7 @@ func (s *Server) filterRequest(fOpts *EventFilterOptions) bool {
if len(fOpts.Tags) > 0 {
opts := s.getOpts()
for _, t := range fOpts.Tags {
if !opts.Tags.Contains(t) {
if !opts.Tags.ContainsEqualsFold(t) {
return true
}
}
Expand Down
2 changes: 1 addition & 1 deletion server/jetstream_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -2697,7 +2697,7 @@ func (s *Server) jsLeaderServerStreamCancelMoveRequest(sub *subscription, c *cli
}
nodeTags := si.(nodeInfo).tags
for _, tag := range cfg.Placement.Tags {
if !nodeTags.Contains(tag) {
if !nodeTags.ContainsEqualsFold(tag) {
// clear placement as tags don't match
cfg.Placement = nil
break FOR_TAGCHECK
Expand Down
4 changes: 2 additions & 2 deletions server/jetstream_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -5858,7 +5858,7 @@ func (cc *jetStreamCluster) selectPeerGroup(r int, cluster string, cfg *StreamCo
continue
}

if ni.tags.Contains(jsExcludePlacement) {
if ni.tags.ContainsEqualsFold(jsExcludePlacement) {
s.Debugf("Peer selection: discard %s@%s tags: %v reason: %s present",
ni.name, ni.cluster, ni.tags, jsExcludePlacement)
err.excludeTag = true
Expand All @@ -5868,7 +5868,7 @@ func (cc *jetStreamCluster) selectPeerGroup(r int, cluster string, cfg *StreamCo
if len(tags) > 0 {
matched := true
for _, t := range tags {
if !ni.tags.Contains(t) {
if !ni.tags.ContainsEqualsFold(t) {
matched = false
s.Debugf("Peer selection: discard %s@%s tags: %v reason: mandatory tag %s not present",
ni.name, ni.cluster, ni.tags, t)
Expand Down
16 changes: 13 additions & 3 deletions server/jetstream_cluster_1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3743,7 +3743,7 @@ func TestJetStreamClusterPeerExclusionTag(t *testing.T) {

v, err := srv.Varz(nil)
require_NoError(t, err)
require_True(t, v.Tags.Contains(jsExcludePlacement))
require_True(t, v.Tags.ContainsEqualsFold(jsExcludePlacement))
content, err := os.ReadFile(srv.configFile)
require_NoError(t, err)
newContent := strings.ReplaceAll(string(content), fmt.Sprintf(", %s]", jsExcludePlacement), "]")
Expand All @@ -3757,14 +3757,24 @@ func TestJetStreamClusterPeerExclusionTag(t *testing.T) {
require_NoError(t, srv.Reload())
v, err = srv.Varz(nil)
require_NoError(t, err)
require_True(t, !v.Tags.Contains(jsExcludePlacement))
require_True(t, !v.Tags.ContainsEqualsFold(jsExcludePlacement))

// it is possible that sub already received a stasz message prior to reload, retry once
type SI struct {
Server ServerInfo `json:"server"`
}

cmp := false
for i := 0; i < 2 && !cmp; i++ {
m, err := sub.NextMsg(time.Second)
require_NoError(t, err)
cmp = strings.Contains(string(m.Data), `"tags":["server:s-1","intersect"]`)

var si SI
err = json.Unmarshal(m.Data, &si)
require_NoError(t, err)

tl := jwt.TagList(si.Server.Tags)
cmp = tl.ContainsEqualsFold("server:s-1") && tl.ContainsEqualsFold("intersect")
}
require_True(t, cmp)

Expand Down
2 changes: 1 addition & 1 deletion server/monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func TestHandleVarz(t *testing.T) {
if v.Name != "server_-1" {
t.Fatalf("Expected ServerName to be 'monitor_server' got %q", v.Name)
}
if !v.Tags.Contains("tag") {
if !v.Tags.ContainsEqualsFold("tag") {
t.Fatalf("Expected tags to be 'tag' got %v", v.Tags)
}
if v.JetStream.Config == nil {
Expand Down