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

Retention period validation #763

Open
chlunde opened this issue Jun 24, 2024 · 4 comments
Open

Retention period validation #763

chlunde opened this issue Jun 24, 2024 · 4 comments

Comments

@chlunde
Copy link

chlunde commented Jun 24, 2024

Hi, it's tempting for someone to use the "d" suffix in retention period, but that's not valid. It will prevent the operator from working as it cannot deserialize TemporalNamespace into Go objects.

With

retentionPeriod: 30d

we got the following error:

Failed to watch *v1beta1.TemporalNamespace: failed to list *v1beta1.TemporalNamespace: time: unknown unit "d" in duration "30d"

This is because it is parsed by https://pkg.go.dev/time#ParseDuration

I tried to delete a temporal UI Deployment, and it was not recreated.

We've had the same issue in an in-house controller. We added the following annotations there:

	// Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
	// Format: 8h30m0s
	//+optional
	//+kubebuilder:validation:Type=string
	//+kubebuilder:validation:Pattern=^(\d+h)?(\d+m)?(\d+s)?$
	//+kubebuilder:validation:MinLength=2
@alexandrevilain
Copy link
Owner

Hi @chlunde !

Thanks for the issue. I understand your point but I'm pretty aligned with the Go team vision on the absence of the "day" in duration: golang/go#11473 (comment)

I don't think it's a good idea to start developing something around the duration to support the day parameter :)

Isn't 720h enough for you ? :)

@chlunde
Copy link
Author

chlunde commented Jun 24, 2024

I just intended to report that we should probably add some comments like above here:
https://github.com/alexandrevilain/temporal-operator/blob/main/api/v1beta1/temporalnamespace_types.go#L44-L45

	// RetentionPeriod to apply on closed workflow executions.
	// Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
	// Format: 8h30m0s
	//+optional
	//+kubebuilder:validation:Type=string
	//+kubebuilder:validation:Pattern=^(\d+h)?(\d+m)?(\d+s)?$
	//+kubebuilder:validation:MinLength=2
	RetentionPeriod *metav1.Duration `json:"retentionPeriod"`

So we don't get invalid values into the api server, because it stops the whole operator is seems (although I would only expect namespace reconcilation to stop)

@alexandrevilain
Copy link
Owner

Good point! Are you interested on contributing ?

it stops the whole operator is seems

What do you mean ? An issue on the NamespaceController stops the whole operator ?

@chlunde
Copy link
Author

chlunde commented Jun 26, 2024

@alexandrevilain I was in a hurry so I didn't properly debug it, but I had added the prometheus annotation setting for TemporalCluster and deleted the Deployment for cluster-ui and expected the operator to re-create it or apply the change for prometheus. That's why I checked the logs and discovered this issue. At that point I fixed the TemporalNamespace retentionPeriod and the operator then fixed the TemporalCluster (annotation and missing deployment).

I can probably test and create a PR for the schema tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants