Skip to content

Commit

Permalink
Add config for packageserver wakeup interval (#298)
Browse files Browse the repository at this point in the history
Signed-off-by: Todd Short <todd.short@me.com>
  • Loading branch information
tmshort committed Sep 29, 2023
1 parent 28c6773 commit 7961b02
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 1 deletion.
4 changes: 4 additions & 0 deletions crds/operators.coreos.com_olmconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ spec:
disableCopiedCSVs:
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.
type: boolean
packageServerSyncInterval:
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.
type: string
pattern: ^([0-9]+(\.[0-9]+)?(s|m|h))+$
status:
description: OLMConfigStatus is the status for an OLMConfig resource.
type: object
Expand Down
2 changes: 1 addition & 1 deletion crds/zz_defs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 70 additions & 0 deletions pkg/operators/v1/olmconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,84 @@ package v1

import (
"testing"
"time"

"github.com/stretchr/testify/require"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func boolPointer(in bool) *bool {
return &in
}
func TestPackageServerSyncInterval(t *testing.T) {
five := time.Minute * 5
one := time.Second * 60

fiveParsed, err := time.ParseDuration("5m")
require.NoError(t, err)

oneParsed, err := time.ParseDuration("60s")
require.NoError(t, err)

tests := []struct {
description string
olmConfig *OLMConfig
expected *time.Duration
}{
{
description: "NilConfig",
olmConfig: nil,
expected: nil,
},
{
description: "MissingSpec",
olmConfig: &OLMConfig{},
expected: nil,
},
{
description: "MissingFeatures",
olmConfig: &OLMConfig{
Spec: OLMConfigSpec{},
},
expected: nil,
},
{
description: "MissingPackageServerInterval",
olmConfig: &OLMConfig{
Spec: OLMConfigSpec{},
},
expected: nil,
},
{
description: "PackageServerInterval5m",
olmConfig: &OLMConfig{
Spec: OLMConfigSpec{
Features: &Features{
PackageServerSyncInterval: &metav1.Duration{Duration: fiveParsed},
},
},
},
expected: &five,
},
{
description: "PackageServerInterval60s",
olmConfig: &OLMConfig{
Spec: OLMConfigSpec{
Features: &Features{
PackageServerSyncInterval: &metav1.Duration{Duration: oneParsed},
},
},
},
expected: &one,
},
}

for _, tt := range tests {
t.Run(tt.description, func(t *testing.T) {
require.EqualValues(t, tt.expected, tt.olmConfig.PackageServerSyncInterval())
})
}
}
func TestCopiedCSVsAreEnabled(t *testing.T) {
tests := []struct {
description string
Expand Down
Loading

0 comments on commit 7961b02

Please sign in to comment.