Skip to content

Commit ad3392b

Browse files
committed
BUG/MINOR: Fix option redispatch serialization
When the redispatch interval is set to zero, remove the option from the configuration.
1 parent bbbe085 commit ad3392b

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

configuration/backend_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,10 @@ func TestCreateEditDeleteBackend(t *testing.T) {
825825
{Name: "test_errors_all"},
826826
},
827827
Disabled: true,
828+
Redispatch: &models.Redispatch{
829+
Enabled: misc.StringP("enabled"),
830+
Interval: 0,
831+
},
828832
}
829833

830834
err := clientTest.CreateBackend(b, "", version)
@@ -839,6 +843,9 @@ func TestCreateEditDeleteBackend(t *testing.T) {
839843
t.Error(err.Error())
840844
}
841845

846+
// A redispatch with a zero interval is automatically removed from configuration.
847+
b.Redispatch = nil
848+
842849
var givenJSONB []byte
843850
givenJSONB, err = b.MarshalBinary()
844851
if err != nil {

configuration/configuration.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2443,6 +2443,9 @@ func (s *SectionObject) redispatch(field reflect.Value) error {
24432443
if *br.Enabled == "disabled" {
24442444
d.NoOption = true
24452445
}
2446+
if br.Interval == 0 {
2447+
d = nil
2448+
}
24462449
if err := s.set("option redispatch", d); err != nil {
24472450
return err
24482451
}

0 commit comments

Comments
 (0)