I AS A USER want to not put in random big integer numbers in CRDs such as terminationgraceperiodseconds: 8763762374, but instead want to have some human readable duration such as terminationgraceperiod: 42h.
I AS A STACKABLE DEVELOPER want to not implement this in all operators, so have it in operator-rs
Requirements
- Must: Try to stick to the k8s way of specifying durations. It is ok to omit or add more features if this makes sense. In general its always easy to add new features, and hard to remove them again.
- Must: Having support for
s,m,h,d,w
- Could: Having support for
M,y as the implementation is more complicated but we might need this for ca certificate lifetime.
- Could: Millisecond support
- Must NOT: Support long variants
5seconds or 42minutes. K8s does not support this as well
- Should: You should be able to do all the stuff std::time::Duration supports
Implementation decisions
- Custom struct
Duration with inner type std::time::Duration
impl Deref for Duration with Target = std::time::Duration
- operators should use the Duration struct everywhere in their code possible and prefer that over
std::time::Duration so that, for example, log messages are consistent to the k8s way of formatting durations.
Implementation checklists
### Tasks
- [x] https://github.com/stackabletech/operator-rs/pull/647
- [x] https://github.com/stackabletech/operator-rs/pull/654
- [ ] https://github.com/stackabletech/trino-operator/pull/474
- [ ] https://github.com/stackabletech/operator-rs/pull/671
- [ ] https://github.com/stackabletech/documentation/pull/467
### Operator Tasks
- [ ] https://github.com/stackabletech/airflow-operator/pull/333
- [ ] https://github.com/stackabletech/druid-operator/pull/478
- [ ] https://github.com/stackabletech/hbase-operator/pull/401
- [ ] https://github.com/stackabletech/hdfs-operator/pull/408
- [ ] https://github.com/stackabletech/hive-operator/pull/378
- [ ] https://github.com/stackabletech/spark-k8s-operator/pull/292
- [ ] https://github.com/stackabletech/superset-operator/pull/412
- [ ] https://github.com/stackabletech/zookeeper-operator/pull/733
- [ ] https://github.com/stackabletech/opa-operator/pull/483
- [ ] https://github.com/stackabletech/secret-operator/pull/306
- [ ] https://github.com/stackabletech/listener-operator/pull/115
I AS A USER want to not put in random big integer numbers in CRDs such as
terminationgraceperiodseconds: 8763762374, but instead want to have some human readable duration such asterminationgraceperiod: 42h.I AS A STACKABLE DEVELOPER want to not implement this in all operators, so have it in operator-rs
Requirements
s,m,h,d,wM,yas the implementation is more complicated but we might need this for ca certificate lifetime.5secondsor42minutes. K8s does not support this as wellImplementation decisions
Durationwith inner typestd::time::Durationimpl Deref for DurationwithTarget = std::time::Durationstd::time::Durationso that, for example, log messages are consistent to the k8s way of formatting durations.Implementation checklists