Open juanpsm opened 1 year ago
The api.Schedule struct 's ttl define is above.
And the flag parse the ttl is:
The ttl define is
There maybe a time cast in k8s api time type and the golang 's time .
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days. If a Velero team member has requested log or more information, please provide the output of the shared commands.
This issue was closed because it has been stalled for 14 days with no activity.
This is still an issue
There is a in-progress PR on this topic. https://github.com/vmware-tanzu/velero/pull/7793
@blackpiglet #7793 is only for timezone for cron for schedule. Not related to duration for TTL.
@kaovilai Thanks, then I reopen this issue.
this is still an issue for me
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days. If a Velero team member has requested log or more information, please provide the output of the shared commands.
unstale
After debugging, the unitMap used by time.ParseDuration is defined as
var unitMap = map[string]uint64{
"ns": uint64(Nanosecond),
"us": uint64(Microsecond),
"µs": uint64(Microsecond), // U+00B5 = micro symbol
"μs": uint64(Microsecond), // U+03BC = Greek letter mu
"ms": uint64(Millisecond),
"s": uint64(Second),
"m": uint64(Minute),
"h": uint64(Hour),
}
from /go/1.23.2/libexec/src/time/format.go (https://cs.opensource.google/go/go/+/refs/tags/go1.23.2:src/time/format.go;l=1601-1610)
Browsing go.dev, the time ParseDuration actualy do not support the "w" format indicated. https://pkg.go.dev/time#ParseDuration
What @juanpsm linked is from https://pkg.go.dev/maze.io/x/duration#ParseDuration which is an entirely different time package.
I think this issue can be considered invalid, unless we want to adopt a different time package and convert it to go's built-ins "time".
Description
When creating a schedule with a TTL I noticed some inconsistencies. First, I couldn't find any resources where to check the accepted format for the TTL string. With
kubectl explain schedule.spec.template.ttl
I found that it is a time.Duration-parseable string.GO's
time.Duration
ParseDuration
function says valid time units are"ns", "us", "ms", "s", "m", "h", "d", "w", "y"
. But when I tried to use"d"
,"w"
or"y"
I got the following error:If instead of using velero cli, I use
kubectl
, it gets created but then I can't retrieve anything usingvelero schedule get
:That persists until the schedule is deleted.
Solution I'd like
I think that days, weeks and years should be valid units for the TTL string. It's somewhat weird that units like
µs
(microseconds) are accepted:I don`t see the use case of such a short lived backup. Weeks, months and years are much useful for this kind of application, and it would provide more readability to the schedule.
Also, it would be nice to have a resource where to check the accepted format, because even if it's briefly mentioned in How Velero Works it is not consistent with what the cli and kubectl shows.
There it says that the default value for the TTL is 30 days (I assume 720h), but when a schedule is created without the
--ttl
flag, the TTL is set to 0s.Additional comments
Missing other parameters, like
--schedule
, results in a validation error that prevents the schedule from being created:Even passing an incorrect value results in a failed validation that is explained in the schedule's description:
Besides,
schedule
field even recognizes the (non-standard)@daily
,@weekly
, etc. expressions, which is great:Environment:
1.11.0
<NOT SET>
1.24.0
OKD 4.11
vSphere 7.0.3
Pop!_OS 22.04 LTS