Skip to content

Commit 7961b02

Browse files
authored
Add config for packageserver wakeup interval (#298)
Signed-off-by: Todd Short <[email protected]>
1 parent 28c6773 commit 7961b02

File tree

5 files changed

+99
-1
lines changed

5 files changed

+99
-1
lines changed

crds/operators.coreos.com_olmconfigs.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ spec:
4343
disableCopiedCSVs:
4444
description: DisableCopiedCSVs is used to disable OLM's "Copied CSV" feature for operators installed at the cluster scope, where a cluster scoped operator is one that has been installed in an OperatorGroup that targets all namespaces. When reenabled, OLM will recreate the "Copied CSVs" for each cluster scoped operator.
4545
type: boolean
46+
packageServerSyncInterval:
47+
description: PackageServerSyncInterval is used to define the sync interval for packagerserver pods. Packageserver pods periodically check the status of CatalogSources; this specifies the period using duration format (e.g. "60m"). For this parameter, only hours ("h"), minutes ("m"), and seconds ("s") may be specified. When not specified, the period defaults to the value specified within the packageserver.
48+
type: string
49+
pattern: ^([0-9]+(\.[0-9]+)?(s|m|h))+$
4650
status:
4751
description: OLMConfigStatus is the status for an OLMConfig resource.
4852
type: object

crds/zz_defs.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/operators/v1/olmconfig_test.go

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,84 @@ package v1
22

33
import (
44
"testing"
5+
"time"
56

67
"github.com/stretchr/testify/require"
8+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
79
)
810

911
func boolPointer(in bool) *bool {
1012
return &in
1113
}
14+
func TestPackageServerSyncInterval(t *testing.T) {
15+
five := time.Minute * 5
16+
one := time.Second * 60
1217

18+
fiveParsed, err := time.ParseDuration("5m")
19+
require.NoError(t, err)
20+
21+
oneParsed, err := time.ParseDuration("60s")
22+
require.NoError(t, err)
23+
24+
tests := []struct {
25+
description string
26+
olmConfig *OLMConfig
27+
expected *time.Duration
28+
}{
29+
{
30+
description: "NilConfig",
31+
olmConfig: nil,
32+
expected: nil,
33+
},
34+
{
35+
description: "MissingSpec",
36+
olmConfig: &OLMConfig{},
37+
expected: nil,
38+
},
39+
{
40+
description: "MissingFeatures",
41+
olmConfig: &OLMConfig{
42+
Spec: OLMConfigSpec{},
43+
},
44+
expected: nil,
45+
},
46+
{
47+
description: "MissingPackageServerInterval",
48+
olmConfig: &OLMConfig{
49+
Spec: OLMConfigSpec{},
50+
},
51+
expected: nil,
52+
},
53+
{
54+
description: "PackageServerInterval5m",
55+
olmConfig: &OLMConfig{
56+
Spec: OLMConfigSpec{
57+
Features: &Features{
58+
PackageServerSyncInterval: &metav1.Duration{Duration: fiveParsed},
59+
},
60+
},
61+
},
62+
expected: &five,
63+
},
64+
{
65+
description: "PackageServerInterval60s",
66+
olmConfig: &OLMConfig{
67+
Spec: OLMConfigSpec{
68+
Features: &Features{
69+
PackageServerSyncInterval: &metav1.Duration{Duration: oneParsed},
70+
},
71+
},
72+
},
73+
expected: &one,
74+
},
75+
}
76+
77+
for _, tt := range tests {
78+
t.Run(tt.description, func(t *testing.T) {
79+
require.EqualValues(t, tt.expected, tt.olmConfig.PackageServerSyncInterval())
80+
})
81+
}
82+
}
1383
func TestCopiedCSVsAreEnabled(t *testing.T) {
1484
tests := []struct {
1585
description string

0 commit comments

Comments
 (0)