Merge pull request #41890 from soltysh/issue37166

Automatic merge from submit-queue (batch tested with PRs 41890, 42593, 42633, 42626, 42609)

Remove everything that is not new from batch/v2alpha1

Fixes #37166.

@lavalamp you've asked for it 
@erictune this is a prereq for moving CronJobs to beta. I initially planned to put all in one PR, but after I did that I figured out it'll be easier to review separately. ptal 

@kubernetes/api-approvers @kubernetes/sig-api-machinery-pr-reviews ptal
This commit is contained in:
Kubernetes Submit Queue
2017-03-07 08:10:38 -08:00
committed by GitHub
62 changed files with 372 additions and 12330 deletions

View File

@@ -31,7 +31,7 @@ import (
"k8s.io/kubernetes/pkg/api/v1"
batchinternal "k8s.io/kubernetes/pkg/apis/batch"
batchv1 "k8s.io/kubernetes/pkg/apis/batch/v1"
batch "k8s.io/kubernetes/pkg/apis/batch/v2alpha1"
batchv2alpha1 "k8s.io/kubernetes/pkg/apis/batch/v2alpha1"
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
"k8s.io/kubernetes/pkg/controller/job"
"k8s.io/kubernetes/pkg/kubectl"
@@ -44,13 +44,12 @@ const (
)
var (
CronJobGroupVersionResource = schema.GroupVersionResource{Group: batch.GroupName, Version: "v2alpha1", Resource: "cronjobs"}
ScheduledJobGroupVersionResource = schema.GroupVersionResource{Group: batch.GroupName, Version: "v2alpha1", Resource: "scheduledjobs"}
BatchV2Alpha1GroupVersion = schema.GroupVersion{Group: batch.GroupName, Version: "v2alpha1"}
CronJobGroupVersionResource = schema.GroupVersionResource{Group: batchv2alpha1.GroupName, Version: "v2alpha1", Resource: "cronjobs"}
ScheduledJobGroupVersionResource = schema.GroupVersionResource{Group: batchv2alpha1.GroupName, Version: "v2alpha1", Resource: "scheduledjobs"}
)
var _ = framework.KubeDescribe("CronJob", func() {
f := framework.NewDefaultGroupVersionFramework("cronjob", BatchV2Alpha1GroupVersion)
f := framework.NewDefaultFramework("cronjob")
sleepCommand := []string{"sleep", "300"}
@@ -64,7 +63,7 @@ var _ = framework.KubeDescribe("CronJob", func() {
// multiple jobs running at once
It("should schedule multiple jobs concurrently", func() {
By("Creating a cronjob")
cronJob := newTestCronJob("concurrent", "*/1 * * * ?", batch.AllowConcurrent,
cronJob := newTestCronJob("concurrent", "*/1 * * * ?", batchv2alpha1.AllowConcurrent,
sleepCommand, nil)
cronJob, err := createCronJob(f.ClientSet, f.Namespace.Name, cronJob)
Expect(err).NotTo(HaveOccurred())
@@ -87,7 +86,7 @@ var _ = framework.KubeDescribe("CronJob", func() {
// suspended should not schedule jobs
It("should not schedule jobs when suspended [Slow]", func() {
By("Creating a suspended cronjob")
cronJob := newTestCronJob("suspended", "*/1 * * * ?", batch.AllowConcurrent,
cronJob := newTestCronJob("suspended", "*/1 * * * ?", batchv2alpha1.AllowConcurrent,
sleepCommand, nil)
t := true
cronJob.Spec.Suspend = &t
@@ -111,7 +110,7 @@ var _ = framework.KubeDescribe("CronJob", func() {
// only single active job is allowed for ForbidConcurrent
It("should not schedule new jobs when ForbidConcurrent [Slow]", func() {
By("Creating a ForbidConcurrent cronjob")
cronJob := newTestCronJob("forbid", "*/1 * * * ?", batch.ForbidConcurrent,
cronJob := newTestCronJob("forbid", "*/1 * * * ?", batchv2alpha1.ForbidConcurrent,
sleepCommand, nil)
cronJob, err := createCronJob(f.ClientSet, f.Namespace.Name, cronJob)
Expect(err).NotTo(HaveOccurred())
@@ -143,7 +142,7 @@ var _ = framework.KubeDescribe("CronJob", func() {
// only single active job is allowed for ReplaceConcurrent
It("should replace jobs when ReplaceConcurrent", func() {
By("Creating a ReplaceConcurrent cronjob")
cronJob := newTestCronJob("replace", "*/1 * * * ?", batch.ReplaceConcurrent,
cronJob := newTestCronJob("replace", "*/1 * * * ?", batchv2alpha1.ReplaceConcurrent,
sleepCommand, nil)
cronJob, err := createCronJob(f.ClientSet, f.Namespace.Name, cronJob)
Expect(err).NotTo(HaveOccurred())
@@ -175,7 +174,7 @@ var _ = framework.KubeDescribe("CronJob", func() {
// shouldn't give us unexpected warnings
It("should not emit unexpected warnings", func() {
By("Creating a cronjob")
cronJob := newTestCronJob("concurrent", "*/1 * * * ?", batch.AllowConcurrent,
cronJob := newTestCronJob("concurrent", "*/1 * * * ?", batchv2alpha1.AllowConcurrent,
nil, nil)
cronJob, err := createCronJob(f.ClientSet, f.Namespace.Name, cronJob)
Expect(err).NotTo(HaveOccurred())
@@ -198,7 +197,7 @@ var _ = framework.KubeDescribe("CronJob", func() {
// deleted jobs should be removed from the active list
It("should remove from active list jobs that have been deleted", func() {
By("Creating a ForbidConcurrent cronjob")
cronJob := newTestCronJob("forbid", "*/1 * * * ?", batch.ForbidConcurrent,
cronJob := newTestCronJob("forbid", "*/1 * * * ?", batchv2alpha1.ForbidConcurrent,
sleepCommand, nil)
cronJob, err := createCronJob(f.ClientSet, f.Namespace.Name, cronJob)
Expect(err).NotTo(HaveOccurred())
@@ -242,7 +241,7 @@ var _ = framework.KubeDescribe("CronJob", func() {
It("should delete successful finished jobs with limit of one successful job", func() {
By("Creating a AllowConcurrent cronjob with custom history limits")
successLimit := int32(1)
cronJob := newTestCronJob("concurrent-limit", "*/1 * * * ?", batch.AllowConcurrent,
cronJob := newTestCronJob("concurrent-limit", "*/1 * * * ?", batchv2alpha1.AllowConcurrent,
successCommand, &successLimit)
cronJob, err := createCronJob(f.ClientSet, f.Namespace.Name, cronJob)
Expect(err).NotTo(HaveOccurred())
@@ -278,19 +277,19 @@ var _ = framework.KubeDescribe("CronJob", func() {
})
// newTestCronJob returns a cronjob which does one of several testing behaviors.
func newTestCronJob(name, schedule string, concurrencyPolicy batch.ConcurrencyPolicy, command []string,
successfulJobsHistoryLimit *int32) *batch.CronJob {
func newTestCronJob(name, schedule string, concurrencyPolicy batchv2alpha1.ConcurrencyPolicy,
command []string, successfulJobsHistoryLimit *int32) *batchv2alpha1.CronJob {
parallelism := int32(1)
completions := int32(1)
sj := &batch.CronJob{
sj := &batchv2alpha1.CronJob{
ObjectMeta: metav1.ObjectMeta{
Name: name,
},
Spec: batch.CronJobSpec{
Spec: batchv2alpha1.CronJobSpec{
Schedule: schedule,
ConcurrencyPolicy: concurrencyPolicy,
JobTemplate: batch.JobTemplateSpec{
Spec: batch.JobSpec{
JobTemplate: batchv2alpha1.JobTemplateSpec{
Spec: batchv1.JobSpec{
Parallelism: &parallelism,
Completions: &completions,
Template: v1.PodTemplateSpec{
@@ -329,11 +328,11 @@ func newTestCronJob(name, schedule string, concurrencyPolicy batch.ConcurrencyPo
return sj
}
func createCronJob(c clientset.Interface, ns string, cronJob *batch.CronJob) (*batch.CronJob, error) {
func createCronJob(c clientset.Interface, ns string, cronJob *batchv2alpha1.CronJob) (*batchv2alpha1.CronJob, error) {
return c.BatchV2alpha1().CronJobs(ns).Create(cronJob)
}
func getCronJob(c clientset.Interface, ns, name string) (*batch.CronJob, error) {
func getCronJob(c clientset.Interface, ns, name string) (*batchv2alpha1.CronJob, error) {
return c.BatchV2alpha1().CronJobs(ns).Get(name, metav1.GetOptions{})
}

View File

@@ -108,12 +108,6 @@ func NewDefaultFramework(baseName string) *Framework {
return NewFramework(baseName, options, nil)
}
func NewDefaultGroupVersionFramework(baseName string, groupVersion schema.GroupVersion) *Framework {
f := NewDefaultFramework(baseName)
f.Options.GroupVersion = &groupVersion
return f
}
func NewFramework(baseName string, options FrameworkOptions, client clientset.Interface) *Framework {
f := &Framework{
BaseName: baseName,

View File

@@ -29,7 +29,8 @@ import (
"k8s.io/apimachinery/pkg/watch"
clientv1 "k8s.io/client-go/pkg/api/v1"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apis/batch/v2alpha1"
batchv1 "k8s.io/kubernetes/pkg/apis/batch/v1"
batchv2alpha1 "k8s.io/kubernetes/pkg/apis/batch/v2alpha1"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo"
@@ -189,21 +190,21 @@ var _ = framework.KubeDescribe("Generated release_1_5 clientset", func() {
})
})
func newTestingCronJob(name string, value string) *v2alpha1.CronJob {
func newTestingCronJob(name string, value string) *batchv2alpha1.CronJob {
parallelism := int32(1)
completions := int32(1)
return &v2alpha1.CronJob{
return &batchv2alpha1.CronJob{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Labels: map[string]string{
"time": value,
},
},
Spec: v2alpha1.CronJobSpec{
Spec: batchv2alpha1.CronJobSpec{
Schedule: "*/1 * * * ?",
ConcurrencyPolicy: v2alpha1.AllowConcurrent,
JobTemplate: v2alpha1.JobTemplateSpec{
Spec: v2alpha1.JobSpec{
ConcurrencyPolicy: batchv2alpha1.AllowConcurrent,
JobTemplate: batchv2alpha1.JobTemplateSpec{
Spec: batchv1.JobSpec{
Parallelism: &parallelism,
Completions: &completions,
Template: v1.PodTemplateSpec{
@@ -244,9 +245,9 @@ var _ = framework.KubeDescribe("Generated release_1_5 clientset", func() {
groupList, err := f.ClientSet.Discovery().ServerGroups()
framework.ExpectNoError(err)
for _, group := range groupList.Groups {
if group.Name == v2alpha1.GroupName {
if group.Name == batchv2alpha1.GroupName {
for _, version := range group.Versions {
if version.Version == v2alpha1.SchemeGroupVersion.Version {
if version.Version == batchv2alpha1.SchemeGroupVersion.Version {
enabled = true
break
}
@@ -254,7 +255,7 @@ var _ = framework.KubeDescribe("Generated release_1_5 clientset", func() {
}
}
if !enabled {
framework.Logf("%s is not enabled, test skipped", v2alpha1.SchemeGroupVersion)
framework.Logf("%s is not enabled, test skipped", batchv2alpha1.SchemeGroupVersion)
return
}
cronJobClient := f.ClientSet.BatchV2alpha1().CronJobs(f.Namespace.Name)

View File

@@ -178,7 +178,7 @@ func runKubectlRetryOrDie(args ...string) string {
// duplicated setup to avoid polluting "normal" clients with alpha features which confuses the generated clients
var _ = framework.KubeDescribe("Kubectl alpha client", func() {
defer GinkgoRecover()
f := framework.NewDefaultGroupVersionFramework("kubectl", BatchV2Alpha1GroupVersion)
f := framework.NewDefaultFramework("kubectl")
var c clientset.Interface
var ns string