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

'30s' is not valid 'duration' #300

Open
xenOs76 opened this issue Nov 5, 2024 · 3 comments · May be fixed by #309
Open

'30s' is not valid 'duration' #300

xenOs76 opened this issue Nov 5, 2024 · 3 comments · May be fixed by #309

Comments

@xenOs76
Copy link

xenOs76 commented Nov 5, 2024

Hi,

I'm unable to validate some Grafana Operator resources containing time intervals.
I did test some Yaml files that have been successfully applied in Kubernetes despite the problems reported by kubeconform.
For this issue report I'm using some examples taken from the Grafana Operator website:

I did convert the following CRDs to Json using the openapi2jsonschema.py script:

I did try to validate with the following commands:

❯ cat grafana-alert-rule-group-sample.yaml | kubeconform -schema-location ./grafanaalertrulegroup_v1beta1.json
stdin - GrafanaAlertRuleGroup grafanaalertrulegroup-sample is invalid: problem validating schema. Check JSON formatting: jsonschema: '/spec/interval' does not validate with file:///[...]/Tmp/kubeconform-duration-tests/grafanaalertrulegroup_v1beta1.json#/properties/spec/properties/interval/format: '5m' is not valid 'duration'

❯ cat grafana-dashboard-sample.yaml | kubeconform -schema-location ./grafanadashboard_v1beta1.json
stdin - GrafanaDashboard grafanadashboard-sample is invalid: problem validating schema. Check JSON formatting: jsonschema: '/spec/resyncPeriod' does not validate with file:///[...]/Tmp/kubeconform-duration-tests/grafanadashboard_v1beta1.json#/properties/spec/properties/resyncPeriod/format: '30s' is not valid 'duration'

I'm attaching the files i used for the tests:
kubeconform-duration-tests.zip

@nezdolik
Copy link

+1 getting the same issue:

stdin - BackendTrafficPolicy service-insights is invalid: problem validating schema. Check JSON formatting: jsonschema: '/spec/healthCheck/active/interval' does not validate with https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/gateway.envoyproxy.io/backendtrafficpolicy_v1alpha1.json#/properties/spec/properties/healthCheck/properties/active/properties/interval/format: '3s' is not valid 'duration'

@gazal-k
Copy link

gazal-k commented Feb 9, 2025

Getting a similar issue with scrapeInterval for OpenTelemetryCollector 😞

OpenTelemetryCollector sumologic-metrics is invalid: problem validating schema. Check JSON formatting: jsonschema: '/spec/targetAllocator/prometheusCR/scrapeInterval' does not validate with https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/opentelemetry.io/opentelemetrycollector_v1alpha1.json#/properties/spec/properties/targetAllocator/properties/prometheusCR/properties/scrapeInterval/format: '30s' is not valid 'duration'

@MattiasAng
Copy link

MattiasAng commented Feb 10, 2025

The jsonschema package which kubeconform use only validates duration against ISO8601/RFC3339, i.e. 5m would be PT5M.

This doesn't conform to what apiextensions expects as duration which should be parsable using time.ParseDuration so expecting most custom controller to not parse this correctly if you want to have a successful validation.

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

Successfully merging a pull request may close this issue.

4 participants