-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent
0
as value for gitClientTimeout
A zero value for the gitClientTimeout setting would mean that the request would not have a client side timeout set, potentially resulting in an endless waiting state. Although it should not happen that this value is missing, which would lead to it being zero, it should be safer to fall back to 30s as in previous versions of Fleet, thereby preventing the user from disabling the git client timeout completely. Follow-up for #2188
- Loading branch information
Showing
4 changed files
with
67 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package config_test | ||
|
||
import ( | ||
"time" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
|
||
v1 "k8s.io/api/core/v1" | ||
|
||
"github.com/rancher/fleet/internal/config" | ||
) | ||
|
||
var _ = Describe("Config", func() { | ||
When("not having set a value for gitClientTimeout", func() { | ||
It("should return the default value", func() { | ||
cfg, err := config.ReadConfig(&v1.ConfigMap{Data: map[string]string{}}) | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(cfg.GitClientTimeout.Duration).To(Equal(30 * time.Second)) | ||
}) | ||
}) | ||
When("having set a value for gitClientTimeout", func() { | ||
It("should return the set value", func() { | ||
jsonConfig := `{"gitClientTimeout": "20s"}` | ||
cfg, err := config.ReadConfig(&v1.ConfigMap{ | ||
Data: map[string]string{ | ||
"config": jsonConfig, | ||
}, | ||
}) | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(cfg.GitClientTimeout.Duration).To(Equal(20 * time.Second)) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package config_test | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
const ( | ||
timeout = 30 * time.Second | ||
) | ||
|
||
func TestFleet(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Config Suite") | ||
} | ||
|
||
var _ = BeforeSuite(func() { | ||
SetDefaultEventuallyTimeout(timeout) | ||
}) |