CronJob: cleanup legacy ScheduledJob vars,docs
Signed-off-by: Zhou Peng <p@ctriple.cn>
This commit is contained in:
@@ -173,16 +173,16 @@ func ValidateJobStatusUpdate(status, oldStatus batch.JobStatus) field.ErrorList
|
||||
}
|
||||
|
||||
// ValidateCronJob validates a CronJob and returns an ErrorList with any errors.
|
||||
func ValidateCronJob(scheduledJob *batch.CronJob) field.ErrorList {
|
||||
func ValidateCronJob(cronJob *batch.CronJob) field.ErrorList {
|
||||
// CronJobs and rcs have the same name validation
|
||||
allErrs := apivalidation.ValidateObjectMeta(&scheduledJob.ObjectMeta, true, apivalidation.ValidateReplicationControllerName, field.NewPath("metadata"))
|
||||
allErrs = append(allErrs, ValidateCronJobSpec(&scheduledJob.Spec, field.NewPath("spec"))...)
|
||||
if len(scheduledJob.ObjectMeta.Name) > apimachineryvalidation.DNS1035LabelMaxLength-11 {
|
||||
allErrs := apivalidation.ValidateObjectMeta(&cronJob.ObjectMeta, true, apivalidation.ValidateReplicationControllerName, field.NewPath("metadata"))
|
||||
allErrs = append(allErrs, ValidateCronJobSpec(&cronJob.Spec, field.NewPath("spec"))...)
|
||||
if len(cronJob.ObjectMeta.Name) > apimachineryvalidation.DNS1035LabelMaxLength-11 {
|
||||
// The cronjob controller appends a 11-character suffix to the cronjob (`-$TIMESTAMP`) when
|
||||
// creating a job. The job name length limit is 63 characters.
|
||||
// Therefore cronjob names must have length <= 63-11=52. If we don't validate this here,
|
||||
// then job creation will fail later.
|
||||
allErrs = append(allErrs, field.Invalid(field.NewPath("metadata").Child("name"), scheduledJob.ObjectMeta.Name, "must be no more than 52 characters"))
|
||||
allErrs = append(allErrs, field.Invalid(field.NewPath("metadata").Child("name"), cronJob.ObjectMeta.Name, "must be no more than 52 characters"))
|
||||
}
|
||||
return allErrs
|
||||
}
|
||||
|
Reference in New Issue
Block a user