Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config for packageserver wakeup interval #298

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))+$
ncdc marked this conversation as resolved.
Show resolved Hide resolved
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