Skip to content

Commit

Permalink
manifests: sched: add and use defaults cache params
Browse files Browse the repository at this point in the history
Set default cache params compatible with RTE >= 0.18

Signed-off-by: Francesco Romani <[email protected]>
  • Loading branch information
ffromani committed Mar 5, 2024
1 parent e44a6c7 commit 061c887
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pkg/manifests/sched/sched.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (mf Manifests) Render(logger logr.Logger, opts options.Scheduler) (Manifest
var err error
params := manifests.ConfigParams{
ProfileName: opts.ProfileName,
Cache: &manifests.ConfigCacheParams{},
Cache: manifests.NewConfigCacheParams(),
}

if len(opts.CacheParamsConfigData) > 0 {
Expand Down
22 changes: 22 additions & 0 deletions pkg/manifests/schedparams.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package manifests

import (
"fmt"
"time"

"sigs.k8s.io/yaml"

Expand Down Expand Up @@ -97,6 +98,19 @@ type ConfigCacheParams struct {
InformerMode *string `json:"informerMode,omitempty"`
}

func SetDefaultsConfigCacheParams(params *ConfigCacheParams) {
params.ResyncPeriodSeconds = newInt64(int64(5 * time.Second))
params.ResyncMethod = newString(CacheResyncAutodetect)
params.ForeignPodsDetectMode = newString(ForeignPodsDetectOnlyExclusiveResources)
// InformerMode support intentionally left unspecified
}

func NewConfigCacheParams() *ConfigCacheParams {
params := ConfigCacheParams{}
SetDefaultsConfigCacheParams(&params)
return &params
}

type ResourceSpecParams struct {
// Name of the resource.
Name string `json:"name"`
Expand Down Expand Up @@ -309,3 +323,11 @@ func extractParams(profileName string, args map[string]interface{}) (ConfigParam

return params, nil
}

func newInt64(v int64) *int64 {
return &v
}

func newString(v string) *string {
return &v
}
8 changes: 0 additions & 8 deletions pkg/manifests/schedparams_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,11 +514,3 @@ func toJSON(v any) string {
}
return string(data)
}

func newInt64(value int64) *int64 {
return &value
}

func newString(value string) *string {
return &value
}

0 comments on commit 061c887

Please sign in to comment.