Skip to content

Commit

Permalink
bump client go to v4.0.0-beta.0 to support kubernetes 1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
andyxning committed Jul 30, 2017
1 parent 848cff2 commit 1f8761d
Show file tree
Hide file tree
Showing 1,058 changed files with 186,574 additions and 208,833 deletions.
1,144 changes: 355 additions & 789 deletions Godeps/Godeps.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions collectors/cronjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/robfig/cron"
"golang.org/x/net/context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/pkg/api"
"k8s.io/client-go/pkg/api/unversioned"
v2batch "k8s.io/client-go/pkg/apis/batch/v2alpha1"
"k8s.io/client-go/tools/cache"
)
Expand Down Expand Up @@ -117,7 +117,7 @@ func (cjc *cronJobCollector) Collect(ch chan<- prometheus.Metric) {
}
}

func getNextScheduledTime(schedule string, lastScheduleTime *unversioned.Time, createdTime unversioned.Time) (time.Time, error) {
func getNextScheduledTime(schedule string, lastScheduleTime *metav1.Time, createdTime metav1.Time) (time.Time, error) {
sched, err := cron.ParseStandard(schedule)
if err != nil {
return time.Time{}, fmt.Errorf("Failed to parse cron job schedule '%s': %s", schedule, err)
Expand Down
62 changes: 31 additions & 31 deletions collectors/cronjob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ import (
"testing"
"time"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/pkg/api/unversioned"
v2batch "k8s.io/client-go/pkg/apis/batch/v2alpha1"
)

var (
SuspendTrue bool = true
SuspendFalse bool = false
SuspendTrue bool = true
SuspendFalse bool = false
StartingDeadlineSeconds300 int64 = 300

ActiveRunningCronJob1LastScheduleTime, _ = time.Parse(time.RFC3339, "2017-05-26T12:00:07Z")
SuspendedCronJob1LastScheduleTime, _ = time.Parse(time.RFC3339, "2017-05-26T17:30:00Z")
ActiveRunningCronJob1LastScheduleTime, _ = time.Parse(time.RFC3339, "2017-05-26T12:00:07Z")
SuspendedCronJob1LastScheduleTime, _ = time.Parse(time.RFC3339, "2017-05-26T17:30:00Z")
ActiveCronJob1NoLastScheduledCreationTimestamp, _ = time.Parse(time.RFC3339, "2017-05-26T18:30:00Z")
)

Expand Down Expand Up @@ -62,58 +62,58 @@ func TestCronJobCollector(t *testing.T) {
`
cases := []struct {
cronJobs []v2batch.CronJob
want string
want string
}{
{
cronJobs: []v2batch.CronJob{
{
ObjectMeta: v1.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: "ActiveRunningCronJob1",
Namespace: "ns1",
Generation: 1,
},
Status: v2batch.CronJobStatus{
Active: []v1.ObjectReference{v1.ObjectReference{Name: "FakeJob1"}, v1.ObjectReference{Name: "FakeJob2"}},
LastScheduleTime: &unversioned.Time{Time: ActiveRunningCronJob1LastScheduleTime},
Active: []v1.ObjectReference{v1.ObjectReference{Name: "FakeJob1"}, v1.ObjectReference{Name: "FakeJob2"}},
LastScheduleTime: &metav1.Time{Time: ActiveRunningCronJob1LastScheduleTime},
},
Spec: v2batch.CronJobSpec{
StartingDeadlineSeconds: &StartingDeadlineSeconds300,
ConcurrencyPolicy: "Forbid",
Suspend: &SuspendFalse,
Schedule: "0 */6 * * *",
StartingDeadlineSeconds: &StartingDeadlineSeconds300,
ConcurrencyPolicy: "Forbid",
Suspend: &SuspendFalse,
Schedule: "0 */6 * * *",
},
}, {
ObjectMeta: v1.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: "SuspendedCronJob1",
Namespace: "ns1",
Generation: 1,
},
Status: v2batch.CronJobStatus{
Active: []v1.ObjectReference{},
LastScheduleTime: &unversioned.Time{Time: SuspendedCronJob1LastScheduleTime},
Active: []v1.ObjectReference{},
LastScheduleTime: &metav1.Time{Time: SuspendedCronJob1LastScheduleTime},
},
Spec: v2batch.CronJobSpec{
StartingDeadlineSeconds: &StartingDeadlineSeconds300,
ConcurrencyPolicy: "Forbid",
Suspend: &SuspendTrue,
Schedule: "0 */3 * * *",
StartingDeadlineSeconds: &StartingDeadlineSeconds300,
ConcurrencyPolicy: "Forbid",
Suspend: &SuspendTrue,
Schedule: "0 */3 * * *",
},
}, {
ObjectMeta: v1.ObjectMeta{
Name: "ActiveCronJob1NoLastScheduled",
CreationTimestamp: unversioned.Time{Time: ActiveCronJob1NoLastScheduledCreationTimestamp},
Namespace: "ns1",
Generation: 1,
ObjectMeta: metav1.ObjectMeta{
Name: "ActiveCronJob1NoLastScheduled",
CreationTimestamp: metav1.Time{Time: ActiveCronJob1NoLastScheduledCreationTimestamp},
Namespace: "ns1",
Generation: 1,
},
Status: v2batch.CronJobStatus{
Active: []v1.ObjectReference{},
LastScheduleTime: nil,
Active: []v1.ObjectReference{},
LastScheduleTime: nil,
},
Spec: v2batch.CronJobSpec{
StartingDeadlineSeconds: &StartingDeadlineSeconds300,
ConcurrencyPolicy: "Forbid",
Suspend: &SuspendFalse,
Schedule: "25 * * * *",
StartingDeadlineSeconds: &StartingDeadlineSeconds300,
ConcurrencyPolicy: "Forbid",
Suspend: &SuspendFalse,
Schedule: "25 * * * *",
},
},
},
Expand Down
6 changes: 3 additions & 3 deletions collectors/daemonset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package collectors
import (
"testing"

"k8s.io/client-go/pkg/api/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/pkg/apis/extensions/v1beta1"
)

Expand Down Expand Up @@ -53,7 +53,7 @@ func TestDaemonSetCollector(t *testing.T) {
{
dss: []v1beta1.DaemonSet{
{
ObjectMeta: v1.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: "ds1",
Namespace: "ns1",
Generation: 21,
Expand All @@ -65,7 +65,7 @@ func TestDaemonSetCollector(t *testing.T) {
NumberReady: 5,
},
}, {
ObjectMeta: v1.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: "ds2",
Namespace: "ns2",
Generation: 14,
Expand Down
2 changes: 1 addition & 1 deletion collectors/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/pkg/api"
"k8s.io/client-go/pkg/apis/extensions/v1beta1"
"k8s.io/client-go/pkg/util/intstr"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/client-go/tools/cache"
)

Expand Down
16 changes: 8 additions & 8 deletions collectors/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import (
dto "github.com/prometheus/client_model/go"
"github.com/prometheus/common/expfmt"

"k8s.io/client-go/pkg/api/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/client-go/pkg/apis/extensions/v1beta1"
"k8s.io/client-go/pkg/util/intstr"
)

var (
Expand Down Expand Up @@ -81,9 +81,9 @@ func TestDeploymentCollector(t *testing.T) {
{
depls: []v1beta1.Deployment{
{
ObjectMeta: v1.ObjectMeta{
Name: "depl1",
Namespace: "ns1",
ObjectMeta: metav1.ObjectMeta{
Name: "depl1",
Namespace: "ns1",
Labels: map[string]string{
"app": "example1",
},
Expand All @@ -105,9 +105,9 @@ func TestDeploymentCollector(t *testing.T) {
},
},
}, {
ObjectMeta: v1.ObjectMeta{
Name: "depl2",
Namespace: "ns2",
ObjectMeta: metav1.ObjectMeta{
Name: "depl2",
Namespace: "ns2",
Labels: map[string]string{
"app": "example2",
},
Expand Down
103 changes: 50 additions & 53 deletions collectors/job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,26 @@ limitations under the License.
package collectors

import (
"time"
"testing"
"time"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/pkg/api/unversioned"
v1batch "k8s.io/client-go/pkg/apis/batch/v1"
)

var (
Parallelism1 int32 = 1
Completions1 int32 = 1
Parallelism1 int32 = 1
Completions1 int32 = 1
ActiveDeadlineSeconds900 int64 = 900

RunningJob1StartTime, _ = time.Parse(time.RFC3339, "2017-05-26T12:00:07Z")
RunningJob1StartTime, _ = time.Parse(time.RFC3339, "2017-05-26T12:00:07Z")
SuccessfulJob1StartTime, _ = time.Parse(time.RFC3339, "2017-05-26T12:00:07Z")
FailedJob1StartTime, _ = time.Parse(time.RFC3339, "2017-05-26T14:00:07Z")
FailedJob1StartTime, _ = time.Parse(time.RFC3339, "2017-05-26T14:00:07Z")
SuccessfulJob2StartTime, _ = time.Parse(time.RFC3339, "2017-05-26T12:10:07Z")

SuccessfulJob1CompletionTime, _ = time.Parse(time.RFC3339, "2017-05-26T13:00:07Z")
FailedJob1CompletionTime, _ = time.Parse(time.RFC3339, "2017-05-26T15:00:07Z")
FailedJob1CompletionTime, _ = time.Parse(time.RFC3339, "2017-05-26T15:00:07Z")
SuccessfulJob2CompletionTime, _ = time.Parse(time.RFC3339, "2017-05-26T13:10:07Z")
)

Expand Down Expand Up @@ -77,93 +77,90 @@ func TestJobCollector(t *testing.T) {
`
cases := []struct {
jobs []v1batch.Job
want string
want string
}{
{
jobs: []v1batch.Job{
{
ObjectMeta: v1.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: "RunningJob1",
Namespace: "ns1",
Generation: 1,
},
Status: v1batch.JobStatus{
Active: 1,
Failed: 0,
Succeeded: 0,
CompletionTime: nil,
StartTime: &unversioned.Time{Time: RunningJob1StartTime},
Active: 1,
Failed: 0,
Succeeded: 0,
CompletionTime: nil,
StartTime: &metav1.Time{Time: RunningJob1StartTime},
},
Spec: v1batch.JobSpec{
ActiveDeadlineSeconds: &ActiveDeadlineSeconds900,
Parallelism: &Parallelism1,
Completions: &Completions1,
ActiveDeadlineSeconds: &ActiveDeadlineSeconds900,
Parallelism: &Parallelism1,
Completions: &Completions1,
},
}, {
ObjectMeta: v1.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: "SuccessfulJob1",
Namespace: "ns1",
Generation: 1,
},
Status: v1batch.JobStatus{
Active: 0,
Failed: 0,
Succeeded: 1,
CompletionTime: &unversioned.Time{Time: SuccessfulJob1CompletionTime},
StartTime: &unversioned.Time{Time: SuccessfulJob1StartTime},
Conditions: []v1batch.JobCondition{
Active: 0,
Failed: 0,
Succeeded: 1,
CompletionTime: &metav1.Time{Time: SuccessfulJob1CompletionTime},
StartTime: &metav1.Time{Time: SuccessfulJob1StartTime},
Conditions: []v1batch.JobCondition{
{Type: v1batch.JobComplete, Status: v1.ConditionTrue},
},

},
},
Spec: v1batch.JobSpec{
ActiveDeadlineSeconds: &ActiveDeadlineSeconds900,
Parallelism: &Parallelism1,
Completions: &Completions1,
ActiveDeadlineSeconds: &ActiveDeadlineSeconds900,
Parallelism: &Parallelism1,
Completions: &Completions1,
},
}, {
ObjectMeta: v1.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: "FailedJob1",
Namespace: "ns1",
Generation: 1,
},
Status: v1batch.JobStatus{
Active: 0,
Failed: 1,
Succeeded: 0,
CompletionTime: &unversioned.Time{Time: FailedJob1CompletionTime},
StartTime: &unversioned.Time{Time: FailedJob1StartTime},
Conditions: []v1batch.JobCondition{
Active: 0,
Failed: 1,
Succeeded: 0,
CompletionTime: &metav1.Time{Time: FailedJob1CompletionTime},
StartTime: &metav1.Time{Time: FailedJob1StartTime},
Conditions: []v1batch.JobCondition{
{Type: v1batch.JobFailed, Status: v1.ConditionTrue},
},

},
},
Spec: v1batch.JobSpec{
ActiveDeadlineSeconds: &ActiveDeadlineSeconds900,
Parallelism: &Parallelism1,
Completions: &Completions1,
ActiveDeadlineSeconds: &ActiveDeadlineSeconds900,
Parallelism: &Parallelism1,
Completions: &Completions1,
},
}, {
ObjectMeta: v1.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: "SuccessfulJob2NoActiveDeadlineSeconds",
Namespace: "ns1",
Generation: 1,
},
Status: v1batch.JobStatus{
Active: 0,
Failed: 0,
Succeeded: 1,
CompletionTime: &unversioned.Time{Time: SuccessfulJob2CompletionTime},
StartTime: &unversioned.Time{Time: SuccessfulJob2StartTime},
Conditions: []v1batch.JobCondition{
Active: 0,
Failed: 0,
Succeeded: 1,
CompletionTime: &metav1.Time{Time: SuccessfulJob2CompletionTime},
StartTime: &metav1.Time{Time: SuccessfulJob2StartTime},
Conditions: []v1batch.JobCondition{
{Type: v1batch.JobComplete, Status: v1.ConditionTrue},
},

},
},
Spec: v1batch.JobSpec{
ActiveDeadlineSeconds: nil,
Parallelism: &Parallelism1,
Completions: &Completions1,
ActiveDeadlineSeconds: nil,
Parallelism: &Parallelism1,
Completions: &Completions1,
},
},
},
Expand Down
5 changes: 3 additions & 2 deletions collectors/limitrange_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ package collectors
import (
"testing"

"k8s.io/client-go/pkg/api/resource"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/pkg/api/v1"
)

Expand Down Expand Up @@ -48,7 +49,7 @@ func TestLimitRangeollector(t *testing.T) {
{
ranges: []v1.LimitRange{
{
ObjectMeta: v1.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: "quotaTest",
Namespace: "testNS",
},
Expand Down
Loading

0 comments on commit 1f8761d

Please sign in to comment.