Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
* [BUGFIX] Ring: Ignore READONLY ingesters when assigning tokens so the active series remain balanced. #7946
* [BUGFIX] Distributor: Fix a `panic: send on closed channel` crash during shutdown when `-distributor.num-push-workers` or `-distributor.num-query-workers` is greater than 0. #7964
* [BUGFIX] Ring: Fix `DoBatch` counting a key more than once when more replicas than the quorum succeed, which in rare cases could hide a write error from a key that did not reach quorum. A distributor push now always waits until every series reaches quorum, so it returns the error of a series that misses quorum, and takes as long as its slowest series to reach quorum. #7975
* [BUGFIX] Alertmanager: Fix per-tenant `alertmanager_receivers_firewall_block_cidr_networks` overrides being appended to the global default list instead of replacing it, so CIDRs a tenant left out of its list stayed blocked. #7831

## 1.22.0 2026-11-19

Expand Down
8 changes: 5 additions & 3 deletions pkg/util/flagext/cidr.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,19 @@ func (c CIDRSliceCSV) String() string {

// Set implements flag.Value
func (c *CIDRSliceCSV) Set(s string) error {
parts := strings.SplitSeq(s, ",")
// Build into a fresh slice so the value replaces the previous one and a bad entry leaves it untouched.
var values CIDRSliceCSV

for part := range parts {
for part := range strings.SplitSeq(s, ",") {
cidr := &CIDR{}
if err := cidr.Set(part); err != nil {
return errors.Wrapf(err, "cidr: %s", part)
}

*c = append(*c, *cidr)
values = append(values, *cidr)
}

*c = values
return nil
}

Expand Down
18 changes: 18 additions & 0 deletions pkg/util/flagext/cidr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v2"
)

Expand Down Expand Up @@ -49,3 +50,20 @@ func Test_CIDRSliceCSV_YamlMarshalling(t *testing.T) {
})
}
}

func Test_CIDRSliceCSV_SetReplacesPreviousValue(t *testing.T) {
c := CIDRSliceCSV{}
require.NoError(t, c.Set("10.0.0.0/8,192.168.0.0/16"))
require.NoError(t, c.Set("172.16.0.0/12"))

assert.Equal(t, "172.16.0.0/12", c.String())
}

func Test_CIDRSliceCSV_SetDoesNotMutateOnError(t *testing.T) {
c := CIDRSliceCSV{}
require.NoError(t, c.Set("10.0.0.0/8"))

// The first entry parses, the second one doesn't: the value must be left untouched.
require.Error(t, c.Set("192.168.0.0/16,not-a-cidr"))
assert.Equal(t, "10.0.0.0/8", c.String())
}
22 changes: 22 additions & 0 deletions pkg/util/validation/limits_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1376,3 +1376,25 @@ func TestCloseIdleTSDBTimeout_OverridesAccessor(t *testing.T) {
assert.Equal(t, time.Duration(0), ov.CloseIdleTSDBTimeout("tenant-with-zero"))
assert.Equal(t, time.Duration(0), ov.CloseIdleTSDBTimeout("unknown-tenant"))
}

func TestAlertmanagerReceiversBlockCIDRNetworksPerTenantOverrideReplacesDefault(t *testing.T) {
defaults := Limits{}
require.NoError(t, defaults.AlertmanagerReceiversBlockCIDRNetworks.Set("10.0.0.0/8,192.168.0.0/16"))
SetDefaultLimitsForYAMLUnmarshalling(defaults)
t.Cleanup(func() { SetDefaultLimitsForYAMLUnmarshalling(Limits{}) })

tenantLimits := map[string]*Limits{}
require.NoError(t, yaml.Unmarshal([]byte(`
user1:
alertmanager_receivers_firewall_block_cidr_networks: 172.16.0.0/12
`), &tenantLimits))

ov := NewOverrides(defaults, newMockTenantLimits(tenantLimits))

blocked := []string{}
for _, c := range ov.AlertmanagerReceiversBlockCIDRNetworks("user1") {
blocked = append(blocked, c.String())
}

assert.Equal(t, []string{"172.16.0.0/12"}, blocked)
}