Skip to content

Commit 82e2655

Browse files
committed
Add config for packageserver wakeup interval (openshift#298)
Signed-off-by: Todd Short <[email protected]> Upstream-repository: api Upstream-commit: 7961b0208d99b3e059a0607663dba547a7e685d7
1 parent 8d6f8c4 commit 82e2655

File tree

10 files changed

+132
-2
lines changed

10 files changed

+132
-2
lines changed

manifests/0000_50_olm_00-olmconfigs.crd.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ spec:
4545
disableCopiedCSVs:
4646
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.
4747
type: boolean
48+
packageServerSyncInterval:
49+
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.
50+
type: string
51+
pattern: ^([0-9]+(\.[0-9]+)?(s|m|h))+$
4852
status:
4953
description: OLMConfigStatus is the status for an OLMConfig resource.
5054
type: object

staging/api/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

staging/api/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.

staging/api/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

staging/api/pkg/operators/v1/olmconfig_types.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package v1
22

33
import (
4+
"time"
5+
46
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
57
)
68

@@ -23,6 +25,16 @@ type Features struct {
2325
// When reenabled, OLM will recreate the "Copied CSVs" for each
2426
// cluster scoped operator.
2527
DisableCopiedCSVs *bool `json:"disableCopiedCSVs,omitempty"`
28+
// PackageServerSyncInterval is used to define the sync interval for
29+
// packagerserver pods. Packageserver pods periodically check the
30+
// status of CatalogSources; this specifies the period using duration
31+
// format (e.g. "60m"). For this parameter, only hours ("h"), minutes
32+
// ("m"), and seconds ("s") may be specified. When not specified, the
33+
// period defaults to the value specified within the packageserver.
34+
// +optional
35+
// +kubebuilder:validation:Type=string
36+
// +kubebuilder:validation:Pattern="^([0-9]+(\\.[0-9]+)?(s|m|h))+$"
37+
PackageServerSyncInterval *metav1.Duration `json:"packageServerSyncInterval,omitempty"`
2638
}
2739

2840
// OLMConfigStatus is the status for an OLMConfig resource.
@@ -69,3 +81,10 @@ func (config *OLMConfig) CopiedCSVsAreEnabled() bool {
6981

7082
return !*config.Spec.Features.DisableCopiedCSVs
7183
}
84+
85+
func (config *OLMConfig) PackageServerSyncInterval() *time.Duration {
86+
if config == nil || config.Spec.Features == nil || config.Spec.Features.PackageServerSyncInterval == nil {
87+
return nil
88+
}
89+
return &config.Spec.Features.PackageServerSyncInterval.Duration
90+
}

staging/api/pkg/operators/v1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/operator-framework/api/crds/operators.coreos.com_olmconfigs.yaml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/operator-framework/api/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.

vendor/github.com/operator-framework/api/pkg/operators/v1/olmconfig_types.go

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/operator-framework/api/pkg/operators/v1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)