From f9439727a66f4340e558912fee749526e02bf1d7 Mon Sep 17 00:00:00 2001 From: "zhongjun.li" Date: Wed, 18 Oct 2023 16:41:13 +0800 Subject: [PATCH] Fix Backup name duplication --- changelogs/unreleased/6971-learner0810 | 1 + pkg/apis/velero/v1/schedule_types.go | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/6971-learner0810 diff --git a/changelogs/unreleased/6971-learner0810 b/changelogs/unreleased/6971-learner0810 new file mode 100644 index 0000000000..d00b67ba54 --- /dev/null +++ b/changelogs/unreleased/6971-learner0810 @@ -0,0 +1 @@ +Fix Backup name duplication \ No newline at end of file diff --git a/pkg/apis/velero/v1/schedule_types.go b/pkg/apis/velero/v1/schedule_types.go index 6cb553b9a8..647c46ae0f 100644 --- a/pkg/apis/velero/v1/schedule_types.go +++ b/pkg/apis/velero/v1/schedule_types.go @@ -21,6 +21,7 @@ import ( "time" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apiserver/pkg/storage/names" ) // ScheduleSpec defines the specification for a Velero schedule @@ -124,5 +125,5 @@ type ScheduleList struct { // TimestampedName returns the default backup name format based on the schedule func (s *Schedule) TimestampedName(timestamp time.Time) string { - return fmt.Sprintf("%s-%s", s.Name, timestamp.Format("20060102150405")) + return names.SimpleNameGenerator.GenerateName(fmt.Sprintf("%s-%s-", s.Name, timestamp.Format("20060102150405"))) }