Skip to content

Commit

Permalink
fix: job name too long for label (#4003)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyelei authored Jun 28, 2023
1 parent e790ec2 commit 568fe69
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions controllers/dataprotection/backup_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,9 @@ var _ = Describe("Backup Controller test", func() {
viper.Set(constant.CfgKeyCtrlrMgrTolerations,
"[{\"key\":\"key1\", \"operator\": \"Exists\", \"effect\": \"NoSchedule\"}]")
viper.Set(constant.CfgKeyCtrlrMgrNodeSelector, "{\"beta.kubernetes.io/arch\":\"amd64\"}")

snapshotBackupName := "backup-default-postgres-cluster-20230628104804"
By("By creating a backup from backupPolicy: " + backupPolicyName)
backup = testapps.NewBackupFactory(testCtx.DefaultNamespace, backupName).
backup = testapps.NewBackupFactory(testCtx.DefaultNamespace, snapshotBackupName).
SetBackupPolicyName(backupPolicyName).
SetBackupType(dpv1alpha1.BackupTypeSnapshot).
Create(&testCtx).GetObject()
Expand Down
4 changes: 2 additions & 2 deletions controllers/dataprotection/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,10 @@ func generateJSON(path string, value string) string {
return jsonString
}

// cropJobName job name cannot exceed 64 characters.
// cropJobName job name cannot exceed 63 characters for label name limit.
func cropJobName(jobName string) string {
if len(jobName) > 63 {
return jobName[:64]
return jobName[:63]
}
return jobName
}
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/plan/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ func (p *RestoreManager) cleanupClusterAnnotations() error {
func (p *RestoreManager) buildRestoreJobName(jobName string) string {
l := len(jobName)
if l > 63 {
return fmt.Sprintf("%s-%s", jobName[:58], jobName[l-5:l])
return fmt.Sprintf("%s-%s", jobName[:57], jobName[l-5:l])
}
return jobName
}

0 comments on commit 568fe69

Please sign in to comment.