Merge pull request #2650 from nats-io/issue-2633

[FIXED] #2633
This commit is contained in:
Derek Collison
2021-10-27 15:34:05 -07:00
committed by GitHub
2 changed files with 17 additions and 5 deletions

View File

@@ -8902,7 +8902,7 @@ func TestJetStreamSeal(t *testing.T) {
}
si := sir.StreamInfo
if !si.Config.Sealed {
t.Fatalf("Expetced the stream to be marked sealed, got %+v\n", si.Config)
t.Fatalf("Expected the stream to be marked sealed, got %+v\n", si.Config)
}
// Make sure we also updated any max age and moved to discard new.
if si.Config.MaxAge != 0 {
@@ -8911,6 +8911,16 @@ func TestJetStreamSeal(t *testing.T) {
if si.Config.Discard != DiscardNew {
t.Fatalf("Expected DiscardPolicy to be set to new, got %v", si.Config.Discard)
}
// Also make sure we set denyDelete and denyPurge.
if !si.Config.DenyDelete {
t.Fatalf("Expected the stream to be marked as DenyDelete, got %+v\n", si.Config)
}
if !si.Config.DenyPurge {
t.Fatalf("Expected the stream to be marked as DenyPurge, got %+v\n", si.Config)
}
if si.Config.AllowRollup {
t.Fatalf("Expected the stream to be marked as not AllowRollup, got %+v\n", si.Config)
}
// Sealing is not reversible, so make sure we get an error trying to undo.
sur = updateStream(t, nc, &StreamConfig{Name: "SEALED", Replicas: replicas, Storage: MemoryStorage, Sealed: false})

View File

@@ -61,14 +61,14 @@ type StreamConfig struct {
// Optional qualifiers. These can not be modified after set to true.
// Sealed will seal a stream so no messages can get out or in.
Sealed bool `json:"sealed,omitempty"`
Sealed bool `json:"sealed"`
// DenyDelete will restrict the ability to delete messages.
DenyDelete bool `json:"deny_delete,omitempty"`
DenyDelete bool `json:"deny_delete"`
// DenyPurge will restrict the ability to purge messages.
DenyPurge bool `json:"deny_purge,omitempty"`
DenyPurge bool `json:"deny_purge"`
// AllowRollup allows messages to be placed into the system and purge
// all older messages using a special msg header.
AllowRollup bool `json:"allow_rollup_hdrs,omitempty"`
AllowRollup bool `json:"allow_rollup_hdrs"`
}
// JSPubAckResponse is a formal response to a publish operation.
@@ -935,6 +935,8 @@ func (jsa *jsAccount) configUpdateCheck(old, new *StreamConfig) (*StreamConfig,
if cfg.Sealed {
cfg.MaxAge = 0
cfg.Discard = DiscardNew
cfg.DenyDelete, cfg.DenyPurge = true, true
cfg.AllowRollup = false
}
// Check limits.