Skip to content

Commit

Permalink
Set APIDefaultTimeout default value through webhooks
Browse files Browse the repository at this point in the history
Like we did for CronJobs and ContainerImage, this patch enforces the same
default defined by kubebuilder to make sure we don't end up creating the
CR with wrong values (e.g., apiTimeout = 0).

Signed-off-by: Francesco Pantano <[email protected]>
  • Loading branch information
fmount committed Jun 10, 2024
1 parent 84eee55 commit c0b9aa1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions api/v1beta1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ const (
DBPurgeDefaultAge = 30
//DBPurgeDefaultSchedule is in crontab format, and the default runs the job once every day
DBPurgeDefaultSchedule = "1 0 * * *"
// APIDefaultTimeout indicates the default APITimeout for HAProxy and Apache, defaults to 60 seconds
APIDefaultTimeout = 60
)

// ManilaTemplate defines common input parameters used by all Manila services
Expand Down
6 changes: 6 additions & 0 deletions api/v1beta1/manila_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type ManilaDefaults struct {
ShareContainerImageURL string
DBPurgeAge int
DBPurgeSchedule string
APITimeout int
}

var manilaDefaults ManilaDefaults
Expand All @@ -61,6 +62,7 @@ func SetupDefaults() {
ShareContainerImageURL: util.GetEnvVar("RELATED_IMAGE_MANILA_SHARE_IMAGE_URL_DEFAULT", ManilaShareContainerImage),
DBPurgeAge: DBPurgeDefaultAge,
DBPurgeSchedule: DBPurgeDefaultSchedule,
APITimeout: APIDefaultTimeout,
}

manilalog.Info("Manila defaults initialized", "defaults", manilaDefaults)
Expand Down Expand Up @@ -109,6 +111,10 @@ func (spec *ManilaSpec) Default() {
// Default - set defaults for this Manila spec base
func (spec *ManilaSpecBase) Default() {

if spec.APITimeout == 0 {
spec.APITimeout = manilaDefaults.APITimeout
}

if spec.DBPurge.Age == 0 {
spec.DBPurge.Age = manilaDefaults.DBPurgeAge
}
Expand Down

0 comments on commit c0b9aa1

Please sign in to comment.