Commit 7eeb71f6 authored by Chao Xu's avatar Chao Xu

cmd/kube-controller-manager

parent 48536eae
...@@ -34,10 +34,11 @@ import ( ...@@ -34,10 +34,11 @@ import (
"k8s.io/kubernetes/cmd/kube-controller-manager/app/options" "k8s.io/kubernetes/cmd/kube-controller-manager/app/options"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apimachinery/registered" "k8s.io/kubernetes/pkg/apimachinery/registered"
"k8s.io/kubernetes/pkg/apis/batch" "k8s.io/kubernetes/pkg/apis/batch"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" clientset "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5"
unversionedcore "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion" v1core "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5/typed/core/v1"
"k8s.io/kubernetes/pkg/client/leaderelection" "k8s.io/kubernetes/pkg/client/leaderelection"
"k8s.io/kubernetes/pkg/client/leaderelection/resourcelock" "k8s.io/kubernetes/pkg/client/leaderelection/resourcelock"
"k8s.io/kubernetes/pkg/client/record" "k8s.io/kubernetes/pkg/client/record"
...@@ -159,8 +160,8 @@ func Run(s *options.CMServer) error { ...@@ -159,8 +160,8 @@ func Run(s *options.CMServer) error {
eventBroadcaster := record.NewBroadcaster() eventBroadcaster := record.NewBroadcaster()
eventBroadcaster.StartLogging(glog.Infof) eventBroadcaster.StartLogging(glog.Infof)
eventBroadcaster.StartRecordingToSink(&unversionedcore.EventSinkImpl{Interface: kubeClient.Core().Events("")}) eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: kubeClient.Core().Events("")})
recorder := eventBroadcaster.NewRecorder(api.EventSource{Component: "controller-manager"}) recorder := eventBroadcaster.NewRecorder(v1.EventSource{Component: "controller-manager"})
run := func(stop <-chan struct{}) { run := func(stop <-chan struct{}) {
rootClientBuilder := controller.SimpleControllerClientBuilder{ rootClientBuilder := controller.SimpleControllerClientBuilder{
...@@ -194,7 +195,7 @@ func Run(s *options.CMServer) error { ...@@ -194,7 +195,7 @@ func Run(s *options.CMServer) error {
// TODO: enable other lock types // TODO: enable other lock types
rl := resourcelock.EndpointsLock{ rl := resourcelock.EndpointsLock{
EndpointsMeta: api.ObjectMeta{ EndpointsMeta: v1.ObjectMeta{
Namespace: "kube-system", Namespace: "kube-system",
Name: "kube-controller-manager", Name: "kube-controller-manager",
}, },
...@@ -225,7 +226,7 @@ func StartControllers(s *options.CMServer, kubeconfig *restclient.Config, rootCl ...@@ -225,7 +226,7 @@ func StartControllers(s *options.CMServer, kubeconfig *restclient.Config, rootCl
return rootClientBuilder.ClientOrDie(serviceAccountName) return rootClientBuilder.ClientOrDie(serviceAccountName)
} }
discoveryClient := client("controller-discovery").Discovery() discoveryClient := client("controller-discovery").Discovery()
sharedInformers := informers.NewSharedInformerFactory(client("shared-informers"), ResyncPeriod(s)()) sharedInformers := informers.NewSharedInformerFactory(client("shared-informers"), nil, ResyncPeriod(s)())
// always start the SA token controller first using a full-power client, since it needs to mint tokens for the rest // always start the SA token controller first using a full-power client, since it needs to mint tokens for the rest
if len(s.ServiceAccountKeyFile) > 0 { if len(s.ServiceAccountKeyFile) > 0 {
...@@ -392,7 +393,7 @@ func StartControllers(s *options.CMServer, kubeconfig *restclient.Config, rootCl ...@@ -392,7 +393,7 @@ func StartControllers(s *options.CMServer, kubeconfig *restclient.Config, rootCl
return gvr, nil return gvr, nil
} }
} }
namespaceController := namespacecontroller.NewNamespaceController(namespaceKubeClient, namespaceClientPool, gvrFn, s.NamespaceSyncPeriod.Duration, api.FinalizerKubernetes) namespaceController := namespacecontroller.NewNamespaceController(namespaceKubeClient, namespaceClientPool, gvrFn, s.NamespaceSyncPeriod.Duration, v1.FinalizerKubernetes)
go namespaceController.Run(int(s.ConcurrentNamespaceSyncs), wait.NeverStop) go namespaceController.Run(int(s.ConcurrentNamespaceSyncs), wait.NeverStop)
time.Sleep(wait.Jitter(s.ControllerStartInterval.Duration, ControllerStartJitter)) time.Sleep(wait.Jitter(s.ControllerStartInterval.Duration, ControllerStartJitter))
......
...@@ -22,11 +22,11 @@ import ( ...@@ -22,11 +22,11 @@ import (
"strings" "strings"
"time" "time"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apis/certificates" certificates "k8s.io/kubernetes/pkg/apis/certificates/v1alpha1"
"k8s.io/kubernetes/pkg/client/cache" "k8s.io/kubernetes/pkg/client/cache"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" clientset "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5"
unversionedcore "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion" v1core "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5/typed/core/v1"
"k8s.io/kubernetes/pkg/client/record" "k8s.io/kubernetes/pkg/client/record"
"k8s.io/kubernetes/pkg/controller" "k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/runtime"
...@@ -62,7 +62,7 @@ func NewCertificateController(kubeClient clientset.Interface, syncPeriod time.Du ...@@ -62,7 +62,7 @@ func NewCertificateController(kubeClient clientset.Interface, syncPeriod time.Du
// Send events to the apiserver // Send events to the apiserver
eventBroadcaster := record.NewBroadcaster() eventBroadcaster := record.NewBroadcaster()
eventBroadcaster.StartLogging(glog.Infof) eventBroadcaster.StartLogging(glog.Infof)
eventBroadcaster.StartRecordingToSink(&unversionedcore.EventSinkImpl{Interface: kubeClient.Core().Events("")}) eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: kubeClient.Core().Events("")})
// Configure cfssl signer // Configure cfssl signer
// TODO: support non-default policy and remote/pkcs11 signing // TODO: support non-default policy and remote/pkcs11 signing
...@@ -84,10 +84,10 @@ func NewCertificateController(kubeClient clientset.Interface, syncPeriod time.Du ...@@ -84,10 +84,10 @@ func NewCertificateController(kubeClient clientset.Interface, syncPeriod time.Du
// Manage the addition/update of certificate requests // Manage the addition/update of certificate requests
cc.csrStore.Store, cc.csrController = cache.NewInformer( cc.csrStore.Store, cc.csrController = cache.NewInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options api.ListOptions) (runtime.Object, error) { ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return cc.kubeClient.Certificates().CertificateSigningRequests().List(options) return cc.kubeClient.Certificates().CertificateSigningRequests().List(options)
}, },
WatchFunc: func(options api.ListOptions) (watch.Interface, error) { WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return cc.kubeClient.Certificates().CertificateSigningRequests().Watch(options) return cc.kubeClient.Certificates().CertificateSigningRequests().Watch(options)
}, },
}, },
...@@ -240,7 +240,7 @@ func (cc *CertificateController) maybeAutoApproveCSR(csr *certificates.Certifica ...@@ -240,7 +240,7 @@ func (cc *CertificateController) maybeAutoApproveCSR(csr *certificates.Certifica
return csr, nil return csr, nil
} }
x509cr, err := certutil.ParseCSR(csr) x509cr, err := certutil.ParseCSRV1alpha1(csr)
if err != nil { if err != nil {
utilruntime.HandleError(fmt.Errorf("unable to parse csr %q: %v", csr.Name, err)) utilruntime.HandleError(fmt.Errorf("unable to parse csr %q: %v", csr.Name, err))
return csr, nil return csr, nil
......
...@@ -16,7 +16,7 @@ limitations under the License. ...@@ -16,7 +16,7 @@ limitations under the License.
package certificates package certificates
import "k8s.io/kubernetes/pkg/apis/certificates" import certificates "k8s.io/kubernetes/pkg/apis/certificates/v1alpha1"
// IsCertificateRequestApproved returns true if a certificate request has the // IsCertificateRequestApproved returns true if a certificate request has the
// "Approved" condition and no "Denied" conditions; false otherwise. // "Approved" condition and no "Denied" conditions; false otherwise.
......
...@@ -22,9 +22,10 @@ import ( ...@@ -22,9 +22,10 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
apierrors "k8s.io/kubernetes/pkg/api/errors" apierrors "k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/client/cache" "k8s.io/kubernetes/pkg/client/cache"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" clientset "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5"
unversionedcore "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion" v1core "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5/typed/core/v1"
"k8s.io/kubernetes/pkg/client/restclient" "k8s.io/kubernetes/pkg/client/restclient"
"k8s.io/kubernetes/pkg/fields" "k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/runtime"
...@@ -76,7 +77,7 @@ type SAControllerClientBuilder struct { ...@@ -76,7 +77,7 @@ type SAControllerClientBuilder struct {
// CoreClient is used to provision service accounts if needed and watch for their associated tokens // CoreClient is used to provision service accounts if needed and watch for their associated tokens
// to construct a controller client // to construct a controller client
CoreClient unversionedcore.CoreInterface CoreClient v1core.CoreV1Interface
// Namespace is the namespace used to host the service accounts that will back the // Namespace is the namespace used to host the service accounts that will back the
// controllers. It must be highly privileged namespace which normal users cannot inspect. // controllers. It must be highly privileged namespace which normal users cannot inspect.
...@@ -96,26 +97,26 @@ func (b SAControllerClientBuilder) Config(name string) (*restclient.Config, erro ...@@ -96,26 +97,26 @@ func (b SAControllerClientBuilder) Config(name string) (*restclient.Config, erro
// check to see if the namespace exists. If it isn't a NotFound, just try to create the SA. // check to see if the namespace exists. If it isn't a NotFound, just try to create the SA.
// It'll probably fail, but perhaps that will have a better message. // It'll probably fail, but perhaps that will have a better message.
if _, err := b.CoreClient.Namespaces().Get(b.Namespace); apierrors.IsNotFound(err) { if _, err := b.CoreClient.Namespaces().Get(b.Namespace); apierrors.IsNotFound(err) {
_, err = b.CoreClient.Namespaces().Create(&api.Namespace{ObjectMeta: api.ObjectMeta{Name: b.Namespace}}) _, err = b.CoreClient.Namespaces().Create(&v1.Namespace{ObjectMeta: v1.ObjectMeta{Name: b.Namespace}})
if err != nil && !apierrors.IsAlreadyExists(err) { if err != nil && !apierrors.IsAlreadyExists(err) {
return nil, err return nil, err
} }
} }
sa, err = b.CoreClient.ServiceAccounts(b.Namespace).Create( sa, err = b.CoreClient.ServiceAccounts(b.Namespace).Create(
&api.ServiceAccount{ObjectMeta: api.ObjectMeta{Namespace: b.Namespace, Name: name}}) &v1.ServiceAccount{ObjectMeta: v1.ObjectMeta{Namespace: b.Namespace, Name: name}})
if err != nil { if err != nil {
return nil, err return nil, err
} }
} }
lw := &cache.ListWatch{ lw := &cache.ListWatch{
ListFunc: func(options api.ListOptions) (runtime.Object, error) { ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
options.FieldSelector = fields.SelectorFromSet(map[string]string{api.SecretTypeField: string(api.SecretTypeServiceAccountToken)}) options.FieldSelector = fields.SelectorFromSet(map[string]string{api.SecretTypeField: string(v1.SecretTypeServiceAccountToken)}).String()
return b.CoreClient.Secrets(b.Namespace).List(options) return b.CoreClient.Secrets(b.Namespace).List(options)
}, },
WatchFunc: func(options api.ListOptions) (watch.Interface, error) { WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
options.FieldSelector = fields.SelectorFromSet(map[string]string{api.SecretTypeField: string(api.SecretTypeServiceAccountToken)}) options.FieldSelector = fields.SelectorFromSet(map[string]string{api.SecretTypeField: string(v1.SecretTypeServiceAccountToken)}).String()
return b.CoreClient.Secrets(b.Namespace).Watch(options) return b.CoreClient.Secrets(b.Namespace).Watch(options)
}, },
} }
...@@ -128,13 +129,13 @@ func (b SAControllerClientBuilder) Config(name string) (*restclient.Config, erro ...@@ -128,13 +129,13 @@ func (b SAControllerClientBuilder) Config(name string) (*restclient.Config, erro
return false, fmt.Errorf("error watching") return false, fmt.Errorf("error watching")
case watch.Added, watch.Modified: case watch.Added, watch.Modified:
secret := event.Object.(*api.Secret) secret := event.Object.(*v1.Secret)
if !serviceaccount.IsServiceAccountToken(secret, sa) || if !serviceaccount.IsServiceAccountToken(secret, sa) ||
len(secret.Data[api.ServiceAccountTokenKey]) == 0 { len(secret.Data[v1.ServiceAccountTokenKey]) == 0 {
return false, nil return false, nil
} }
// TODO maybe verify the token is valid // TODO maybe verify the token is valid
clientConfig.BearerToken = string(secret.Data[api.ServiceAccountTokenKey]) clientConfig.BearerToken = string(secret.Data[v1.ServiceAccountTokenKey])
restclient.AddUserAgent(clientConfig, serviceaccount.MakeUsername(b.Namespace, name)) restclient.AddUserAgent(clientConfig, serviceaccount.MakeUsername(b.Namespace, name))
return true, nil return true, nil
......
...@@ -21,15 +21,15 @@ import ( ...@@ -21,15 +21,15 @@ import (
"strings" "strings"
"github.com/golang/glog" "github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors" "k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/labels"
) )
type PodControllerRefManager struct { type PodControllerRefManager struct {
podControl PodControlInterface podControl PodControlInterface
controllerObject api.ObjectMeta controllerObject v1.ObjectMeta
controllerSelector labels.Selector controllerSelector labels.Selector
controllerKind unversioned.GroupVersionKind controllerKind unversioned.GroupVersionKind
} }
...@@ -38,7 +38,7 @@ type PodControllerRefManager struct { ...@@ -38,7 +38,7 @@ type PodControllerRefManager struct {
// methods to manage the controllerRef of pods. // methods to manage the controllerRef of pods.
func NewPodControllerRefManager( func NewPodControllerRefManager(
podControl PodControlInterface, podControl PodControlInterface,
controllerObject api.ObjectMeta, controllerObject v1.ObjectMeta,
controllerSelector labels.Selector, controllerSelector labels.Selector,
controllerKind unversioned.GroupVersionKind, controllerKind unversioned.GroupVersionKind,
) *PodControllerRefManager { ) *PodControllerRefManager {
...@@ -53,10 +53,10 @@ func NewPodControllerRefManager( ...@@ -53,10 +53,10 @@ func NewPodControllerRefManager(
// controllerRef pointing to other object are ignored) 3. controlledDoesNotMatch // controllerRef pointing to other object are ignored) 3. controlledDoesNotMatch
// are the pods that have a controllerRef pointing to the controller, but their // are the pods that have a controllerRef pointing to the controller, but their
// labels no longer match the selector. // labels no longer match the selector.
func (m *PodControllerRefManager) Classify(pods []*api.Pod) ( func (m *PodControllerRefManager) Classify(pods []*v1.Pod) (
matchesAndControlled []*api.Pod, matchesAndControlled []*v1.Pod,
matchesNeedsController []*api.Pod, matchesNeedsController []*v1.Pod,
controlledDoesNotMatch []*api.Pod) { controlledDoesNotMatch []*v1.Pod) {
for i := range pods { for i := range pods {
pod := pods[i] pod := pods[i]
if !IsPodActive(pod) { if !IsPodActive(pod) {
...@@ -91,7 +91,7 @@ func (m *PodControllerRefManager) Classify(pods []*api.Pod) ( ...@@ -91,7 +91,7 @@ func (m *PodControllerRefManager) Classify(pods []*api.Pod) (
// getControllerOf returns the controllerRef if controllee has a controller, // getControllerOf returns the controllerRef if controllee has a controller,
// otherwise returns nil. // otherwise returns nil.
func getControllerOf(controllee api.ObjectMeta) *api.OwnerReference { func getControllerOf(controllee v1.ObjectMeta) *v1.OwnerReference {
for _, owner := range controllee.OwnerReferences { for _, owner := range controllee.OwnerReferences {
// controlled by other controller // controlled by other controller
if owner.Controller != nil && *owner.Controller == true { if owner.Controller != nil && *owner.Controller == true {
...@@ -103,7 +103,7 @@ func getControllerOf(controllee api.ObjectMeta) *api.OwnerReference { ...@@ -103,7 +103,7 @@ func getControllerOf(controllee api.ObjectMeta) *api.OwnerReference {
// AdoptPod sends a patch to take control of the pod. It returns the error if // AdoptPod sends a patch to take control of the pod. It returns the error if
// the patching fails. // the patching fails.
func (m *PodControllerRefManager) AdoptPod(pod *api.Pod) error { func (m *PodControllerRefManager) AdoptPod(pod *v1.Pod) error {
// we should not adopt any pods if the controller is about to be deleted // we should not adopt any pods if the controller is about to be deleted
if m.controllerObject.DeletionTimestamp != nil { if m.controllerObject.DeletionTimestamp != nil {
return fmt.Errorf("cancel the adopt attempt for pod %s because the controlller is being deleted", return fmt.Errorf("cancel the adopt attempt for pod %s because the controlller is being deleted",
...@@ -118,7 +118,7 @@ func (m *PodControllerRefManager) AdoptPod(pod *api.Pod) error { ...@@ -118,7 +118,7 @@ func (m *PodControllerRefManager) AdoptPod(pod *api.Pod) error {
// ReleasePod sends a patch to free the pod from the control of the controller. // ReleasePod sends a patch to free the pod from the control of the controller.
// It returns the error if the patching fails. 404 and 422 errors are ignored. // It returns the error if the patching fails. 404 and 422 errors are ignored.
func (m *PodControllerRefManager) ReleasePod(pod *api.Pod) error { func (m *PodControllerRefManager) ReleasePod(pod *v1.Pod) error {
glog.V(2).Infof("patching pod %s_%s to remove its controllerRef to %s/%s:%s", glog.V(2).Infof("patching pod %s_%s to remove its controllerRef to %s/%s:%s",
pod.Namespace, pod.Name, m.controllerKind.GroupVersion(), m.controllerKind.Kind, m.controllerObject.Name) pod.Namespace, pod.Name, m.controllerKind.GroupVersion(), m.controllerKind.Kind, m.controllerObject.Name)
deleteOwnerRefPatch := fmt.Sprintf(`{"metadata":{"ownerReferences":[{"$patch":"delete","uid":"%s"}],"uid":"%s"}}`, m.controllerObject.UID, pod.UID) deleteOwnerRefPatch := fmt.Sprintf(`{"metadata":{"ownerReferences":[{"$patch":"delete","uid":"%s"}],"uid":"%s"}}`, m.controllerObject.UID, pod.UID)
......
...@@ -34,14 +34,13 @@ import ( ...@@ -34,14 +34,13 @@ import (
"github.com/golang/glog" "github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors" "k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apis/batch" "k8s.io/kubernetes/pkg/api/v1"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" batch "k8s.io/kubernetes/pkg/apis/batch/v2alpha1"
unversionedcore "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion" clientset "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5"
v1core "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5/typed/core/v1"
"k8s.io/kubernetes/pkg/client/record" "k8s.io/kubernetes/pkg/client/record"
"k8s.io/kubernetes/pkg/controller/job"
"k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/runtime"
utilerrors "k8s.io/kubernetes/pkg/util/errors" utilerrors "k8s.io/kubernetes/pkg/util/errors"
"k8s.io/kubernetes/pkg/util/metrics" "k8s.io/kubernetes/pkg/util/metrics"
...@@ -63,7 +62,7 @@ func NewCronJobController(kubeClient clientset.Interface) *CronJobController { ...@@ -63,7 +62,7 @@ func NewCronJobController(kubeClient clientset.Interface) *CronJobController {
eventBroadcaster := record.NewBroadcaster() eventBroadcaster := record.NewBroadcaster()
eventBroadcaster.StartLogging(glog.Infof) eventBroadcaster.StartLogging(glog.Infof)
// TODO: remove the wrapper when every clients have moved to use the clientset. // TODO: remove the wrapper when every clients have moved to use the clientset.
eventBroadcaster.StartRecordingToSink(&unversionedcore.EventSinkImpl{Interface: kubeClient.Core().Events("")}) eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: kubeClient.Core().Events("")})
if kubeClient != nil && kubeClient.Core().RESTClient().GetRateLimiter() != nil { if kubeClient != nil && kubeClient.Core().RESTClient().GetRateLimiter() != nil {
metrics.RegisterMetricAndTrackRateLimiterUsage("cronjob_controller", kubeClient.Core().RESTClient().GetRateLimiter()) metrics.RegisterMetricAndTrackRateLimiterUsage("cronjob_controller", kubeClient.Core().RESTClient().GetRateLimiter())
...@@ -74,7 +73,7 @@ func NewCronJobController(kubeClient clientset.Interface) *CronJobController { ...@@ -74,7 +73,7 @@ func NewCronJobController(kubeClient clientset.Interface) *CronJobController {
jobControl: realJobControl{KubeClient: kubeClient}, jobControl: realJobControl{KubeClient: kubeClient},
sjControl: &realSJControl{KubeClient: kubeClient}, sjControl: &realSJControl{KubeClient: kubeClient},
podControl: &realPodControl{KubeClient: kubeClient}, podControl: &realPodControl{KubeClient: kubeClient},
recorder: eventBroadcaster.NewRecorder(api.EventSource{Component: "cronjob-controller"}), recorder: eventBroadcaster.NewRecorder(v1.EventSource{Component: "cronjob-controller"}),
} }
return jm return jm
...@@ -97,7 +96,7 @@ func (jm *CronJobController) Run(stopCh <-chan struct{}) { ...@@ -97,7 +96,7 @@ func (jm *CronJobController) Run(stopCh <-chan struct{}) {
// SyncAll lists all the CronJobs and Jobs and reconciles them. // SyncAll lists all the CronJobs and Jobs and reconciles them.
func (jm *CronJobController) SyncAll() { func (jm *CronJobController) SyncAll() {
sjl, err := jm.kubeClient.Batch().CronJobs(api.NamespaceAll).List(api.ListOptions{}) sjl, err := jm.kubeClient.BatchV2alpha1().CronJobs(v1.NamespaceAll).List(v1.ListOptions{})
if err != nil { if err != nil {
glog.Errorf("Error listing cronjobs: %v", err) glog.Errorf("Error listing cronjobs: %v", err)
return return
...@@ -105,7 +104,7 @@ func (jm *CronJobController) SyncAll() { ...@@ -105,7 +104,7 @@ func (jm *CronJobController) SyncAll() {
sjs := sjl.Items sjs := sjl.Items
glog.V(4).Infof("Found %d cronjobs", len(sjs)) glog.V(4).Infof("Found %d cronjobs", len(sjs))
jl, err := jm.kubeClient.Batch().Jobs(api.NamespaceAll).List(api.ListOptions{}) jl, err := jm.kubeClient.BatchV2alpha1().Jobs(v1.NamespaceAll).List(v1.ListOptions{})
if err != nil { if err != nil {
glog.Errorf("Error listing jobs") glog.Errorf("Error listing jobs")
return return
...@@ -131,8 +130,8 @@ func SyncOne(sj batch.CronJob, js []batch.Job, now time.Time, jc jobControlInter ...@@ -131,8 +130,8 @@ func SyncOne(sj batch.CronJob, js []batch.Job, now time.Time, jc jobControlInter
for i := range js { for i := range js {
j := js[i] j := js[i]
found := inActiveList(sj, j.ObjectMeta.UID) found := inActiveList(sj, j.ObjectMeta.UID)
if !found && !job.IsJobFinished(&j) { if !found && !IsJobFinished(&j) {
recorder.Eventf(&sj, api.EventTypeWarning, "UnexpectedJob", "Saw a job that the controller did not create or forgot: %v", j.Name) recorder.Eventf(&sj, v1.EventTypeWarning, "UnexpectedJob", "Saw a job that the controller did not create or forgot: %v", j.Name)
// We found an unfinished job that has us as the parent, but it is not in our Active list. // We found an unfinished job that has us as the parent, but it is not in our Active list.
// This could happen if we crashed right after creating the Job and before updating the status, // This could happen if we crashed right after creating the Job and before updating the status,
// or if our jobs list is newer than our sj status after a relist, or if someone intentionally created // or if our jobs list is newer than our sj status after a relist, or if someone intentionally created
...@@ -143,10 +142,10 @@ func SyncOne(sj batch.CronJob, js []batch.Job, now time.Time, jc jobControlInter ...@@ -143,10 +142,10 @@ func SyncOne(sj batch.CronJob, js []batch.Job, now time.Time, jc jobControlInter
// user has permission to create a job within a namespace, then they have permission to make any scheduledJob // user has permission to create a job within a namespace, then they have permission to make any scheduledJob
// in the same namespace "adopt" that job. ReplicaSets and their Pods work the same way. // in the same namespace "adopt" that job. ReplicaSets and their Pods work the same way.
// TBS: how to update sj.Status.LastScheduleTime if the adopted job is newer than any we knew about? // TBS: how to update sj.Status.LastScheduleTime if the adopted job is newer than any we knew about?
} else if found && job.IsJobFinished(&j) { } else if found && IsJobFinished(&j) {
deleteFromActiveList(&sj, j.ObjectMeta.UID) deleteFromActiveList(&sj, j.ObjectMeta.UID)
// TODO: event to call out failure vs success. // TODO: event to call out failure vs success.
recorder.Eventf(&sj, api.EventTypeNormal, "SawCompletedJob", "Saw completed job: %v", j.Name) recorder.Eventf(&sj, v1.EventTypeNormal, "SawCompletedJob", "Saw completed job: %v", j.Name)
} }
} }
updatedSJ, err := sjc.UpdateStatus(&sj) updatedSJ, err := sjc.UpdateStatus(&sj)
...@@ -209,7 +208,7 @@ func SyncOne(sj batch.CronJob, js []batch.Job, now time.Time, jc jobControlInter ...@@ -209,7 +208,7 @@ func SyncOne(sj batch.CronJob, js []batch.Job, now time.Time, jc jobControlInter
glog.V(4).Infof("Deleting job %s of %s that was still running at next scheduled start time", j.Name, nameForLog) glog.V(4).Infof("Deleting job %s of %s that was still running at next scheduled start time", j.Name, nameForLog)
job, err := jc.GetJob(j.Namespace, j.Name) job, err := jc.GetJob(j.Namespace, j.Name)
if err != nil { if err != nil {
recorder.Eventf(&sj, api.EventTypeWarning, "FailedGet", "Get job: %v", err) recorder.Eventf(&sj, v1.EventTypeWarning, "FailedGet", "Get job: %v", err)
return return
} }
// scale job down to 0 // scale job down to 0
...@@ -218,16 +217,16 @@ func SyncOne(sj batch.CronJob, js []batch.Job, now time.Time, jc jobControlInter ...@@ -218,16 +217,16 @@ func SyncOne(sj batch.CronJob, js []batch.Job, now time.Time, jc jobControlInter
job.Spec.Parallelism = &zero job.Spec.Parallelism = &zero
job, err = jc.UpdateJob(job.Namespace, job) job, err = jc.UpdateJob(job.Namespace, job)
if err != nil { if err != nil {
recorder.Eventf(&sj, api.EventTypeWarning, "FailedUpdate", "Update job: %v", err) recorder.Eventf(&sj, v1.EventTypeWarning, "FailedUpdate", "Update job: %v", err)
return return
} }
} }
// remove all pods... // remove all pods...
selector, _ := unversioned.LabelSelectorAsSelector(job.Spec.Selector) selector, _ := unversioned.LabelSelectorAsSelector(job.Spec.Selector)
options := api.ListOptions{LabelSelector: selector} options := v1.ListOptions{LabelSelector: selector.String()}
podList, err := pc.ListPods(job.Namespace, options) podList, err := pc.ListPods(job.Namespace, options)
if err != nil { if err != nil {
recorder.Eventf(&sj, api.EventTypeWarning, "FailedList", "List job-pods: %v", err) recorder.Eventf(&sj, v1.EventTypeWarning, "FailedList", "List job-pods: %v", err)
} }
errList := []error{} errList := []error{}
for _, pod := range podList.Items { for _, pod := range podList.Items {
...@@ -240,18 +239,18 @@ func SyncOne(sj batch.CronJob, js []batch.Job, now time.Time, jc jobControlInter ...@@ -240,18 +239,18 @@ func SyncOne(sj batch.CronJob, js []batch.Job, now time.Time, jc jobControlInter
} }
} }
if len(errList) != 0 { if len(errList) != 0 {
recorder.Eventf(&sj, api.EventTypeWarning, "FailedDelete", "Deleted job-pods: %v", utilerrors.NewAggregate(errList)) recorder.Eventf(&sj, v1.EventTypeWarning, "FailedDelete", "Deleted job-pods: %v", utilerrors.NewAggregate(errList))
return return
} }
// ... the job itself... // ... the job itself...
if err := jc.DeleteJob(job.Namespace, job.Name); err != nil { if err := jc.DeleteJob(job.Namespace, job.Name); err != nil {
recorder.Eventf(&sj, api.EventTypeWarning, "FailedDelete", "Deleted job: %v", err) recorder.Eventf(&sj, v1.EventTypeWarning, "FailedDelete", "Deleted job: %v", err)
glog.Errorf("Error deleting job %s from %s: %v", job.Name, nameForLog, err) glog.Errorf("Error deleting job %s from %s: %v", job.Name, nameForLog, err)
return return
} }
// ... and its reference from active list // ... and its reference from active list
deleteFromActiveList(&sj, job.ObjectMeta.UID) deleteFromActiveList(&sj, job.ObjectMeta.UID)
recorder.Eventf(&sj, api.EventTypeNormal, "SuccessfulDelete", "Deleted job %v", j.Name) recorder.Eventf(&sj, v1.EventTypeNormal, "SuccessfulDelete", "Deleted job %v", j.Name)
} }
} }
...@@ -262,11 +261,11 @@ func SyncOne(sj batch.CronJob, js []batch.Job, now time.Time, jc jobControlInter ...@@ -262,11 +261,11 @@ func SyncOne(sj batch.CronJob, js []batch.Job, now time.Time, jc jobControlInter
} }
jobResp, err := jc.CreateJob(sj.Namespace, jobReq) jobResp, err := jc.CreateJob(sj.Namespace, jobReq)
if err != nil { if err != nil {
recorder.Eventf(&sj, api.EventTypeWarning, "FailedCreate", "Error creating job: %v", err) recorder.Eventf(&sj, v1.EventTypeWarning, "FailedCreate", "Error creating job: %v", err)
return return
} }
glog.V(4).Infof("Created Job %s for %s", jobResp.Name, nameForLog) glog.V(4).Infof("Created Job %s for %s", jobResp.Name, nameForLog)
recorder.Eventf(&sj, api.EventTypeNormal, "SuccessfulCreate", "Created job %v", jobResp.Name) recorder.Eventf(&sj, v1.EventTypeNormal, "SuccessfulCreate", "Created job %v", jobResp.Name)
// ------------------------------------------------------------------ // // ------------------------------------------------------------------ //
...@@ -293,6 +292,6 @@ func SyncOne(sj batch.CronJob, js []batch.Job, now time.Time, jc jobControlInter ...@@ -293,6 +292,6 @@ func SyncOne(sj batch.CronJob, js []batch.Job, now time.Time, jc jobControlInter
return return
} }
func getRef(object runtime.Object) (*api.ObjectReference, error) { func getRef(object runtime.Object) (*v1.ObjectReference, error) {
return api.GetReference(object) return v1.GetReference(object)
} }
...@@ -20,9 +20,9 @@ import ( ...@@ -20,9 +20,9 @@ import (
"testing" "testing"
"time" "time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apis/batch" "k8s.io/kubernetes/pkg/api/v1"
batch "k8s.io/kubernetes/pkg/apis/batch/v2alpha1"
"k8s.io/kubernetes/pkg/client/record" "k8s.io/kubernetes/pkg/client/record"
"k8s.io/kubernetes/pkg/types" "k8s.io/kubernetes/pkg/types"
) )
...@@ -75,7 +75,7 @@ func justAfterThePriorHour() time.Time { ...@@ -75,7 +75,7 @@ func justAfterThePriorHour() time.Time {
// returns a cronJob with some fields filled in. // returns a cronJob with some fields filled in.
func cronJob() batch.CronJob { func cronJob() batch.CronJob {
return batch.CronJob{ return batch.CronJob{
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Name: "mycronjob", Name: "mycronjob",
Namespace: "snazzycats", Namespace: "snazzycats",
UID: types.UID("1a2b3c"), UID: types.UID("1a2b3c"),
...@@ -86,7 +86,7 @@ func cronJob() batch.CronJob { ...@@ -86,7 +86,7 @@ func cronJob() batch.CronJob {
Schedule: "* * * * ?", Schedule: "* * * * ?",
ConcurrencyPolicy: batch.AllowConcurrent, ConcurrencyPolicy: batch.AllowConcurrent,
JobTemplate: batch.JobTemplateSpec{ JobTemplate: batch.JobTemplateSpec{
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Labels: map[string]string{"a": "b"}, Labels: map[string]string{"a": "b"},
Annotations: map[string]string{"x": "y"}, Annotations: map[string]string{"x": "y"},
}, },
...@@ -101,14 +101,14 @@ func jobSpec() batch.JobSpec { ...@@ -101,14 +101,14 @@ func jobSpec() batch.JobSpec {
return batch.JobSpec{ return batch.JobSpec{
Parallelism: &one, Parallelism: &one,
Completions: &one, Completions: &one,
Template: api.PodTemplateSpec{ Template: v1.PodTemplateSpec{
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Labels: map[string]string{ Labels: map[string]string{
"foo": "bar", "foo": "bar",
}, },
}, },
Spec: api.PodSpec{ Spec: v1.PodSpec{
Containers: []api.Container{ Containers: []v1.Container{
{Image: "foo/bar"}, {Image: "foo/bar"},
}, },
}, },
...@@ -118,10 +118,10 @@ func jobSpec() batch.JobSpec { ...@@ -118,10 +118,10 @@ func jobSpec() batch.JobSpec {
func newJob(UID string) batch.Job { func newJob(UID string) batch.Job {
return batch.Job{ return batch.Job{
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
UID: types.UID(UID), UID: types.UID(UID),
Name: "foobar", Name: "foobar",
Namespace: api.NamespaceDefault, Namespace: v1.NamespaceDefault,
SelfLink: "/apis/batch/v1/namespaces/snazzycats/jobs/myjob", SelfLink: "/apis/batch/v1/namespaces/snazzycats/jobs/myjob",
}, },
Spec: jobSpec(), Spec: jobSpec(),
...@@ -213,7 +213,7 @@ func TestSyncOne_RunOrNot(t *testing.T) { ...@@ -213,7 +213,7 @@ func TestSyncOne_RunOrNot(t *testing.T) {
job.UID = "1234" job.UID = "1234"
job.Namespace = "" job.Namespace = ""
if tc.stillActive { if tc.stillActive {
sj.Status.Active = []api.ObjectReference{{UID: job.UID}} sj.Status.Active = []v1.ObjectReference{{UID: job.UID}}
js = append(js, *job) js = append(js, *job)
} }
} else { } else {
...@@ -271,7 +271,7 @@ func TestSyncOne_RunOrNot(t *testing.T) { ...@@ -271,7 +271,7 @@ func TestSyncOne_RunOrNot(t *testing.T) {
// TestSyncOne_Status tests sj.UpdateStatus in SyncOne // TestSyncOne_Status tests sj.UpdateStatus in SyncOne
func TestSyncOne_Status(t *testing.T) { func TestSyncOne_Status(t *testing.T) {
finishedJob := newJob("1") finishedJob := newJob("1")
finishedJob.Status.Conditions = append(finishedJob.Status.Conditions, batch.JobCondition{Type: batch.JobComplete, Status: api.ConditionTrue}) finishedJob.Status.Conditions = append(finishedJob.Status.Conditions, batch.JobCondition{Type: batch.JobComplete, Status: v1.ConditionTrue})
unexpectedJob := newJob("2") unexpectedJob := newJob("2")
testCases := map[string]struct { testCases := map[string]struct {
...@@ -360,7 +360,7 @@ func TestSyncOne_Status(t *testing.T) { ...@@ -360,7 +360,7 @@ func TestSyncOne_Status(t *testing.T) {
if err != nil { if err != nil {
t.Errorf("%s: test setup error: failed to get job's ref: %v.", name, err) t.Errorf("%s: test setup error: failed to get job's ref: %v.", name, err)
} }
sj.Status.Active = []api.ObjectReference{*ref} sj.Status.Active = []v1.ObjectReference{*ref}
jobs = append(jobs, finishedJob) jobs = append(jobs, finishedJob)
} }
if tc.hasUnexpectedJob { if tc.hasUnexpectedJob {
......
...@@ -20,9 +20,9 @@ import ( ...@@ -20,9 +20,9 @@ import (
"fmt" "fmt"
"sync" "sync"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apis/batch" batch "k8s.io/kubernetes/pkg/apis/batch/v2alpha1"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" clientset "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5"
"k8s.io/kubernetes/pkg/client/record" "k8s.io/kubernetes/pkg/client/record"
"k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/labels"
) )
...@@ -41,7 +41,7 @@ type realSJControl struct { ...@@ -41,7 +41,7 @@ type realSJControl struct {
var _ sjControlInterface = &realSJControl{} var _ sjControlInterface = &realSJControl{}
func (c *realSJControl) UpdateStatus(sj *batch.CronJob) (*batch.CronJob, error) { func (c *realSJControl) UpdateStatus(sj *batch.CronJob) (*batch.CronJob, error) {
return c.KubeClient.Batch().CronJobs(sj.Namespace).UpdateStatus(sj) return c.KubeClient.BatchV2alpha1().CronJobs(sj.Namespace).UpdateStatus(sj)
} }
// fakeSJControl is the default implementation of sjControlInterface. // fakeSJControl is the default implementation of sjControlInterface.
...@@ -97,19 +97,19 @@ func copyAnnotations(template *batch.JobTemplateSpec) labels.Set { ...@@ -97,19 +97,19 @@ func copyAnnotations(template *batch.JobTemplateSpec) labels.Set {
} }
func (r realJobControl) GetJob(namespace, name string) (*batch.Job, error) { func (r realJobControl) GetJob(namespace, name string) (*batch.Job, error) {
return r.KubeClient.Batch().Jobs(namespace).Get(name) return r.KubeClient.BatchV2alpha1().Jobs(namespace).Get(name)
} }
func (r realJobControl) UpdateJob(namespace string, job *batch.Job) (*batch.Job, error) { func (r realJobControl) UpdateJob(namespace string, job *batch.Job) (*batch.Job, error) {
return r.KubeClient.Batch().Jobs(namespace).Update(job) return r.KubeClient.BatchV2alpha1().Jobs(namespace).Update(job)
} }
func (r realJobControl) CreateJob(namespace string, job *batch.Job) (*batch.Job, error) { func (r realJobControl) CreateJob(namespace string, job *batch.Job) (*batch.Job, error) {
return r.KubeClient.Batch().Jobs(namespace).Create(job) return r.KubeClient.BatchV2alpha1().Jobs(namespace).Create(job)
} }
func (r realJobControl) DeleteJob(namespace string, name string) error { func (r realJobControl) DeleteJob(namespace string, name string) error {
return r.KubeClient.Batch().Jobs(namespace).Delete(name, nil) return r.KubeClient.BatchV2alpha1().Jobs(namespace).Delete(name, nil)
} }
type fakeJobControl struct { type fakeJobControl struct {
...@@ -176,7 +176,7 @@ func (f *fakeJobControl) Clear() { ...@@ -176,7 +176,7 @@ func (f *fakeJobControl) Clear() {
// created as an interface to allow testing. // created as an interface to allow testing.
type podControlInterface interface { type podControlInterface interface {
// ListPods list pods // ListPods list pods
ListPods(namespace string, opts api.ListOptions) (*api.PodList, error) ListPods(namespace string, opts v1.ListOptions) (*v1.PodList, error)
// DeleteJob deletes the pod identified by name. // DeleteJob deletes the pod identified by name.
// TODO: delete by UID? // TODO: delete by UID?
DeletePod(namespace string, name string) error DeletePod(namespace string, name string) error
...@@ -190,7 +190,7 @@ type realPodControl struct { ...@@ -190,7 +190,7 @@ type realPodControl struct {
var _ podControlInterface = &realPodControl{} var _ podControlInterface = &realPodControl{}
func (r realPodControl) ListPods(namespace string, opts api.ListOptions) (*api.PodList, error) { func (r realPodControl) ListPods(namespace string, opts v1.ListOptions) (*v1.PodList, error) {
return r.KubeClient.Core().Pods(namespace).List(opts) return r.KubeClient.Core().Pods(namespace).List(opts)
} }
...@@ -200,17 +200,17 @@ func (r realPodControl) DeletePod(namespace string, name string) error { ...@@ -200,17 +200,17 @@ func (r realPodControl) DeletePod(namespace string, name string) error {
type fakePodControl struct { type fakePodControl struct {
sync.Mutex sync.Mutex
Pods []api.Pod Pods []v1.Pod
DeletePodName []string DeletePodName []string
Err error Err error
} }
var _ podControlInterface = &fakePodControl{} var _ podControlInterface = &fakePodControl{}
func (f *fakePodControl) ListPods(namespace string, opts api.ListOptions) (*api.PodList, error) { func (f *fakePodControl) ListPods(namespace string, opts v1.ListOptions) (*v1.PodList, error) {
f.Lock() f.Lock()
defer f.Unlock() defer f.Unlock()
return &api.PodList{Items: f.Pods}, nil return &v1.PodList{Items: f.Pods}, nil
} }
func (f *fakePodControl) DeletePod(namespace string, name string) error { func (f *fakePodControl) DeletePod(namespace string, name string) error {
......
...@@ -26,7 +26,8 @@ import ( ...@@ -26,7 +26,8 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apis/batch" "k8s.io/kubernetes/pkg/api/v1"
batch "k8s.io/kubernetes/pkg/apis/batch/v2alpha1"
"k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/types" "k8s.io/kubernetes/pkg/types"
) )
...@@ -46,7 +47,7 @@ func deleteFromActiveList(sj *batch.CronJob, uid types.UID) { ...@@ -46,7 +47,7 @@ func deleteFromActiveList(sj *batch.CronJob, uid types.UID) {
if sj == nil { if sj == nil {
return return
} }
newActive := []api.ObjectReference{} newActive := []v1.ObjectReference{}
for _, j := range sj.Status.Active { for _, j := range sj.Status.Active {
if j.UID != uid { if j.UID != uid {
newActive = append(newActive, j) newActive = append(newActive, j)
...@@ -57,12 +58,12 @@ func deleteFromActiveList(sj *batch.CronJob, uid types.UID) { ...@@ -57,12 +58,12 @@ func deleteFromActiveList(sj *batch.CronJob, uid types.UID) {
// getParentUIDFromJob extracts UID of job's parent and whether it was found // getParentUIDFromJob extracts UID of job's parent and whether it was found
func getParentUIDFromJob(j batch.Job) (types.UID, bool) { func getParentUIDFromJob(j batch.Job) (types.UID, bool) {
creatorRefJson, found := j.ObjectMeta.Annotations[api.CreatedByAnnotation] creatorRefJson, found := j.ObjectMeta.Annotations[v1.CreatedByAnnotation]
if !found { if !found {
glog.V(4).Infof("Job with no created-by annotation, name %s namespace %s", j.Name, j.Namespace) glog.V(4).Infof("Job with no created-by annotation, name %s namespace %s", j.Name, j.Namespace)
return types.UID(""), false return types.UID(""), false
} }
var sr api.SerializedReference var sr v1.SerializedReference
err := json.Unmarshal([]byte(creatorRefJson), &sr) err := json.Unmarshal([]byte(creatorRefJson), &sr)
if err != nil { if err != nil {
glog.V(4).Infof("Job with unparsable created-by annotation, name %s namespace %s: %v", j.Name, j.Namespace, err) glog.V(4).Infof("Job with unparsable created-by annotation, name %s namespace %s: %v", j.Name, j.Namespace, err)
...@@ -181,12 +182,12 @@ func getJobFromTemplate(sj *batch.CronJob, scheduledTime time.Time) (*batch.Job, ...@@ -181,12 +182,12 @@ func getJobFromTemplate(sj *batch.CronJob, scheduledTime time.Time) (*batch.Job,
if err != nil { if err != nil {
return nil, err return nil, err
} }
annotations[api.CreatedByAnnotation] = string(createdByRefJson) annotations[v1.CreatedByAnnotation] = string(createdByRefJson)
// We want job names for a given nominal start time to have a deterministic name to avoid the same job being created twice // We want job names for a given nominal start time to have a deterministic name to avoid the same job being created twice
name := fmt.Sprintf("%s-%d", sj.Name, getTimeHash(scheduledTime)) name := fmt.Sprintf("%s-%d", sj.Name, getTimeHash(scheduledTime))
job := &batch.Job{ job := &batch.Job{
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Labels: labels, Labels: labels,
Annotations: annotations, Annotations: annotations,
Name: name, Name: name,
...@@ -205,7 +206,7 @@ func getTimeHash(scheduledTime time.Time) int64 { ...@@ -205,7 +206,7 @@ func getTimeHash(scheduledTime time.Time) int64 {
// makeCreatedByRefJson makes a json string with an object reference for use in "created-by" annotation value // makeCreatedByRefJson makes a json string with an object reference for use in "created-by" annotation value
func makeCreatedByRefJson(object runtime.Object) (string, error) { func makeCreatedByRefJson(object runtime.Object) (string, error) {
createdByRef, err := api.GetReference(object) createdByRef, err := v1.GetReference(object)
if err != nil { if err != nil {
return "", fmt.Errorf("unable to get controller reference: %v", err) return "", fmt.Errorf("unable to get controller reference: %v", err)
} }
...@@ -213,9 +214,9 @@ func makeCreatedByRefJson(object runtime.Object) (string, error) { ...@@ -213,9 +214,9 @@ func makeCreatedByRefJson(object runtime.Object) (string, error) {
// TODO: this code was not safe previously - as soon as new code came along that switched to v2, old clients // TODO: this code was not safe previously - as soon as new code came along that switched to v2, old clients
// would be broken upon reading it. This is explicitly hardcoded to v1 to guarantee predictable deployment. // would be broken upon reading it. This is explicitly hardcoded to v1 to guarantee predictable deployment.
// We need to consistently handle this case of annotation versioning. // We need to consistently handle this case of annotation versioning.
codec := api.Codecs.LegacyCodec(unversioned.GroupVersion{Group: api.GroupName, Version: "v1"}) codec := api.Codecs.LegacyCodec(unversioned.GroupVersion{Group: v1.GroupName, Version: "v1"})
createdByRefJson, err := runtime.Encode(codec, &api.SerializedReference{ createdByRefJson, err := runtime.Encode(codec, &v1.SerializedReference{
Reference: *createdByRef, Reference: *createdByRef,
}) })
if err != nil { if err != nil {
...@@ -223,3 +224,12 @@ func makeCreatedByRefJson(object runtime.Object) (string, error) { ...@@ -223,3 +224,12 @@ func makeCreatedByRefJson(object runtime.Object) (string, error) {
} }
return string(createdByRefJson), nil return string(createdByRefJson), nil
} }
func IsJobFinished(j *batch.Job) bool {
for _, c := range j.Status.Conditions {
if (c.Type == batch.JobComplete || c.Type == batch.JobFailed) && c.Status == v1.ConditionTrue {
return true
}
}
return false
}
...@@ -22,9 +22,9 @@ import ( ...@@ -22,9 +22,9 @@ import (
"testing" "testing"
"time" "time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apis/batch" "k8s.io/kubernetes/pkg/api/v1"
batch "k8s.io/kubernetes/pkg/apis/batch/v2alpha1"
"k8s.io/kubernetes/pkg/types" "k8s.io/kubernetes/pkg/types"
//"k8s.io/kubernetes/pkg/controller" //"k8s.io/kubernetes/pkg/controller"
// "k8s.io/kubernetes/pkg/util/rand" // "k8s.io/kubernetes/pkg/util/rand"
...@@ -38,7 +38,7 @@ func TestGetJobFromTemplate(t *testing.T) { ...@@ -38,7 +38,7 @@ func TestGetJobFromTemplate(t *testing.T) {
var no bool = false var no bool = false
sj := batch.CronJob{ sj := batch.CronJob{
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Name: "mycronjob", Name: "mycronjob",
Namespace: "snazzycats", Namespace: "snazzycats",
UID: types.UID("1a2b3c"), UID: types.UID("1a2b3c"),
...@@ -48,21 +48,21 @@ func TestGetJobFromTemplate(t *testing.T) { ...@@ -48,21 +48,21 @@ func TestGetJobFromTemplate(t *testing.T) {
Schedule: "* * * * ?", Schedule: "* * * * ?",
ConcurrencyPolicy: batch.AllowConcurrent, ConcurrencyPolicy: batch.AllowConcurrent,
JobTemplate: batch.JobTemplateSpec{ JobTemplate: batch.JobTemplateSpec{
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Labels: map[string]string{"a": "b"}, Labels: map[string]string{"a": "b"},
Annotations: map[string]string{"x": "y"}, Annotations: map[string]string{"x": "y"},
}, },
Spec: batch.JobSpec{ Spec: batch.JobSpec{
ActiveDeadlineSeconds: &one, ActiveDeadlineSeconds: &one,
ManualSelector: &no, ManualSelector: &no,
Template: api.PodTemplateSpec{ Template: v1.PodTemplateSpec{
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Labels: map[string]string{ Labels: map[string]string{
"foo": "bar", "foo": "bar",
}, },
}, },
Spec: api.PodSpec{ Spec: v1.PodSpec{
Containers: []api.Container{ Containers: []v1.Container{
{Image: "foo/bar"}, {Image: "foo/bar"},
}, },
}, },
...@@ -86,7 +86,7 @@ func TestGetJobFromTemplate(t *testing.T) { ...@@ -86,7 +86,7 @@ func TestGetJobFromTemplate(t *testing.T) {
if len(job.ObjectMeta.Annotations) != 2 { if len(job.ObjectMeta.Annotations) != 2 {
t.Errorf("Wrong number of annotations") t.Errorf("Wrong number of annotations")
} }
v, ok := job.ObjectMeta.Annotations[api.CreatedByAnnotation] v, ok := job.ObjectMeta.Annotations[v1.CreatedByAnnotation]
if !ok { if !ok {
t.Errorf("Missing created-by annotation") t.Errorf("Missing created-by annotation")
} }
...@@ -102,22 +102,22 @@ func TestGetJobFromTemplate(t *testing.T) { ...@@ -102,22 +102,22 @@ func TestGetJobFromTemplate(t *testing.T) {
func TestGetParentUIDFromJob(t *testing.T) { func TestGetParentUIDFromJob(t *testing.T) {
j := &batch.Job{ j := &batch.Job{
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Name: "foobar", Name: "foobar",
Namespace: api.NamespaceDefault, Namespace: v1.NamespaceDefault,
}, },
Spec: batch.JobSpec{ Spec: batch.JobSpec{
Selector: &unversioned.LabelSelector{ Selector: &unversioned.LabelSelector{
MatchLabels: map[string]string{"foo": "bar"}, MatchLabels: map[string]string{"foo": "bar"},
}, },
Template: api.PodTemplateSpec{ Template: v1.PodTemplateSpec{
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Labels: map[string]string{ Labels: map[string]string{
"foo": "bar", "foo": "bar",
}, },
}, },
Spec: api.PodSpec{ Spec: v1.PodSpec{
Containers: []api.Container{ Containers: []v1.Container{
{Image: "foo/bar"}, {Image: "foo/bar"},
}, },
}, },
...@@ -126,7 +126,7 @@ func TestGetParentUIDFromJob(t *testing.T) { ...@@ -126,7 +126,7 @@ func TestGetParentUIDFromJob(t *testing.T) {
Status: batch.JobStatus{ Status: batch.JobStatus{
Conditions: []batch.JobCondition{{ Conditions: []batch.JobCondition{{
Type: batch.JobComplete, Type: batch.JobComplete,
Status: api.ConditionTrue, Status: v1.ConditionTrue,
}}, }},
}, },
} }
...@@ -140,7 +140,7 @@ func TestGetParentUIDFromJob(t *testing.T) { ...@@ -140,7 +140,7 @@ func TestGetParentUIDFromJob(t *testing.T) {
} }
{ {
// Case 2: Has UID annotation // Case 2: Has UID annotation
j.ObjectMeta.Annotations = map[string]string{api.CreatedByAnnotation: `{"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"CronJob","namespace":"default","name":"pi","uid":"5ef034e0-1890-11e6-8935-42010af0003e","apiVersion":"extensions","resourceVersion":"427339"}}`} j.ObjectMeta.Annotations = map[string]string{v1.CreatedByAnnotation: `{"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"CronJob","namespace":"default","name":"pi","uid":"5ef034e0-1890-11e6-8935-42010af0003e","apiVersion":"extensions","resourceVersion":"427339"}}`}
expectedUID := types.UID("5ef034e0-1890-11e6-8935-42010af0003e") expectedUID := types.UID("5ef034e0-1890-11e6-8935-42010af0003e")
...@@ -158,9 +158,9 @@ func TestGroupJobsByParent(t *testing.T) { ...@@ -158,9 +158,9 @@ func TestGroupJobsByParent(t *testing.T) {
uid1 := types.UID("11111111-1111-1111-1111-111111111111") uid1 := types.UID("11111111-1111-1111-1111-111111111111")
uid2 := types.UID("22222222-2222-2222-2222-222222222222") uid2 := types.UID("22222222-2222-2222-2222-222222222222")
uid3 := types.UID("33333333-3333-3333-3333-333333333333") uid3 := types.UID("33333333-3333-3333-3333-333333333333")
createdBy1 := map[string]string{api.CreatedByAnnotation: `{"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"CronJob","namespace":"x","name":"pi","uid":"11111111-1111-1111-1111-111111111111","apiVersion":"extensions","resourceVersion":"111111"}}`} createdBy1 := map[string]string{v1.CreatedByAnnotation: `{"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"CronJob","namespace":"x","name":"pi","uid":"11111111-1111-1111-1111-111111111111","apiVersion":"extensions","resourceVersion":"111111"}}`}
createdBy2 := map[string]string{api.CreatedByAnnotation: `{"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"CronJob","namespace":"x","name":"pi","uid":"22222222-2222-2222-2222-222222222222","apiVersion":"extensions","resourceVersion":"222222"}}`} createdBy2 := map[string]string{v1.CreatedByAnnotation: `{"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"CronJob","namespace":"x","name":"pi","uid":"22222222-2222-2222-2222-222222222222","apiVersion":"extensions","resourceVersion":"222222"}}`}
createdBy3 := map[string]string{api.CreatedByAnnotation: `{"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"CronJob","namespace":"y","name":"pi","uid":"33333333-3333-3333-3333-333333333333","apiVersion":"extensions","resourceVersion":"333333"}}`} createdBy3 := map[string]string{v1.CreatedByAnnotation: `{"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"CronJob","namespace":"y","name":"pi","uid":"33333333-3333-3333-3333-333333333333","apiVersion":"extensions","resourceVersion":"333333"}}`}
noCreatedBy := map[string]string{} noCreatedBy := map[string]string{}
{ {
...@@ -176,7 +176,7 @@ func TestGroupJobsByParent(t *testing.T) { ...@@ -176,7 +176,7 @@ func TestGroupJobsByParent(t *testing.T) {
{ {
// Case 2: there is one controller with no job. // Case 2: there is one controller with no job.
sjs := []batch.CronJob{ sjs := []batch.CronJob{
{ObjectMeta: api.ObjectMeta{Name: "e", Namespace: "x", UID: uid1}}, {ObjectMeta: v1.ObjectMeta{Name: "e", Namespace: "x", UID: uid1}},
} }
js := []batch.Job{} js := []batch.Job{}
jobsBySj := groupJobsByParent(sjs, js) jobsBySj := groupJobsByParent(sjs, js)
...@@ -188,10 +188,10 @@ func TestGroupJobsByParent(t *testing.T) { ...@@ -188,10 +188,10 @@ func TestGroupJobsByParent(t *testing.T) {
{ {
// Case 3: there is one controller with one job it created. // Case 3: there is one controller with one job it created.
sjs := []batch.CronJob{ sjs := []batch.CronJob{
{ObjectMeta: api.ObjectMeta{Name: "e", Namespace: "x", UID: uid1}}, {ObjectMeta: v1.ObjectMeta{Name: "e", Namespace: "x", UID: uid1}},
} }
js := []batch.Job{ js := []batch.Job{
{ObjectMeta: api.ObjectMeta{Name: "a", Namespace: "x", Annotations: createdBy1}}, {ObjectMeta: v1.ObjectMeta{Name: "a", Namespace: "x", Annotations: createdBy1}},
} }
jobsBySj := groupJobsByParent(sjs, js) jobsBySj := groupJobsByParent(sjs, js)
...@@ -211,18 +211,18 @@ func TestGroupJobsByParent(t *testing.T) { ...@@ -211,18 +211,18 @@ func TestGroupJobsByParent(t *testing.T) {
// Case 4: Two namespaces, one has two jobs from one controller, other has 3 jobs from two controllers. // Case 4: Two namespaces, one has two jobs from one controller, other has 3 jobs from two controllers.
// There are also two jobs with no created-by annotation. // There are also two jobs with no created-by annotation.
js := []batch.Job{ js := []batch.Job{
{ObjectMeta: api.ObjectMeta{Name: "a", Namespace: "x", Annotations: createdBy1}}, {ObjectMeta: v1.ObjectMeta{Name: "a", Namespace: "x", Annotations: createdBy1}},
{ObjectMeta: api.ObjectMeta{Name: "b", Namespace: "x", Annotations: createdBy2}}, {ObjectMeta: v1.ObjectMeta{Name: "b", Namespace: "x", Annotations: createdBy2}},
{ObjectMeta: api.ObjectMeta{Name: "c", Namespace: "x", Annotations: createdBy1}}, {ObjectMeta: v1.ObjectMeta{Name: "c", Namespace: "x", Annotations: createdBy1}},
{ObjectMeta: api.ObjectMeta{Name: "d", Namespace: "x", Annotations: noCreatedBy}}, {ObjectMeta: v1.ObjectMeta{Name: "d", Namespace: "x", Annotations: noCreatedBy}},
{ObjectMeta: api.ObjectMeta{Name: "a", Namespace: "y", Annotations: createdBy3}}, {ObjectMeta: v1.ObjectMeta{Name: "a", Namespace: "y", Annotations: createdBy3}},
{ObjectMeta: api.ObjectMeta{Name: "b", Namespace: "y", Annotations: createdBy3}}, {ObjectMeta: v1.ObjectMeta{Name: "b", Namespace: "y", Annotations: createdBy3}},
{ObjectMeta: api.ObjectMeta{Name: "d", Namespace: "y", Annotations: noCreatedBy}}, {ObjectMeta: v1.ObjectMeta{Name: "d", Namespace: "y", Annotations: noCreatedBy}},
} }
sjs := []batch.CronJob{ sjs := []batch.CronJob{
{ObjectMeta: api.ObjectMeta{Name: "e", Namespace: "x", UID: uid1}}, {ObjectMeta: v1.ObjectMeta{Name: "e", Namespace: "x", UID: uid1}},
{ObjectMeta: api.ObjectMeta{Name: "f", Namespace: "x", UID: uid2}}, {ObjectMeta: v1.ObjectMeta{Name: "f", Namespace: "x", UID: uid2}},
{ObjectMeta: api.ObjectMeta{Name: "g", Namespace: "y", UID: uid3}}, {ObjectMeta: v1.ObjectMeta{Name: "g", Namespace: "y", UID: uid3}},
} }
jobsBySj := groupJobsByParent(sjs, js) jobsBySj := groupJobsByParent(sjs, js)
...@@ -270,9 +270,9 @@ func TestGetRecentUnmetScheduleTimes(t *testing.T) { ...@@ -270,9 +270,9 @@ func TestGetRecentUnmetScheduleTimes(t *testing.T) {
} }
sj := batch.CronJob{ sj := batch.CronJob{
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Name: "mycronjob", Name: "mycronjob",
Namespace: api.NamespaceDefault, Namespace: v1.NamespaceDefault,
UID: types.UID("1a2b3c"), UID: types.UID("1a2b3c"),
}, },
Spec: batch.CronJobSpec{ Spec: batch.CronJobSpec{
......
...@@ -27,12 +27,12 @@ import ( ...@@ -27,12 +27,12 @@ import (
"time" "time"
"github.com/golang/glog" "github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apis/extensions" "k8s.io/kubernetes/pkg/api/v1"
extensions "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
"k8s.io/kubernetes/pkg/client/cache" "k8s.io/kubernetes/pkg/client/cache"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" clientset "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5"
unversionedcore "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion" v1core "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5/typed/core/v1"
"k8s.io/kubernetes/pkg/client/record" "k8s.io/kubernetes/pkg/client/record"
"k8s.io/kubernetes/pkg/controller" "k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/pkg/controller/deployment/util" "k8s.io/kubernetes/pkg/controller/deployment/util"
...@@ -91,14 +91,14 @@ func NewDeploymentController(dInformer informers.DeploymentInformer, rsInformer ...@@ -91,14 +91,14 @@ func NewDeploymentController(dInformer informers.DeploymentInformer, rsInformer
eventBroadcaster := record.NewBroadcaster() eventBroadcaster := record.NewBroadcaster()
eventBroadcaster.StartLogging(glog.Infof) eventBroadcaster.StartLogging(glog.Infof)
// TODO: remove the wrapper when every clients have moved to use the clientset. // TODO: remove the wrapper when every clients have moved to use the clientset.
eventBroadcaster.StartRecordingToSink(&unversionedcore.EventSinkImpl{Interface: client.Core().Events("")}) eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: client.Core().Events("")})
if client != nil && client.Core().RESTClient().GetRateLimiter() != nil { if client != nil && client.Core().RESTClient().GetRateLimiter() != nil {
metrics.RegisterMetricAndTrackRateLimiterUsage("deployment_controller", client.Core().RESTClient().GetRateLimiter()) metrics.RegisterMetricAndTrackRateLimiterUsage("deployment_controller", client.Core().RESTClient().GetRateLimiter())
} }
dc := &DeploymentController{ dc := &DeploymentController{
client: client, client: client,
eventRecorder: eventBroadcaster.NewRecorder(api.EventSource{Component: "deployment-controller"}), eventRecorder: eventBroadcaster.NewRecorder(v1.EventSource{Component: "deployment-controller"}),
queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "deployment"), queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "deployment"),
} }
...@@ -220,7 +220,7 @@ func (dc *DeploymentController) updateReplicaSet(old, cur interface{}) { ...@@ -220,7 +220,7 @@ func (dc *DeploymentController) updateReplicaSet(old, cur interface{}) {
} }
// A number of things could affect the old deployment: labels changing, // A number of things could affect the old deployment: labels changing,
// pod template changing, etc. // pod template changing, etc.
if !api.Semantic.DeepEqual(oldRS, curRS) { if !v1.Semantic.DeepEqual(oldRS, curRS) {
if oldD := dc.getDeploymentForReplicaSet(oldRS); oldD != nil { if oldD := dc.getDeploymentForReplicaSet(oldRS); oldD != nil {
dc.enqueueDeployment(oldD) dc.enqueueDeployment(oldD)
} }
...@@ -333,7 +333,7 @@ func (dc *DeploymentController) syncDeployment(key string) error { ...@@ -333,7 +333,7 @@ func (dc *DeploymentController) syncDeployment(key string) error {
everything := unversioned.LabelSelector{} everything := unversioned.LabelSelector{}
if reflect.DeepEqual(d.Spec.Selector, &everything) { if reflect.DeepEqual(d.Spec.Selector, &everything) {
dc.eventRecorder.Eventf(d, api.EventTypeWarning, "SelectingAll", "This deployment is selecting all pods. A non-empty selector is required.") dc.eventRecorder.Eventf(d, v1.EventTypeWarning, "SelectingAll", "This deployment is selecting all pods. A non-empty selector is required.")
if d.Status.ObservedGeneration < d.Generation { if d.Status.ObservedGeneration < d.Generation {
d.Status.ObservedGeneration = d.Generation d.Status.ObservedGeneration = d.Generation
dc.client.Extensions().Deployments(d.Namespace).UpdateStatus(d) dc.client.Extensions().Deployments(d.Namespace).UpdateStatus(d)
...@@ -347,7 +347,7 @@ func (dc *DeploymentController) syncDeployment(key string) error { ...@@ -347,7 +347,7 @@ func (dc *DeploymentController) syncDeployment(key string) error {
// Handle overlapping deployments by deterministically avoid syncing deployments that fight over ReplicaSets. // Handle overlapping deployments by deterministically avoid syncing deployments that fight over ReplicaSets.
if err = dc.handleOverlap(d); err != nil { if err = dc.handleOverlap(d); err != nil {
dc.eventRecorder.Eventf(d, api.EventTypeWarning, "SelectorOverlap", err.Error()) dc.eventRecorder.Eventf(d, v1.EventTypeWarning, "SelectorOverlap", err.Error())
return nil return nil
} }
......
...@@ -20,11 +20,11 @@ import ( ...@@ -20,11 +20,11 @@ import (
"fmt" "fmt"
"testing" "testing"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apimachinery/registered" "k8s.io/kubernetes/pkg/apimachinery/registered"
"k8s.io/kubernetes/pkg/apis/extensions" extensions "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake" "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5/fake"
"k8s.io/kubernetes/pkg/client/record" "k8s.io/kubernetes/pkg/client/record"
"k8s.io/kubernetes/pkg/client/testing/core" "k8s.io/kubernetes/pkg/client/testing/core"
"k8s.io/kubernetes/pkg/controller" "k8s.io/kubernetes/pkg/controller"
...@@ -41,15 +41,15 @@ var ( ...@@ -41,15 +41,15 @@ var (
func rs(name string, replicas int, selector map[string]string, timestamp unversioned.Time) *extensions.ReplicaSet { func rs(name string, replicas int, selector map[string]string, timestamp unversioned.Time) *extensions.ReplicaSet {
return &extensions.ReplicaSet{ return &extensions.ReplicaSet{
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Name: name, Name: name,
CreationTimestamp: timestamp, CreationTimestamp: timestamp,
Namespace: api.NamespaceDefault, Namespace: v1.NamespaceDefault,
}, },
Spec: extensions.ReplicaSetSpec{ Spec: extensions.ReplicaSetSpec{
Replicas: int32(replicas), Replicas: func() *int32 { i := int32(replicas); return &i }(),
Selector: &unversioned.LabelSelector{MatchLabels: selector}, Selector: &unversioned.LabelSelector{MatchLabels: selector},
Template: api.PodTemplateSpec{}, Template: v1.PodTemplateSpec{},
}, },
} }
} }
...@@ -65,24 +65,27 @@ func newRSWithStatus(name string, specReplicas, statusReplicas int, selector map ...@@ -65,24 +65,27 @@ func newRSWithStatus(name string, specReplicas, statusReplicas int, selector map
func newDeployment(name string, replicas int, revisionHistoryLimit *int32, maxSurge, maxUnavailable *intstr.IntOrString, selector map[string]string) *extensions.Deployment { func newDeployment(name string, replicas int, revisionHistoryLimit *int32, maxSurge, maxUnavailable *intstr.IntOrString, selector map[string]string) *extensions.Deployment {
d := extensions.Deployment{ d := extensions.Deployment{
TypeMeta: unversioned.TypeMeta{APIVersion: registered.GroupOrDie(extensions.GroupName).GroupVersion.String()}, TypeMeta: unversioned.TypeMeta{APIVersion: registered.GroupOrDie(extensions.GroupName).GroupVersion.String()},
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
UID: uuid.NewUUID(), UID: uuid.NewUUID(),
Name: name, Name: name,
Namespace: api.NamespaceDefault, Namespace: v1.NamespaceDefault,
}, },
Spec: extensions.DeploymentSpec{ Spec: extensions.DeploymentSpec{
Strategy: extensions.DeploymentStrategy{ Strategy: extensions.DeploymentStrategy{
Type: extensions.RollingUpdateDeploymentStrategyType, Type: extensions.RollingUpdateDeploymentStrategyType,
RollingUpdate: &extensions.RollingUpdateDeployment{}, RollingUpdate: &extensions.RollingUpdateDeployment{
MaxUnavailable: func() *intstr.IntOrString { i := intstr.FromInt(0); return &i }(),
MaxSurge: func() *intstr.IntOrString { i := intstr.FromInt(0); return &i }(),
},
}, },
Replicas: int32(replicas), Replicas: func() *int32 { i := int32(replicas); return &i }(),
Selector: &unversioned.LabelSelector{MatchLabels: selector}, Selector: &unversioned.LabelSelector{MatchLabels: selector},
Template: api.PodTemplateSpec{ Template: v1.PodTemplateSpec{
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Labels: selector, Labels: selector,
}, },
Spec: api.PodSpec{ Spec: v1.PodSpec{
Containers: []api.Container{ Containers: []v1.Container{
{ {
Image: "foo/bar", Image: "foo/bar",
}, },
...@@ -93,22 +96,22 @@ func newDeployment(name string, replicas int, revisionHistoryLimit *int32, maxSu ...@@ -93,22 +96,22 @@ func newDeployment(name string, replicas int, revisionHistoryLimit *int32, maxSu
}, },
} }
if maxSurge != nil { if maxSurge != nil {
d.Spec.Strategy.RollingUpdate.MaxSurge = *maxSurge d.Spec.Strategy.RollingUpdate.MaxSurge = maxSurge
} }
if maxUnavailable != nil { if maxUnavailable != nil {
d.Spec.Strategy.RollingUpdate.MaxUnavailable = *maxUnavailable d.Spec.Strategy.RollingUpdate.MaxUnavailable = maxUnavailable
} }
return &d return &d
} }
func newReplicaSet(d *extensions.Deployment, name string, replicas int) *extensions.ReplicaSet { func newReplicaSet(d *extensions.Deployment, name string, replicas int) *extensions.ReplicaSet {
return &extensions.ReplicaSet{ return &extensions.ReplicaSet{
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Name: name, Name: name,
Namespace: api.NamespaceDefault, Namespace: v1.NamespaceDefault,
}, },
Spec: extensions.ReplicaSetSpec{ Spec: extensions.ReplicaSetSpec{
Replicas: int32(replicas), Replicas: func() *int32 { i := int32(replicas); return &i }(),
Template: d.Spec.Template, Template: d.Spec.Template,
}, },
} }
...@@ -130,7 +133,7 @@ type fixture struct { ...@@ -130,7 +133,7 @@ type fixture struct {
// Objects to put in the store. // Objects to put in the store.
dLister []*extensions.Deployment dLister []*extensions.Deployment
rsLister []*extensions.ReplicaSet rsLister []*extensions.ReplicaSet
podLister []*api.Pod podLister []*v1.Pod
// Actions expected to happen on the client. Objects from here are also // Actions expected to happen on the client. Objects from here are also
// preloaded into NewSimpleFake. // preloaded into NewSimpleFake.
...@@ -161,7 +164,7 @@ func newFixture(t *testing.T) *fixture { ...@@ -161,7 +164,7 @@ func newFixture(t *testing.T) *fixture {
func (f *fixture) run(deploymentName string) { func (f *fixture) run(deploymentName string) {
f.client = fake.NewSimpleClientset(f.objects...) f.client = fake.NewSimpleClientset(f.objects...)
informers := informers.NewSharedInformerFactory(f.client, controller.NoResyncPeriodFunc()) informers := informers.NewSharedInformerFactory(f.client, nil, controller.NoResyncPeriodFunc())
c := NewDeploymentController(informers.Deployments(), informers.ReplicaSets(), informers.Pods(), f.client) c := NewDeploymentController(informers.Deployments(), informers.ReplicaSets(), informers.Pods(), f.client)
c.eventRecorder = &record.FakeRecorder{} c.eventRecorder = &record.FakeRecorder{}
c.dListerSynced = alwaysReady c.dListerSynced = alwaysReady
...@@ -234,7 +237,7 @@ func TestSyncDeploymentDontDoAnythingDuringDeletion(t *testing.T) { ...@@ -234,7 +237,7 @@ func TestSyncDeploymentDontDoAnythingDuringDeletion(t *testing.T) {
// issue: https://github.com/kubernetes/kubernetes/issues/23218 // issue: https://github.com/kubernetes/kubernetes/issues/23218
func TestDeploymentController_dontSyncDeploymentsWithEmptyPodSelector(t *testing.T) { func TestDeploymentController_dontSyncDeploymentsWithEmptyPodSelector(t *testing.T) {
fake := &fake.Clientset{} fake := &fake.Clientset{}
informers := informers.NewSharedInformerFactory(fake, controller.NoResyncPeriodFunc()) informers := informers.NewSharedInformerFactory(fake, nil, controller.NoResyncPeriodFunc())
controller := NewDeploymentController(informers.Deployments(), informers.ReplicaSets(), informers.Pods(), fake) controller := NewDeploymentController(informers.Deployments(), informers.ReplicaSets(), informers.Pods(), fake)
controller.eventRecorder = &record.FakeRecorder{} controller.eventRecorder = &record.FakeRecorder{}
controller.dListerSynced = alwaysReady controller.dListerSynced = alwaysReady
......
...@@ -20,8 +20,8 @@ import ( ...@@ -20,8 +20,8 @@ import (
"fmt" "fmt"
"reflect" "reflect"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apis/extensions" extensions "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
"k8s.io/kubernetes/pkg/controller/deployment/util" "k8s.io/kubernetes/pkg/controller/deployment/util"
) )
...@@ -95,14 +95,14 @@ func (dc *DeploymentController) syncRolloutStatus(allRSs []*extensions.ReplicaSe ...@@ -95,14 +95,14 @@ func (dc *DeploymentController) syncRolloutStatus(allRSs []*extensions.ReplicaSe
// Update the deployment conditions with a message for the new replica set that // Update the deployment conditions with a message for the new replica set that
// was successfully deployed. If the condition already exists, we ignore this update. // was successfully deployed. If the condition already exists, we ignore this update.
msg := fmt.Sprintf("Replica set %q has successfully progressed.", newRS.Name) msg := fmt.Sprintf("Replica set %q has successfully progressed.", newRS.Name)
condition := util.NewDeploymentCondition(extensions.DeploymentProgressing, api.ConditionTrue, util.NewRSAvailableReason, msg) condition := util.NewDeploymentCondition(extensions.DeploymentProgressing, v1.ConditionTrue, util.NewRSAvailableReason, msg)
util.SetDeploymentCondition(&newStatus, *condition) util.SetDeploymentCondition(&newStatus, *condition)
case util.DeploymentProgressing(d, &newStatus): case util.DeploymentProgressing(d, &newStatus):
// If there is any progress made, continue by not checking if the deployment failed. This // If there is any progress made, continue by not checking if the deployment failed. This
// behavior emulates the rolling updater progressDeadline check. // behavior emulates the rolling updater progressDeadline check.
msg := fmt.Sprintf("Replica set %q is progressing.", newRS.Name) msg := fmt.Sprintf("Replica set %q is progressing.", newRS.Name)
condition := util.NewDeploymentCondition(extensions.DeploymentProgressing, api.ConditionTrue, util.ReplicaSetUpdatedReason, msg) condition := util.NewDeploymentCondition(extensions.DeploymentProgressing, v1.ConditionTrue, util.ReplicaSetUpdatedReason, msg)
// Update the current Progressing condition or add a new one if it doesn't exist. // Update the current Progressing condition or add a new one if it doesn't exist.
// If a Progressing condition with status=true already exists, we should update // If a Progressing condition with status=true already exists, we should update
// everything but lastTransitionTime. SetDeploymentCondition already does that but // everything but lastTransitionTime. SetDeploymentCondition already does that but
...@@ -111,7 +111,7 @@ func (dc *DeploymentController) syncRolloutStatus(allRSs []*extensions.ReplicaSe ...@@ -111,7 +111,7 @@ func (dc *DeploymentController) syncRolloutStatus(allRSs []*extensions.ReplicaSe
// update with the same reason and change just lastUpdateTime iff we notice any // update with the same reason and change just lastUpdateTime iff we notice any
// progress. That's why we handle it here. // progress. That's why we handle it here.
if currentCond != nil { if currentCond != nil {
if currentCond.Status == api.ConditionTrue { if currentCond.Status == v1.ConditionTrue {
condition.LastTransitionTime = currentCond.LastTransitionTime condition.LastTransitionTime = currentCond.LastTransitionTime
} }
util.RemoveDeploymentCondition(&newStatus, extensions.DeploymentProgressing) util.RemoveDeploymentCondition(&newStatus, extensions.DeploymentProgressing)
...@@ -122,7 +122,7 @@ func (dc *DeploymentController) syncRolloutStatus(allRSs []*extensions.ReplicaSe ...@@ -122,7 +122,7 @@ func (dc *DeploymentController) syncRolloutStatus(allRSs []*extensions.ReplicaSe
// Update the deployment with a timeout condition. If the condition already exists, // Update the deployment with a timeout condition. If the condition already exists,
// we ignore this update. // we ignore this update.
msg := fmt.Sprintf("Replica set %q has timed out progressing.", newRS.Name) msg := fmt.Sprintf("Replica set %q has timed out progressing.", newRS.Name)
condition := util.NewDeploymentCondition(extensions.DeploymentProgressing, api.ConditionFalse, util.TimedOutReason, msg) condition := util.NewDeploymentCondition(extensions.DeploymentProgressing, v1.ConditionFalse, util.TimedOutReason, msg)
util.SetDeploymentCondition(&newStatus, *condition) util.SetDeploymentCondition(&newStatus, *condition)
} }
} }
......
...@@ -19,7 +19,7 @@ package deployment ...@@ -19,7 +19,7 @@ package deployment
import ( import (
"fmt" "fmt"
"k8s.io/kubernetes/pkg/apis/extensions" extensions "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
"k8s.io/kubernetes/pkg/client/retry" "k8s.io/kubernetes/pkg/client/retry"
"k8s.io/kubernetes/pkg/controller" "k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/pkg/util/wait" "k8s.io/kubernetes/pkg/util/wait"
...@@ -82,7 +82,7 @@ func (dc *DeploymentController) scaleDownOldReplicaSetsForRecreate(oldRSs []*ext ...@@ -82,7 +82,7 @@ func (dc *DeploymentController) scaleDownOldReplicaSetsForRecreate(oldRSs []*ext
for i := range oldRSs { for i := range oldRSs {
rs := oldRSs[i] rs := oldRSs[i]
// Scaling not required. // Scaling not required.
if rs.Spec.Replicas == 0 { if *(rs.Spec.Replicas) == 0 {
continue continue
} }
scaledRS, updatedRS, err := dc.scaleReplicaSetAndRecordEvent(rs, 0, deployment) scaledRS, updatedRS, err := dc.scaleReplicaSetAndRecordEvent(rs, 0, deployment)
...@@ -104,7 +104,7 @@ func (dc *DeploymentController) waitForInactiveReplicaSets(oldRSs []*extensions. ...@@ -104,7 +104,7 @@ func (dc *DeploymentController) waitForInactiveReplicaSets(oldRSs []*extensions.
rs := oldRSs[i] rs := oldRSs[i]
desiredGeneration := rs.Generation desiredGeneration := rs.Generation
observedGeneration := rs.Status.ObservedGeneration observedGeneration := rs.Status.ObservedGeneration
specReplicas := rs.Spec.Replicas specReplicas := *(rs.Spec.Replicas)
statusReplicas := rs.Status.Replicas statusReplicas := rs.Status.Replicas
if err := wait.ExponentialBackoff(retry.DefaultRetry, func() (bool, error) { if err := wait.ExponentialBackoff(retry.DefaultRetry, func() (bool, error) {
...@@ -113,13 +113,13 @@ func (dc *DeploymentController) waitForInactiveReplicaSets(oldRSs []*extensions. ...@@ -113,13 +113,13 @@ func (dc *DeploymentController) waitForInactiveReplicaSets(oldRSs []*extensions.
return false, err return false, err
} }
specReplicas = replicaSet.Spec.Replicas specReplicas = *(replicaSet.Spec.Replicas)
statusReplicas = replicaSet.Status.Replicas statusReplicas = replicaSet.Status.Replicas
observedGeneration = replicaSet.Status.ObservedGeneration observedGeneration = replicaSet.Status.ObservedGeneration
// TODO: We also need to wait for terminating replicas to actually terminate. // TODO: We also need to wait for terminating replicas to actually terminate.
// See https://github.com/kubernetes/kubernetes/issues/32567 // See https://github.com/kubernetes/kubernetes/issues/32567
return observedGeneration >= desiredGeneration && replicaSet.Spec.Replicas == 0 && replicaSet.Status.Replicas == 0, nil return observedGeneration >= desiredGeneration && *(replicaSet.Spec.Replicas) == 0 && replicaSet.Status.Replicas == 0, nil
}); err != nil { }); err != nil {
if err == wait.ErrWaitTimeout { if err == wait.ErrWaitTimeout {
err = fmt.Errorf("replica set %q never became inactive: synced=%t, spec.replicas=%d, status.replicas=%d", err = fmt.Errorf("replica set %q never became inactive: synced=%t, spec.replicas=%d, status.replicas=%d",
...@@ -133,6 +133,6 @@ func (dc *DeploymentController) waitForInactiveReplicaSets(oldRSs []*extensions. ...@@ -133,6 +133,6 @@ func (dc *DeploymentController) waitForInactiveReplicaSets(oldRSs []*extensions.
// scaleUpNewReplicaSetForRecreate scales up new replica set when deployment strategy is "Recreate" // scaleUpNewReplicaSetForRecreate scales up new replica set when deployment strategy is "Recreate"
func (dc *DeploymentController) scaleUpNewReplicaSetForRecreate(newRS *extensions.ReplicaSet, deployment *extensions.Deployment) (bool, error) { func (dc *DeploymentController) scaleUpNewReplicaSetForRecreate(newRS *extensions.ReplicaSet, deployment *extensions.Deployment) (bool, error) {
scaled, _, err := dc.scaleReplicaSetAndRecordEvent(newRS, deployment.Spec.Replicas, deployment) scaled, _, err := dc.scaleReplicaSetAndRecordEvent(newRS, *(deployment.Spec.Replicas), deployment)
return scaled, err return scaled, err
} }
...@@ -21,8 +21,8 @@ import ( ...@@ -21,8 +21,8 @@ import (
"reflect" "reflect"
"github.com/golang/glog" "github.com/golang/glog"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apis/extensions" extensions "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
deploymentutil "k8s.io/kubernetes/pkg/controller/deployment/util" deploymentutil "k8s.io/kubernetes/pkg/controller/deployment/util"
) )
...@@ -91,11 +91,11 @@ func (dc *DeploymentController) rollbackToTemplate(deployment *extensions.Deploy ...@@ -91,11 +91,11 @@ func (dc *DeploymentController) rollbackToTemplate(deployment *extensions.Deploy
} }
func (dc *DeploymentController) emitRollbackWarningEvent(deployment *extensions.Deployment, reason, message string) { func (dc *DeploymentController) emitRollbackWarningEvent(deployment *extensions.Deployment, reason, message string) {
dc.eventRecorder.Eventf(deployment, api.EventTypeWarning, reason, message) dc.eventRecorder.Eventf(deployment, v1.EventTypeWarning, reason, message)
} }
func (dc *DeploymentController) emitRollbackNormalEvent(deployment *extensions.Deployment, message string) { func (dc *DeploymentController) emitRollbackNormalEvent(deployment *extensions.Deployment, message string) {
dc.eventRecorder.Eventf(deployment, api.EventTypeNormal, deploymentutil.RollbackDone, message) dc.eventRecorder.Eventf(deployment, v1.EventTypeNormal, deploymentutil.RollbackDone, message)
} }
// updateDeploymentAndClearRollbackTo sets .spec.rollbackTo to nil and update the input deployment // updateDeploymentAndClearRollbackTo sets .spec.rollbackTo to nil and update the input deployment
......
...@@ -21,7 +21,7 @@ import ( ...@@ -21,7 +21,7 @@ import (
"sort" "sort"
"github.com/golang/glog" "github.com/golang/glog"
"k8s.io/kubernetes/pkg/apis/extensions" extensions "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
"k8s.io/kubernetes/pkg/controller" "k8s.io/kubernetes/pkg/controller"
deploymentutil "k8s.io/kubernetes/pkg/controller/deployment/util" deploymentutil "k8s.io/kubernetes/pkg/controller/deployment/util"
"k8s.io/kubernetes/pkg/util/integer" "k8s.io/kubernetes/pkg/util/integer"
...@@ -62,13 +62,13 @@ func (dc *DeploymentController) rolloutRolling(deployment *extensions.Deployment ...@@ -62,13 +62,13 @@ func (dc *DeploymentController) rolloutRolling(deployment *extensions.Deployment
} }
func (dc *DeploymentController) reconcileNewReplicaSet(allRSs []*extensions.ReplicaSet, newRS *extensions.ReplicaSet, deployment *extensions.Deployment) (bool, error) { func (dc *DeploymentController) reconcileNewReplicaSet(allRSs []*extensions.ReplicaSet, newRS *extensions.ReplicaSet, deployment *extensions.Deployment) (bool, error) {
if newRS.Spec.Replicas == deployment.Spec.Replicas { if *(newRS.Spec.Replicas) == *(deployment.Spec.Replicas) {
// Scaling not required. // Scaling not required.
return false, nil return false, nil
} }
if newRS.Spec.Replicas > deployment.Spec.Replicas { if *(newRS.Spec.Replicas) > *(deployment.Spec.Replicas) {
// Scale down. // Scale down.
scaled, _, err := dc.scaleReplicaSetAndRecordEvent(newRS, deployment.Spec.Replicas, deployment) scaled, _, err := dc.scaleReplicaSetAndRecordEvent(newRS, *(deployment.Spec.Replicas), deployment)
return scaled, err return scaled, err
} }
newReplicasCount, err := deploymentutil.NewRSNewReplicas(deployment, allRSs, newRS) newReplicasCount, err := deploymentutil.NewRSNewReplicas(deployment, allRSs, newRS)
...@@ -120,8 +120,8 @@ func (dc *DeploymentController) reconcileOldReplicaSets(allRSs []*extensions.Rep ...@@ -120,8 +120,8 @@ func (dc *DeploymentController) reconcileOldReplicaSets(allRSs []*extensions.Rep
// * The new replica set created must start with 0 replicas because allPodsCount is already at 13. // * The new replica set created must start with 0 replicas because allPodsCount is already at 13.
// * However, newRSPodsUnavailable would also be 0, so the 2 old replica sets could be scaled down by 5 (13 - 8 - 0), which would then // * However, newRSPodsUnavailable would also be 0, so the 2 old replica sets could be scaled down by 5 (13 - 8 - 0), which would then
// allow the new replica set to be scaled up by 5. // allow the new replica set to be scaled up by 5.
minAvailable := deployment.Spec.Replicas - maxUnavailable minAvailable := *(deployment.Spec.Replicas) - maxUnavailable
newRSUnavailablePodCount := newRS.Spec.Replicas - newRS.Status.AvailableReplicas newRSUnavailablePodCount := *(newRS.Spec.Replicas) - newRS.Status.AvailableReplicas
maxScaledDown := allPodsCount - minAvailable - newRSUnavailablePodCount maxScaledDown := allPodsCount - minAvailable - newRSUnavailablePodCount
if maxScaledDown <= 0 { if maxScaledDown <= 0 {
return false, nil return false, nil
...@@ -158,20 +158,20 @@ func (dc *DeploymentController) cleanupUnhealthyReplicas(oldRSs []*extensions.Re ...@@ -158,20 +158,20 @@ func (dc *DeploymentController) cleanupUnhealthyReplicas(oldRSs []*extensions.Re
if totalScaledDown >= maxCleanupCount { if totalScaledDown >= maxCleanupCount {
break break
} }
if targetRS.Spec.Replicas == 0 { if *(targetRS.Spec.Replicas) == 0 {
// cannot scale down this replica set. // cannot scale down this replica set.
continue continue
} }
glog.V(4).Infof("Found %d available pods in old RS %s/%s", targetRS.Status.AvailableReplicas, targetRS.Namespace, targetRS.Name) glog.V(4).Infof("Found %d available pods in old RS %s/%s", targetRS.Status.AvailableReplicas, targetRS.Namespace, targetRS.Name)
if targetRS.Spec.Replicas == targetRS.Status.AvailableReplicas { if *(targetRS.Spec.Replicas) == targetRS.Status.AvailableReplicas {
// no unhealthy replicas found, no scaling required. // no unhealthy replicas found, no scaling required.
continue continue
} }
scaledDownCount := int32(integer.IntMin(int(maxCleanupCount-totalScaledDown), int(targetRS.Spec.Replicas-targetRS.Status.AvailableReplicas))) scaledDownCount := int32(integer.IntMin(int(maxCleanupCount-totalScaledDown), int(*(targetRS.Spec.Replicas)-targetRS.Status.AvailableReplicas)))
newReplicasCount := targetRS.Spec.Replicas - scaledDownCount newReplicasCount := *(targetRS.Spec.Replicas) - scaledDownCount
if newReplicasCount > targetRS.Spec.Replicas { if newReplicasCount > *(targetRS.Spec.Replicas) {
return nil, 0, fmt.Errorf("when cleaning up unhealthy replicas, got invalid request to scale down %s/%s %d -> %d", targetRS.Namespace, targetRS.Name, targetRS.Spec.Replicas, newReplicasCount) return nil, 0, fmt.Errorf("when cleaning up unhealthy replicas, got invalid request to scale down %s/%s %d -> %d", targetRS.Namespace, targetRS.Name, *(targetRS.Spec.Replicas), newReplicasCount)
} }
_, updatedOldRS, err := dc.scaleReplicaSetAndRecordEvent(targetRS, newReplicasCount, deployment) _, updatedOldRS, err := dc.scaleReplicaSetAndRecordEvent(targetRS, newReplicasCount, deployment)
if err != nil { if err != nil {
...@@ -189,7 +189,7 @@ func (dc *DeploymentController) scaleDownOldReplicaSetsForRollingUpdate(allRSs [ ...@@ -189,7 +189,7 @@ func (dc *DeploymentController) scaleDownOldReplicaSetsForRollingUpdate(allRSs [
maxUnavailable := deploymentutil.MaxUnavailable(*deployment) maxUnavailable := deploymentutil.MaxUnavailable(*deployment)
// Check if we can scale down. // Check if we can scale down.
minAvailable := deployment.Spec.Replicas - maxUnavailable minAvailable := *(deployment.Spec.Replicas) - maxUnavailable
// Find the number of available pods. // Find the number of available pods.
availablePodCount := deploymentutil.GetAvailableReplicaCountForReplicaSets(allRSs) availablePodCount := deploymentutil.GetAvailableReplicaCountForReplicaSets(allRSs)
if availablePodCount <= minAvailable { if availablePodCount <= minAvailable {
...@@ -207,15 +207,15 @@ func (dc *DeploymentController) scaleDownOldReplicaSetsForRollingUpdate(allRSs [ ...@@ -207,15 +207,15 @@ func (dc *DeploymentController) scaleDownOldReplicaSetsForRollingUpdate(allRSs [
// No further scaling required. // No further scaling required.
break break
} }
if targetRS.Spec.Replicas == 0 { if *(targetRS.Spec.Replicas) == 0 {
// cannot scale down this ReplicaSet. // cannot scale down this ReplicaSet.
continue continue
} }
// Scale down. // Scale down.
scaleDownCount := int32(integer.IntMin(int(targetRS.Spec.Replicas), int(totalScaleDownCount-totalScaledDown))) scaleDownCount := int32(integer.IntMin(int(*(targetRS.Spec.Replicas)), int(totalScaleDownCount-totalScaledDown)))
newReplicasCount := targetRS.Spec.Replicas - scaleDownCount newReplicasCount := *(targetRS.Spec.Replicas) - scaleDownCount
if newReplicasCount > targetRS.Spec.Replicas { if newReplicasCount > *(targetRS.Spec.Replicas) {
return 0, fmt.Errorf("when scaling down old RS, got invalid request to scale down %s/%s %d -> %d", targetRS.Namespace, targetRS.Name, targetRS.Spec.Replicas, newReplicasCount) return 0, fmt.Errorf("when scaling down old RS, got invalid request to scale down %s/%s %d -> %d", targetRS.Namespace, targetRS.Name, *(targetRS.Spec.Replicas), newReplicasCount)
} }
_, _, err := dc.scaleReplicaSetAndRecordEvent(targetRS, newReplicasCount, deployment) _, _, err := dc.scaleReplicaSetAndRecordEvent(targetRS, newReplicasCount, deployment)
if err != nil { if err != nil {
......
...@@ -19,8 +19,8 @@ package deployment ...@@ -19,8 +19,8 @@ package deployment
import ( import (
"testing" "testing"
"k8s.io/kubernetes/pkg/apis/extensions" extensions "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake" "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5/fake"
"k8s.io/kubernetes/pkg/client/record" "k8s.io/kubernetes/pkg/client/record"
"k8s.io/kubernetes/pkg/client/testing/core" "k8s.io/kubernetes/pkg/client/testing/core"
"k8s.io/kubernetes/pkg/util/intstr" "k8s.io/kubernetes/pkg/util/intstr"
...@@ -110,7 +110,7 @@ func TestDeploymentController_reconcileNewReplicaSet(t *testing.T) { ...@@ -110,7 +110,7 @@ func TestDeploymentController_reconcileNewReplicaSet(t *testing.T) {
continue continue
} }
updated := fake.Actions()[0].(core.UpdateAction).GetObject().(*extensions.ReplicaSet) updated := fake.Actions()[0].(core.UpdateAction).GetObject().(*extensions.ReplicaSet)
if e, a := test.expectedNewReplicas, int(updated.Spec.Replicas); e != a { if e, a := test.expectedNewReplicas, int(*(updated.Spec.Replicas)); e != a {
t.Errorf("expected update to %d replicas, got %d", e, a) t.Errorf("expected update to %d replicas, got %d", e, a)
} }
} }
...@@ -372,7 +372,7 @@ func TestDeploymentController_scaleDownOldReplicaSetsForRollingUpdate(t *testing ...@@ -372,7 +372,7 @@ func TestDeploymentController_scaleDownOldReplicaSetsForRollingUpdate(t *testing
continue continue
} }
updated := updateAction.GetObject().(*extensions.ReplicaSet) updated := updateAction.GetObject().(*extensions.ReplicaSet)
if e, a := test.expectedOldReplicas, int(updated.Spec.Replicas); e != a { if e, a := test.expectedOldReplicas, int(*(updated.Spec.Replicas)); e != a {
t.Errorf("expected update to %d replicas, got %d", e, a) t.Errorf("expected update to %d replicas, got %d", e, a)
} }
} }
......
...@@ -21,8 +21,8 @@ import ( ...@@ -21,8 +21,8 @@ import (
"time" "time"
"k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apis/extensions" extensions "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake" "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5/fake"
"k8s.io/kubernetes/pkg/client/record" "k8s.io/kubernetes/pkg/client/record"
testclient "k8s.io/kubernetes/pkg/client/testing/core" testclient "k8s.io/kubernetes/pkg/client/testing/core"
"k8s.io/kubernetes/pkg/controller" "k8s.io/kubernetes/pkg/controller"
...@@ -261,7 +261,7 @@ func TestScale(t *testing.T) { ...@@ -261,7 +261,7 @@ func TestScale(t *testing.T) {
} }
if test.newRS != nil { if test.newRS != nil {
desiredReplicas := test.oldDeployment.Spec.Replicas desiredReplicas := *(test.oldDeployment.Spec.Replicas)
if desired, ok := test.desiredReplicasAnnotations[test.newRS.Name]; ok { if desired, ok := test.desiredReplicasAnnotations[test.newRS.Name]; ok {
desiredReplicas = desired desiredReplicas = desired
} }
...@@ -272,7 +272,7 @@ func TestScale(t *testing.T) { ...@@ -272,7 +272,7 @@ func TestScale(t *testing.T) {
if rs == nil { if rs == nil {
continue continue
} }
desiredReplicas := test.oldDeployment.Spec.Replicas desiredReplicas := *(test.oldDeployment.Spec.Replicas)
if desired, ok := test.desiredReplicasAnnotations[rs.Name]; ok { if desired, ok := test.desiredReplicasAnnotations[rs.Name]; ok {
desiredReplicas = desired desiredReplicas = desired
} }
...@@ -289,22 +289,22 @@ func TestScale(t *testing.T) { ...@@ -289,22 +289,22 @@ func TestScale(t *testing.T) {
// no update action for it. // no update action for it.
nameToSize := make(map[string]int32) nameToSize := make(map[string]int32)
if test.newRS != nil { if test.newRS != nil {
nameToSize[test.newRS.Name] = test.newRS.Spec.Replicas nameToSize[test.newRS.Name] = *(test.newRS.Spec.Replicas)
} }
for i := range test.oldRSs { for i := range test.oldRSs {
rs := test.oldRSs[i] rs := test.oldRSs[i]
nameToSize[rs.Name] = rs.Spec.Replicas nameToSize[rs.Name] = *(rs.Spec.Replicas)
} }
// Get all the UPDATE actions and update nameToSize with all the updated sizes. // Get all the UPDATE actions and update nameToSize with all the updated sizes.
for _, action := range fake.Actions() { for _, action := range fake.Actions() {
rs := action.(testclient.UpdateAction).GetObject().(*extensions.ReplicaSet) rs := action.(testclient.UpdateAction).GetObject().(*extensions.ReplicaSet)
if !test.wasntUpdated[rs.Name] { if !test.wasntUpdated[rs.Name] {
nameToSize[rs.Name] = rs.Spec.Replicas nameToSize[rs.Name] = *(rs.Spec.Replicas)
} }
} }
if test.expectedNew != nil && test.newRS != nil && test.expectedNew.Spec.Replicas != nameToSize[test.newRS.Name] { if test.expectedNew != nil && test.newRS != nil && *(test.expectedNew.Spec.Replicas) != nameToSize[test.newRS.Name] {
t.Errorf("%s: expected new replicas: %d, got: %d", test.name, test.expectedNew.Spec.Replicas, nameToSize[test.newRS.Name]) t.Errorf("%s: expected new replicas: %d, got: %d", test.name, *(test.expectedNew.Spec.Replicas), nameToSize[test.newRS.Name])
continue continue
} }
if len(test.expectedOld) != len(test.oldRSs) { if len(test.expectedOld) != len(test.oldRSs) {
...@@ -314,8 +314,8 @@ func TestScale(t *testing.T) { ...@@ -314,8 +314,8 @@ func TestScale(t *testing.T) {
for n := range test.oldRSs { for n := range test.oldRSs {
rs := test.oldRSs[n] rs := test.oldRSs[n]
expected := test.expectedOld[n] expected := test.expectedOld[n]
if expected.Spec.Replicas != nameToSize[rs.Name] { if *(expected.Spec.Replicas) != nameToSize[rs.Name] {
t.Errorf("%s: expected old (%s) replicas: %d, got: %d", test.name, rs.Name, expected.Spec.Replicas, nameToSize[rs.Name]) t.Errorf("%s: expected old (%s) replicas: %d, got: %d", test.name, rs.Name, *(expected.Spec.Replicas), nameToSize[rs.Name])
} }
} }
} }
...@@ -371,7 +371,7 @@ func TestDeploymentController_cleanupDeployment(t *testing.T) { ...@@ -371,7 +371,7 @@ func TestDeploymentController_cleanupDeployment(t *testing.T) {
for i := range tests { for i := range tests {
test := tests[i] test := tests[i]
fake := &fake.Clientset{} fake := &fake.Clientset{}
informers := informers.NewSharedInformerFactory(fake, controller.NoResyncPeriodFunc()) informers := informers.NewSharedInformerFactory(fake, nil, controller.NoResyncPeriodFunc())
controller := NewDeploymentController(informers.Deployments(), informers.ReplicaSets(), informers.Pods(), fake) controller := NewDeploymentController(informers.Deployments(), informers.ReplicaSets(), informers.Pods(), fake)
controller.eventRecorder = &record.FakeRecorder{} controller.eventRecorder = &record.FakeRecorder{}
......
...@@ -25,9 +25,10 @@ import ( ...@@ -25,9 +25,10 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apimachinery/registered" "k8s.io/kubernetes/pkg/apimachinery/registered"
"k8s.io/kubernetes/pkg/apis/extensions" extensions "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
"k8s.io/kubernetes/pkg/apis/policy" policy "k8s.io/kubernetes/pkg/apis/policy/v1beta1"
"k8s.io/kubernetes/pkg/client/cache" "k8s.io/kubernetes/pkg/client/cache"
"k8s.io/kubernetes/pkg/client/record" "k8s.io/kubernetes/pkg/client/record"
"k8s.io/kubernetes/pkg/controller" "k8s.io/kubernetes/pkg/controller"
...@@ -95,7 +96,7 @@ func newFakeDisruptionController() (*DisruptionController, *pdbStates) { ...@@ -95,7 +96,7 @@ func newFakeDisruptionController() (*DisruptionController, *pdbStates) {
broadcaster: record.NewBroadcaster(), broadcaster: record.NewBroadcaster(),
} }
dc.recorder = dc.broadcaster.NewRecorder(api.EventSource{Component: "disruption_test"}) dc.recorder = dc.broadcaster.NewRecorder(v1.EventSource{Component: "disruption_test"})
return dc, ps return dc, ps
} }
...@@ -115,11 +116,11 @@ func newSelFooBar() *unversioned.LabelSelector { ...@@ -115,11 +116,11 @@ func newSelFooBar() *unversioned.LabelSelector {
func newPodDisruptionBudget(t *testing.T, minAvailable intstr.IntOrString) (*policy.PodDisruptionBudget, string) { func newPodDisruptionBudget(t *testing.T, minAvailable intstr.IntOrString) (*policy.PodDisruptionBudget, string) {
pdb := &policy.PodDisruptionBudget{ pdb := &policy.PodDisruptionBudget{
TypeMeta: unversioned.TypeMeta{APIVersion: registered.GroupOrDie(api.GroupName).GroupVersion.String()}, TypeMeta: unversioned.TypeMeta{APIVersion: registered.GroupOrDie(v1.GroupName).GroupVersion.String()},
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
UID: uuid.NewUUID(), UID: uuid.NewUUID(),
Name: "foobar", Name: "foobar",
Namespace: api.NamespaceDefault, Namespace: v1.NamespaceDefault,
ResourceVersion: "18", ResourceVersion: "18",
}, },
Spec: policy.PodDisruptionBudgetSpec{ Spec: policy.PodDisruptionBudgetSpec{
...@@ -136,21 +137,21 @@ func newPodDisruptionBudget(t *testing.T, minAvailable intstr.IntOrString) (*pol ...@@ -136,21 +137,21 @@ func newPodDisruptionBudget(t *testing.T, minAvailable intstr.IntOrString) (*pol
return pdb, pdbName return pdb, pdbName
} }
func newPod(t *testing.T, name string) (*api.Pod, string) { func newPod(t *testing.T, name string) (*v1.Pod, string) {
pod := &api.Pod{ pod := &v1.Pod{
TypeMeta: unversioned.TypeMeta{APIVersion: registered.GroupOrDie(api.GroupName).GroupVersion.String()}, TypeMeta: unversioned.TypeMeta{APIVersion: registered.GroupOrDie(v1.GroupName).GroupVersion.String()},
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
UID: uuid.NewUUID(), UID: uuid.NewUUID(),
Annotations: make(map[string]string), Annotations: make(map[string]string),
Name: name, Name: name,
Namespace: api.NamespaceDefault, Namespace: v1.NamespaceDefault,
ResourceVersion: "18", ResourceVersion: "18",
Labels: fooBar(), Labels: fooBar(),
}, },
Spec: api.PodSpec{}, Spec: v1.PodSpec{},
Status: api.PodStatus{ Status: v1.PodStatus{
Conditions: []api.PodCondition{ Conditions: []v1.PodCondition{
{Type: api.PodReady, Status: api.ConditionTrue}, {Type: v1.PodReady, Status: v1.ConditionTrue},
}, },
}, },
} }
...@@ -163,18 +164,18 @@ func newPod(t *testing.T, name string) (*api.Pod, string) { ...@@ -163,18 +164,18 @@ func newPod(t *testing.T, name string) (*api.Pod, string) {
return pod, podName return pod, podName
} }
func newReplicationController(t *testing.T, size int32) (*api.ReplicationController, string) { func newReplicationController(t *testing.T, size int32) (*v1.ReplicationController, string) {
rc := &api.ReplicationController{ rc := &v1.ReplicationController{
TypeMeta: unversioned.TypeMeta{APIVersion: registered.GroupOrDie(api.GroupName).GroupVersion.String()}, TypeMeta: unversioned.TypeMeta{APIVersion: registered.GroupOrDie(v1.GroupName).GroupVersion.String()},
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
UID: uuid.NewUUID(), UID: uuid.NewUUID(),
Name: "foobar", Name: "foobar",
Namespace: api.NamespaceDefault, Namespace: v1.NamespaceDefault,
ResourceVersion: "18", ResourceVersion: "18",
Labels: fooBar(), Labels: fooBar(),
}, },
Spec: api.ReplicationControllerSpec{ Spec: v1.ReplicationControllerSpec{
Replicas: size, Replicas: &size,
Selector: fooBar(), Selector: fooBar(),
}, },
} }
...@@ -189,16 +190,16 @@ func newReplicationController(t *testing.T, size int32) (*api.ReplicationControl ...@@ -189,16 +190,16 @@ func newReplicationController(t *testing.T, size int32) (*api.ReplicationControl
func newDeployment(t *testing.T, size int32) (*extensions.Deployment, string) { func newDeployment(t *testing.T, size int32) (*extensions.Deployment, string) {
d := &extensions.Deployment{ d := &extensions.Deployment{
TypeMeta: unversioned.TypeMeta{APIVersion: registered.GroupOrDie(api.GroupName).GroupVersion.String()}, TypeMeta: unversioned.TypeMeta{APIVersion: registered.GroupOrDie(v1.GroupName).GroupVersion.String()},
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
UID: uuid.NewUUID(), UID: uuid.NewUUID(),
Name: "foobar", Name: "foobar",
Namespace: api.NamespaceDefault, Namespace: v1.NamespaceDefault,
ResourceVersion: "18", ResourceVersion: "18",
Labels: fooBar(), Labels: fooBar(),
}, },
Spec: extensions.DeploymentSpec{ Spec: extensions.DeploymentSpec{
Replicas: size, Replicas: &size,
Selector: newSelFooBar(), Selector: newSelFooBar(),
}, },
} }
...@@ -213,16 +214,16 @@ func newDeployment(t *testing.T, size int32) (*extensions.Deployment, string) { ...@@ -213,16 +214,16 @@ func newDeployment(t *testing.T, size int32) (*extensions.Deployment, string) {
func newReplicaSet(t *testing.T, size int32) (*extensions.ReplicaSet, string) { func newReplicaSet(t *testing.T, size int32) (*extensions.ReplicaSet, string) {
rs := &extensions.ReplicaSet{ rs := &extensions.ReplicaSet{
TypeMeta: unversioned.TypeMeta{APIVersion: registered.GroupOrDie(api.GroupName).GroupVersion.String()}, TypeMeta: unversioned.TypeMeta{APIVersion: registered.GroupOrDie(v1.GroupName).GroupVersion.String()},
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
UID: uuid.NewUUID(), UID: uuid.NewUUID(),
Name: "foobar", Name: "foobar",
Namespace: api.NamespaceDefault, Namespace: v1.NamespaceDefault,
ResourceVersion: "18", ResourceVersion: "18",
Labels: fooBar(), Labels: fooBar(),
}, },
Spec: extensions.ReplicaSetSpec{ Spec: extensions.ReplicaSetSpec{
Replicas: size, Replicas: &size,
Selector: newSelFooBar(), Selector: newSelFooBar(),
}, },
} }
...@@ -274,7 +275,7 @@ func TestUnavailable(t *testing.T) { ...@@ -274,7 +275,7 @@ func TestUnavailable(t *testing.T) {
dc.sync(pdbName) dc.sync(pdbName)
// Add three pods, verifying that the counts go up at each step. // Add three pods, verifying that the counts go up at each step.
pods := []*api.Pod{} pods := []*v1.Pod{}
for i := int32(0); i < 4; i++ { for i := int32(0); i < 4; i++ {
ps.VerifyPdbStatus(t, pdbName, 0, i, 3, i, map[string]unversioned.Time{}) ps.VerifyPdbStatus(t, pdbName, 0, i, 3, i, map[string]unversioned.Time{})
pod, _ := newPod(t, fmt.Sprintf("yo-yo-yo %d", i)) pod, _ := newPod(t, fmt.Sprintf("yo-yo-yo %d", i))
...@@ -285,7 +286,7 @@ func TestUnavailable(t *testing.T) { ...@@ -285,7 +286,7 @@ func TestUnavailable(t *testing.T) {
ps.VerifyPdbStatus(t, pdbName, 1, 4, 3, 4, map[string]unversioned.Time{}) ps.VerifyPdbStatus(t, pdbName, 1, 4, 3, 4, map[string]unversioned.Time{})
// Now set one pod as unavailable // Now set one pod as unavailable
pods[0].Status.Conditions = []api.PodCondition{} pods[0].Status.Conditions = []v1.PodCondition{}
update(t, dc.podLister.Indexer, pods[0]) update(t, dc.podLister.Indexer, pods[0])
dc.sync(pdbName) dc.sync(pdbName)
...@@ -387,7 +388,7 @@ func TestReplicationController(t *testing.T) { ...@@ -387,7 +388,7 @@ func TestReplicationController(t *testing.T) {
// about the RC. This is a known bug. TODO(mml): file issue // about the RC. This is a known bug. TODO(mml): file issue
ps.VerifyPdbStatus(t, pdbName, 0, 0, 0, 0, map[string]unversioned.Time{}) ps.VerifyPdbStatus(t, pdbName, 0, 0, 0, 0, map[string]unversioned.Time{})
pods := []*api.Pod{} pods := []*v1.Pod{}
for i := int32(0); i < 3; i++ { for i := int32(0); i < 3; i++ {
pod, _ := newPod(t, fmt.Sprintf("foobar %d", i)) pod, _ := newPod(t, fmt.Sprintf("foobar %d", i))
...@@ -439,7 +440,7 @@ func TestTwoControllers(t *testing.T) { ...@@ -439,7 +440,7 @@ func TestTwoControllers(t *testing.T) {
ps.VerifyPdbStatus(t, pdbName, 0, 0, 0, 0, map[string]unversioned.Time{}) ps.VerifyPdbStatus(t, pdbName, 0, 0, 0, 0, map[string]unversioned.Time{})
pods := []*api.Pod{} pods := []*v1.Pod{}
unavailablePods := collectionSize - minimumOne - 1 unavailablePods := collectionSize - minimumOne - 1
for i := int32(1); i <= collectionSize; i++ { for i := int32(1); i <= collectionSize; i++ {
...@@ -447,7 +448,7 @@ func TestTwoControllers(t *testing.T) { ...@@ -447,7 +448,7 @@ func TestTwoControllers(t *testing.T) {
pods = append(pods, pod) pods = append(pods, pod)
pod.Labels = rcLabels pod.Labels = rcLabels
if i <= unavailablePods { if i <= unavailablePods {
pod.Status.Conditions = []api.PodCondition{} pod.Status.Conditions = []v1.PodCondition{}
} }
add(t, dc.podLister.Indexer, pod) add(t, dc.podLister.Indexer, pod)
dc.sync(pdbName) dc.sync(pdbName)
...@@ -480,7 +481,7 @@ func TestTwoControllers(t *testing.T) { ...@@ -480,7 +481,7 @@ func TestTwoControllers(t *testing.T) {
pods = append(pods, pod) pods = append(pods, pod)
pod.Labels = dLabels pod.Labels = dLabels
if i <= unavailablePods { if i <= unavailablePods {
pod.Status.Conditions = []api.PodCondition{} pod.Status.Conditions = []v1.PodCondition{}
} }
add(t, dc.podLister.Indexer, pod) add(t, dc.podLister.Indexer, pod)
dc.sync(pdbName) dc.sync(pdbName)
...@@ -498,17 +499,17 @@ func TestTwoControllers(t *testing.T) { ...@@ -498,17 +499,17 @@ func TestTwoControllers(t *testing.T) {
// but if we bring down two, it's not. Then we make the pod ready again and // but if we bring down two, it's not. Then we make the pod ready again and
// verify that a disruption is permitted again. // verify that a disruption is permitted again.
ps.VerifyPdbStatus(t, pdbName, 2, 2+minimumTwo, minimumTwo, 2*collectionSize, map[string]unversioned.Time{}) ps.VerifyPdbStatus(t, pdbName, 2, 2+minimumTwo, minimumTwo, 2*collectionSize, map[string]unversioned.Time{})
pods[collectionSize-1].Status.Conditions = []api.PodCondition{} pods[collectionSize-1].Status.Conditions = []v1.PodCondition{}
update(t, dc.podLister.Indexer, pods[collectionSize-1]) update(t, dc.podLister.Indexer, pods[collectionSize-1])
dc.sync(pdbName) dc.sync(pdbName)
ps.VerifyPdbStatus(t, pdbName, 1, 1+minimumTwo, minimumTwo, 2*collectionSize, map[string]unversioned.Time{}) ps.VerifyPdbStatus(t, pdbName, 1, 1+minimumTwo, minimumTwo, 2*collectionSize, map[string]unversioned.Time{})
pods[collectionSize-2].Status.Conditions = []api.PodCondition{} pods[collectionSize-2].Status.Conditions = []v1.PodCondition{}
update(t, dc.podLister.Indexer, pods[collectionSize-2]) update(t, dc.podLister.Indexer, pods[collectionSize-2])
dc.sync(pdbName) dc.sync(pdbName)
ps.VerifyPdbStatus(t, pdbName, 0, minimumTwo, minimumTwo, 2*collectionSize, map[string]unversioned.Time{}) ps.VerifyPdbStatus(t, pdbName, 0, minimumTwo, minimumTwo, 2*collectionSize, map[string]unversioned.Time{})
pods[collectionSize-1].Status.Conditions = []api.PodCondition{{Type: api.PodReady, Status: api.ConditionTrue}} pods[collectionSize-1].Status.Conditions = []v1.PodCondition{{Type: v1.PodReady, Status: v1.ConditionTrue}}
update(t, dc.podLister.Indexer, pods[collectionSize-1]) update(t, dc.podLister.Indexer, pods[collectionSize-1])
dc.sync(pdbName) dc.sync(pdbName)
ps.VerifyPdbStatus(t, pdbName, 1, 1+minimumTwo, minimumTwo, 2*collectionSize, map[string]unversioned.Time{}) ps.VerifyPdbStatus(t, pdbName, 1, 1+minimumTwo, minimumTwo, 2*collectionSize, map[string]unversioned.Time{})
......
...@@ -24,13 +24,13 @@ import ( ...@@ -24,13 +24,13 @@ import (
"encoding/json" "encoding/json"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/endpoints"
"k8s.io/kubernetes/pkg/api/errors" "k8s.io/kubernetes/pkg/api/errors"
podutil "k8s.io/kubernetes/pkg/api/pod" "k8s.io/kubernetes/pkg/api/v1"
utilpod "k8s.io/kubernetes/pkg/api/pod" "k8s.io/kubernetes/pkg/api/v1/endpoints"
podutil "k8s.io/kubernetes/pkg/api/v1/pod"
utilpod "k8s.io/kubernetes/pkg/api/v1/pod"
"k8s.io/kubernetes/pkg/client/cache" "k8s.io/kubernetes/pkg/client/cache"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" clientset "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5"
"k8s.io/kubernetes/pkg/controller" "k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/pkg/controller/informers" "k8s.io/kubernetes/pkg/controller/informers"
"k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/labels"
...@@ -80,14 +80,14 @@ func NewEndpointController(podInformer cache.SharedIndexInformer, client clients ...@@ -80,14 +80,14 @@ func NewEndpointController(podInformer cache.SharedIndexInformer, client clients
e.serviceStore.Indexer, e.serviceController = cache.NewIndexerInformer( e.serviceStore.Indexer, e.serviceController = cache.NewIndexerInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options api.ListOptions) (runtime.Object, error) { ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return e.client.Core().Services(api.NamespaceAll).List(options) return e.client.Core().Services(v1.NamespaceAll).List(options)
}, },
WatchFunc: func(options api.ListOptions) (watch.Interface, error) { WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return e.client.Core().Services(api.NamespaceAll).Watch(options) return e.client.Core().Services(v1.NamespaceAll).Watch(options)
}, },
}, },
&api.Service{}, &v1.Service{},
// TODO: Can we have much longer period here? // TODO: Can we have much longer period here?
FullServiceResyncPeriod, FullServiceResyncPeriod,
cache.ResourceEventHandlerFuncs{ cache.ResourceEventHandlerFuncs{
...@@ -180,7 +180,7 @@ func (e *EndpointController) Run(workers int, stopCh <-chan struct{}) { ...@@ -180,7 +180,7 @@ func (e *EndpointController) Run(workers int, stopCh <-chan struct{}) {
<-stopCh <-stopCh
} }
func (e *EndpointController) getPodServiceMemberships(pod *api.Pod) (sets.String, error) { func (e *EndpointController) getPodServiceMemberships(pod *v1.Pod) (sets.String, error) {
set := sets.String{} set := sets.String{}
services, err := e.serviceStore.GetPodServices(pod) services, err := e.serviceStore.GetPodServices(pod)
if err != nil { if err != nil {
...@@ -199,9 +199,9 @@ func (e *EndpointController) getPodServiceMemberships(pod *api.Pod) (sets.String ...@@ -199,9 +199,9 @@ func (e *EndpointController) getPodServiceMemberships(pod *api.Pod) (sets.String
} }
// When a pod is added, figure out what services it will be a member of and // When a pod is added, figure out what services it will be a member of and
// enqueue them. obj must have *api.Pod type. // enqueue them. obj must have *v1.Pod type.
func (e *EndpointController) addPod(obj interface{}) { func (e *EndpointController) addPod(obj interface{}) {
pod := obj.(*api.Pod) pod := obj.(*v1.Pod)
services, err := e.getPodServiceMemberships(pod) services, err := e.getPodServiceMemberships(pod)
if err != nil { if err != nil {
utilruntime.HandleError(fmt.Errorf("Unable to get pod %v/%v's service memberships: %v", pod.Namespace, pod.Name, err)) utilruntime.HandleError(fmt.Errorf("Unable to get pod %v/%v's service memberships: %v", pod.Namespace, pod.Name, err))
...@@ -214,10 +214,10 @@ func (e *EndpointController) addPod(obj interface{}) { ...@@ -214,10 +214,10 @@ func (e *EndpointController) addPod(obj interface{}) {
// When a pod is updated, figure out what services it used to be a member of // When a pod is updated, figure out what services it used to be a member of
// and what services it will be a member of, and enqueue the union of these. // and what services it will be a member of, and enqueue the union of these.
// old and cur must be *api.Pod types. // old and cur must be *v1.Pod types.
func (e *EndpointController) updatePod(old, cur interface{}) { func (e *EndpointController) updatePod(old, cur interface{}) {
newPod := cur.(*api.Pod) newPod := cur.(*v1.Pod)
oldPod := old.(*api.Pod) oldPod := old.(*v1.Pod)
if newPod.ResourceVersion == oldPod.ResourceVersion { if newPod.ResourceVersion == oldPod.ResourceVersion {
// Periodic resync will send update events for all known pods. // Periodic resync will send update events for all known pods.
// Two different versions of the same pod will always have different RVs. // Two different versions of the same pod will always have different RVs.
...@@ -244,12 +244,12 @@ func (e *EndpointController) updatePod(old, cur interface{}) { ...@@ -244,12 +244,12 @@ func (e *EndpointController) updatePod(old, cur interface{}) {
} }
} }
func hostNameAndDomainAreEqual(pod1, pod2 *api.Pod) bool { func hostNameAndDomainAreEqual(pod1, pod2 *v1.Pod) bool {
return getHostname(pod1) == getHostname(pod2) && return getHostname(pod1) == getHostname(pod2) &&
getSubdomain(pod1) == getSubdomain(pod2) getSubdomain(pod1) == getSubdomain(pod2)
} }
func getHostname(pod *api.Pod) string { func getHostname(pod *v1.Pod) string {
if len(pod.Spec.Hostname) > 0 { if len(pod.Spec.Hostname) > 0 {
return pod.Spec.Hostname return pod.Spec.Hostname
} }
...@@ -259,7 +259,7 @@ func getHostname(pod *api.Pod) string { ...@@ -259,7 +259,7 @@ func getHostname(pod *api.Pod) string {
return "" return ""
} }
func getSubdomain(pod *api.Pod) string { func getSubdomain(pod *v1.Pod) string {
if len(pod.Spec.Subdomain) > 0 { if len(pod.Spec.Subdomain) > 0 {
return pod.Spec.Subdomain return pod.Spec.Subdomain
} }
...@@ -270,9 +270,9 @@ func getSubdomain(pod *api.Pod) string { ...@@ -270,9 +270,9 @@ func getSubdomain(pod *api.Pod) string {
} }
// When a pod is deleted, enqueue the services the pod used to be a member of. // When a pod is deleted, enqueue the services the pod used to be a member of.
// obj could be an *api.Pod, or a DeletionFinalStateUnknown marker item. // obj could be an *v1.Pod, or a DeletionFinalStateUnknown marker item.
func (e *EndpointController) deletePod(obj interface{}) { func (e *EndpointController) deletePod(obj interface{}) {
if _, ok := obj.(*api.Pod); ok { if _, ok := obj.(*v1.Pod); ok {
// Enqueue all the services that the pod used to be a member // Enqueue all the services that the pod used to be a member
// of. This happens to be exactly the same thing we do when a // of. This happens to be exactly the same thing we do when a
// pod is added. // pod is added.
...@@ -289,7 +289,7 @@ func (e *EndpointController) deletePod(obj interface{}) { ...@@ -289,7 +289,7 @@ func (e *EndpointController) deletePod(obj interface{}) {
// TODO: keep a map of pods to services to handle this condition. // TODO: keep a map of pods to services to handle this condition.
} }
// obj could be an *api.Service, or a DeletionFinalStateUnknown marker item. // obj could be an *v1.Service, or a DeletionFinalStateUnknown marker item.
func (e *EndpointController) enqueueService(obj interface{}) { func (e *EndpointController) enqueueService(obj interface{}) {
key, err := keyFunc(obj) key, err := keyFunc(obj)
if err != nil { if err != nil {
...@@ -354,7 +354,7 @@ func (e *EndpointController) syncService(key string) error { ...@@ -354,7 +354,7 @@ func (e *EndpointController) syncService(key string) error {
return nil return nil
} }
service := obj.(*api.Service) service := obj.(*v1.Service)
if service.Spec.Selector == nil { if service.Spec.Selector == nil {
// services without a selector receive no endpoints from this controller; // services without a selector receive no endpoints from this controller;
// these services will receive the endpoints that are created out-of-band via the REST API. // these services will receive the endpoints that are created out-of-band via the REST API.
...@@ -369,7 +369,7 @@ func (e *EndpointController) syncService(key string) error { ...@@ -369,7 +369,7 @@ func (e *EndpointController) syncService(key string) error {
return err return err
} }
subsets := []api.EndpointSubset{} subsets := []v1.EndpointSubset{}
podHostNames := map[string]endpoints.HostRecord{} podHostNames := map[string]endpoints.HostRecord{}
var tolerateUnreadyEndpoints bool var tolerateUnreadyEndpoints bool
...@@ -407,11 +407,11 @@ func (e *EndpointController) syncService(key string) error { ...@@ -407,11 +407,11 @@ func (e *EndpointController) syncService(key string) error {
continue continue
} }
epp := api.EndpointPort{Name: portName, Port: int32(portNum), Protocol: portProto} epp := v1.EndpointPort{Name: portName, Port: int32(portNum), Protocol: portProto}
epa := api.EndpointAddress{ epa := v1.EndpointAddress{
IP: pod.Status.PodIP, IP: pod.Status.PodIP,
NodeName: &pod.Spec.NodeName, NodeName: &pod.Spec.NodeName,
TargetRef: &api.ObjectReference{ TargetRef: &v1.ObjectReference{
Kind: "Pod", Kind: "Pod",
Namespace: pod.ObjectMeta.Namespace, Namespace: pod.ObjectMeta.Namespace,
Name: pod.ObjectMeta.Name, Name: pod.ObjectMeta.Name,
...@@ -431,17 +431,17 @@ func (e *EndpointController) syncService(key string) error { ...@@ -431,17 +431,17 @@ func (e *EndpointController) syncService(key string) error {
epa.Hostname = hostname epa.Hostname = hostname
} }
if tolerateUnreadyEndpoints || api.IsPodReady(pod) { if tolerateUnreadyEndpoints || v1.IsPodReady(pod) {
subsets = append(subsets, api.EndpointSubset{ subsets = append(subsets, v1.EndpointSubset{
Addresses: []api.EndpointAddress{epa}, Addresses: []v1.EndpointAddress{epa},
Ports: []api.EndpointPort{epp}, Ports: []v1.EndpointPort{epp},
}) })
readyEps++ readyEps++
} else { } else {
glog.V(5).Infof("Pod is out of service: %v/%v", pod.Namespace, pod.Name) glog.V(5).Infof("Pod is out of service: %v/%v", pod.Namespace, pod.Name)
subsets = append(subsets, api.EndpointSubset{ subsets = append(subsets, v1.EndpointSubset{
NotReadyAddresses: []api.EndpointAddress{epa}, NotReadyAddresses: []v1.EndpointAddress{epa},
Ports: []api.EndpointPort{epp}, Ports: []v1.EndpointPort{epp},
}) })
notReadyEps++ notReadyEps++
} }
...@@ -453,8 +453,8 @@ func (e *EndpointController) syncService(key string) error { ...@@ -453,8 +453,8 @@ func (e *EndpointController) syncService(key string) error {
currentEndpoints, err := e.client.Core().Endpoints(service.Namespace).Get(service.Name) currentEndpoints, err := e.client.Core().Endpoints(service.Namespace).Get(service.Name)
if err != nil { if err != nil {
if errors.IsNotFound(err) { if errors.IsNotFound(err) {
currentEndpoints = &api.Endpoints{ currentEndpoints = &v1.Endpoints{
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Name: service.Name, Name: service.Name,
Labels: service.Labels, Labels: service.Labels,
}, },
...@@ -521,7 +521,7 @@ func (e *EndpointController) syncService(key string) error { ...@@ -521,7 +521,7 @@ func (e *EndpointController) syncService(key string) error {
// some stragglers could have been left behind if the endpoint controller // some stragglers could have been left behind if the endpoint controller
// reboots). // reboots).
func (e *EndpointController) checkLeftoverEndpoints() { func (e *EndpointController) checkLeftoverEndpoints() {
list, err := e.client.Core().Endpoints(api.NamespaceAll).List(api.ListOptions{}) list, err := e.client.Core().Endpoints(v1.NamespaceAll).List(v1.ListOptions{})
if err != nil { if err != nil {
utilruntime.HandleError(fmt.Errorf("Unable to list endpoints (%v); orphaned endpoints will not be cleaned up. (They're pretty harmless, but you can restart this component if you want another attempt made.)", err)) utilruntime.HandleError(fmt.Errorf("Unable to list endpoints (%v); orphaned endpoints will not be cleaned up. (They're pretty harmless, but you can restart this component if you want another attempt made.)", err))
return return
......
...@@ -232,7 +232,7 @@ func shouldOrphanDependents(e *event, accessor meta.Object) bool { ...@@ -232,7 +232,7 @@ func shouldOrphanDependents(e *event, accessor meta.Object) bool {
} }
finalizers := accessor.GetFinalizers() finalizers := accessor.GetFinalizers()
for _, finalizer := range finalizers { for _, finalizer := range finalizers {
if finalizer == api.FinalizerOrphan { if finalizer == v1.FinalizerOrphan {
return true return true
} }
} }
...@@ -277,7 +277,7 @@ func (gc *GarbageCollector) removeOrphanFinalizer(owner *node) error { ...@@ -277,7 +277,7 @@ func (gc *GarbageCollector) removeOrphanFinalizer(owner *node) error {
var newFinalizers []string var newFinalizers []string
found := false found := false
for _, f := range finalizers { for _, f := range finalizers {
if f == api.FinalizerOrphan { if f == v1.FinalizerOrphan {
found = true found = true
break break
} else { } else {
...@@ -450,24 +450,24 @@ type GarbageCollector struct { ...@@ -450,24 +450,24 @@ type GarbageCollector struct {
func gcListWatcher(client *dynamic.Client, resource unversioned.GroupVersionResource) *cache.ListWatch { func gcListWatcher(client *dynamic.Client, resource unversioned.GroupVersionResource) *cache.ListWatch {
return &cache.ListWatch{ return &cache.ListWatch{
ListFunc: func(options api.ListOptions) (runtime.Object, error) { ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
// APIResource.Kind is not used by the dynamic client, so // APIResource.Kind is not used by the dynamic client, so
// leave it empty. We want to list this resource in all // leave it empty. We want to list this resource in all
// namespaces if it's namespace scoped, so leave // namespaces if it's namespace scoped, so leave
// APIResource.Namespaced as false is all right. // APIResource.Namespaced as false is all right.
apiResource := unversioned.APIResource{Name: resource.Resource} apiResource := unversioned.APIResource{Name: resource.Resource}
return client.ParameterCodec(dynamic.VersionedParameterEncoderWithV1Fallback). return client.ParameterCodec(dynamic.VersionedParameterEncoderWithV1Fallback).
Resource(&apiResource, api.NamespaceAll). Resource(&apiResource, v1.NamespaceAll).
List(&options) List(&options)
}, },
WatchFunc: func(options api.ListOptions) (watch.Interface, error) { WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
// APIResource.Kind is not used by the dynamic client, so // APIResource.Kind is not used by the dynamic client, so
// leave it empty. We want to list this resource in all // leave it empty. We want to list this resource in all
// namespaces if it's namespace scoped, so leave // namespaces if it's namespace scoped, so leave
// APIResource.Namespaced as false is all right. // APIResource.Namespaced as false is all right.
apiResource := unversioned.APIResource{Name: resource.Resource} apiResource := unversioned.APIResource{Name: resource.Resource}
return client.ParameterCodec(dynamic.VersionedParameterEncoderWithV1Fallback). return client.ParameterCodec(dynamic.VersionedParameterEncoderWithV1Fallback).
Resource(&apiResource, api.NamespaceAll). Resource(&apiResource, v1.NamespaceAll).
Watch(&options) Watch(&options)
}, },
} }
......
...@@ -27,7 +27,6 @@ import ( ...@@ -27,7 +27,6 @@ import (
_ "k8s.io/kubernetes/pkg/api/install" _ "k8s.io/kubernetes/pkg/api/install"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/meta/metatypes" "k8s.io/kubernetes/pkg/api/meta/metatypes"
"k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/v1" "k8s.io/kubernetes/pkg/api/v1"
...@@ -231,14 +230,14 @@ func verifyGraphInvariants(scenario string, uidToNode map[types.UID]*node, t *te ...@@ -231,14 +230,14 @@ func verifyGraphInvariants(scenario string, uidToNode map[types.UID]*node, t *te
} }
func createEvent(eventType eventType, selfUID string, owners []string) event { func createEvent(eventType eventType, selfUID string, owners []string) event {
var ownerReferences []api.OwnerReference var ownerReferences []v1.OwnerReference
for i := 0; i < len(owners); i++ { for i := 0; i < len(owners); i++ {
ownerReferences = append(ownerReferences, api.OwnerReference{UID: types.UID(owners[i])}) ownerReferences = append(ownerReferences, v1.OwnerReference{UID: types.UID(owners[i])})
} }
return event{ return event{
eventType: eventType, eventType: eventType,
obj: &api.Pod{ obj: &v1.Pod{
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
UID: types.UID(selfUID), UID: types.UID(selfUID),
OwnerReferences: ownerReferences, OwnerReferences: ownerReferences,
}, },
...@@ -350,8 +349,8 @@ func TestGCListWatcher(t *testing.T) { ...@@ -350,8 +349,8 @@ func TestGCListWatcher(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
lw := gcListWatcher(client, podResource) lw := gcListWatcher(client, podResource)
lw.Watch(api.ListOptions{ResourceVersion: "1"}) lw.Watch(v1.ListOptions{ResourceVersion: "1"})
lw.List(api.ListOptions{ResourceVersion: "1"}) lw.List(v1.ListOptions{ResourceVersion: "1"})
if e, a := 2, len(testHandler.actions); e != a { if e, a := 2, len(testHandler.actions); e != a {
t.Errorf("expect %d requests, got %d", e, a) t.Errorf("expect %d requests, got %d", e, a)
} }
......
...@@ -24,13 +24,14 @@ package metaonly ...@@ -24,13 +24,14 @@ package metaonly
import ( import (
"errors" "errors"
"fmt" "fmt"
"reflect"
"runtime"
time "time"
codec1978 "github.com/ugorji/go/codec" codec1978 "github.com/ugorji/go/codec"
pkg1_unversioned "k8s.io/kubernetes/pkg/api/unversioned" pkg1_unversioned "k8s.io/kubernetes/pkg/api/unversioned"
pkg2_v1 "k8s.io/kubernetes/pkg/api/v1" pkg2_v1 "k8s.io/kubernetes/pkg/api/v1"
pkg3_types "k8s.io/kubernetes/pkg/types" pkg3_types "k8s.io/kubernetes/pkg/types"
"reflect"
"runtime"
time "time"
) )
const ( const (
......
...@@ -20,11 +20,11 @@ import ( ...@@ -20,11 +20,11 @@ import (
"reflect" "reflect"
"time" "time"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apis/batch" batch "k8s.io/kubernetes/pkg/apis/batch/v1"
"k8s.io/kubernetes/pkg/client/cache" "k8s.io/kubernetes/pkg/client/cache"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" clientset "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5"
batchinternallisters "k8s.io/kubernetes/pkg/client/listers/batch/internalversion" batchv1listers "k8s.io/kubernetes/pkg/client/listers/batch/v1"
"k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/watch" "k8s.io/kubernetes/pkg/watch"
) )
...@@ -33,7 +33,7 @@ import ( ...@@ -33,7 +33,7 @@ import (
// Interface provides constructor for informer and lister for jobs // Interface provides constructor for informer and lister for jobs
type JobInformer interface { type JobInformer interface {
Informer() cache.SharedIndexInformer Informer() cache.SharedIndexInformer
Lister() batchinternallisters.JobLister Lister() batchv1listers.JobLister
} }
type jobInformer struct { type jobInformer struct {
...@@ -61,11 +61,11 @@ func (f *jobInformer) Informer() cache.SharedIndexInformer { ...@@ -61,11 +61,11 @@ func (f *jobInformer) Informer() cache.SharedIndexInformer {
func NewJobInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { func NewJobInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer( sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options api.ListOptions) (runtime.Object, error) { ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return client.Batch().Jobs(api.NamespaceAll).List(options) return client.Batch().Jobs(v1.NamespaceAll).List(options)
}, },
WatchFunc: func(options api.ListOptions) (watch.Interface, error) { WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return client.Batch().Jobs(api.NamespaceAll).Watch(options) return client.Batch().Jobs(v1.NamespaceAll).Watch(options)
}, },
}, },
&batch.Job{}, &batch.Job{},
...@@ -77,7 +77,7 @@ func NewJobInformer(client clientset.Interface, resyncPeriod time.Duration) cach ...@@ -77,7 +77,7 @@ func NewJobInformer(client clientset.Interface, resyncPeriod time.Duration) cach
} }
// Lister returns lister for jobInformer // Lister returns lister for jobInformer
func (f *jobInformer) Lister() batchinternallisters.JobLister { func (f *jobInformer) Lister() batchv1listers.JobLister {
informer := f.Informer() informer := f.Informer()
return batchinternallisters.NewJobLister(informer.GetIndexer()) return batchv1listers.NewJobLister(informer.GetIndexer())
} }
...@@ -20,8 +20,8 @@ import ( ...@@ -20,8 +20,8 @@ import (
"reflect" "reflect"
"time" "time"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apis/extensions" extensions "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
"k8s.io/kubernetes/pkg/client/cache" "k8s.io/kubernetes/pkg/client/cache"
"k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/watch" "k8s.io/kubernetes/pkg/watch"
...@@ -49,11 +49,11 @@ func (f *daemonSetInformer) Informer() cache.SharedIndexInformer { ...@@ -49,11 +49,11 @@ func (f *daemonSetInformer) Informer() cache.SharedIndexInformer {
} }
informer = cache.NewSharedIndexInformer( informer = cache.NewSharedIndexInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options api.ListOptions) (runtime.Object, error) { ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return f.client.Extensions().DaemonSets(api.NamespaceAll).List(options) return f.client.Extensions().DaemonSets(v1.NamespaceAll).List(options)
}, },
WatchFunc: func(options api.ListOptions) (watch.Interface, error) { WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return f.client.Extensions().DaemonSets(api.NamespaceAll).Watch(options) return f.client.Extensions().DaemonSets(v1.NamespaceAll).Watch(options)
}, },
}, },
&extensions.DaemonSet{}, &extensions.DaemonSet{},
...@@ -91,11 +91,11 @@ func (f *deploymentInformer) Informer() cache.SharedIndexInformer { ...@@ -91,11 +91,11 @@ func (f *deploymentInformer) Informer() cache.SharedIndexInformer {
} }
informer = cache.NewSharedIndexInformer( informer = cache.NewSharedIndexInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options api.ListOptions) (runtime.Object, error) { ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return f.client.Extensions().Deployments(api.NamespaceAll).List(options) return f.client.Extensions().Deployments(v1.NamespaceAll).List(options)
}, },
WatchFunc: func(options api.ListOptions) (watch.Interface, error) { WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return f.client.Extensions().Deployments(api.NamespaceAll).Watch(options) return f.client.Extensions().Deployments(v1.NamespaceAll).Watch(options)
}, },
}, },
&extensions.Deployment{}, &extensions.Deployment{},
...@@ -135,11 +135,11 @@ func (f *replicaSetInformer) Informer() cache.SharedIndexInformer { ...@@ -135,11 +135,11 @@ func (f *replicaSetInformer) Informer() cache.SharedIndexInformer {
} }
informer = cache.NewSharedIndexInformer( informer = cache.NewSharedIndexInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options api.ListOptions) (runtime.Object, error) { ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return f.client.Extensions().ReplicaSets(api.NamespaceAll).List(options) return f.client.Extensions().ReplicaSets(v1.NamespaceAll).List(options)
}, },
WatchFunc: func(options api.ListOptions) (watch.Interface, error) { WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return f.client.Extensions().ReplicaSets(api.NamespaceAll).Watch(options) return f.client.Extensions().ReplicaSets(v1.NamespaceAll).Watch(options)
}, },
}, },
&extensions.ReplicaSet{}, &extensions.ReplicaSet{},
......
...@@ -23,7 +23,8 @@ import ( ...@@ -23,7 +23,8 @@ import (
"k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/client/cache" "k8s.io/kubernetes/pkg/client/cache"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5"
) )
// SharedInformerFactory provides interface which holds unique informers for pods, nodes, namespaces, persistent volume // SharedInformerFactory provides interface which holds unique informers for pods, nodes, namespaces, persistent volume
...@@ -38,7 +39,9 @@ type SharedInformerFactory interface { ...@@ -38,7 +39,9 @@ type SharedInformerFactory interface {
Pods() PodInformer Pods() PodInformer
LimitRanges() LimitRangeInformer LimitRanges() LimitRangeInformer
InternalLimitRanges() InternalLimitRangeInformer
Namespaces() NamespaceInformer Namespaces() NamespaceInformer
InternalNamespaces() InternalNamespaceInformer
Nodes() NodeInformer Nodes() NodeInformer
PersistentVolumeClaims() PVCInformer PersistentVolumeClaims() PVCInformer
PersistentVolumes() PVInformer PersistentVolumes() PVInformer
...@@ -60,6 +63,8 @@ type SharedInformerFactory interface { ...@@ -60,6 +63,8 @@ type SharedInformerFactory interface {
type sharedInformerFactory struct { type sharedInformerFactory struct {
client clientset.Interface client clientset.Interface
// for admission plugins etc.
internalclient internalclientset.Interface
lock sync.Mutex lock sync.Mutex
defaultResync time.Duration defaultResync time.Duration
...@@ -70,9 +75,10 @@ type sharedInformerFactory struct { ...@@ -70,9 +75,10 @@ type sharedInformerFactory struct {
} }
// NewSharedInformerFactory constructs a new instance of sharedInformerFactory // NewSharedInformerFactory constructs a new instance of sharedInformerFactory
func NewSharedInformerFactory(client clientset.Interface, defaultResync time.Duration) SharedInformerFactory { func NewSharedInformerFactory(client clientset.Interface, internalclient internalclientset.Interface, defaultResync time.Duration) SharedInformerFactory {
return &sharedInformerFactory{ return &sharedInformerFactory{
client: client, client: client,
internalclient: internalclient,
defaultResync: defaultResync, defaultResync: defaultResync,
informers: make(map[reflect.Type]cache.SharedIndexInformer), informers: make(map[reflect.Type]cache.SharedIndexInformer),
startedInformers: make(map[reflect.Type]bool), startedInformers: make(map[reflect.Type]bool),
...@@ -107,6 +113,11 @@ func (f *sharedInformerFactory) Namespaces() NamespaceInformer { ...@@ -107,6 +113,11 @@ func (f *sharedInformerFactory) Namespaces() NamespaceInformer {
return &namespaceInformer{sharedInformerFactory: f} return &namespaceInformer{sharedInformerFactory: f}
} }
// InternalNamespaces returns a SharedIndexInformer that lists and watches all namespaces
func (f *sharedInformerFactory) InternalNamespaces() InternalNamespaceInformer {
return &internalNamespaceInformer{sharedInformerFactory: f}
}
// PersistentVolumeClaims returns a SharedIndexInformer that lists and watches all persistent volume claims // PersistentVolumeClaims returns a SharedIndexInformer that lists and watches all persistent volume claims
func (f *sharedInformerFactory) PersistentVolumeClaims() PVCInformer { func (f *sharedInformerFactory) PersistentVolumeClaims() PVCInformer {
return &pvcInformer{sharedInformerFactory: f} return &pvcInformer{sharedInformerFactory: f}
...@@ -156,6 +167,11 @@ func (f *sharedInformerFactory) LimitRanges() LimitRangeInformer { ...@@ -156,6 +167,11 @@ func (f *sharedInformerFactory) LimitRanges() LimitRangeInformer {
return &limitRangeInformer{sharedInformerFactory: f} return &limitRangeInformer{sharedInformerFactory: f}
} }
// InternalLimitRanges returns a SharedIndexInformer that lists and watches all limit ranges.
func (f *sharedInformerFactory) InternalLimitRanges() InternalLimitRangeInformer {
return &internalLimitRangeInformer{sharedInformerFactory: f}
}
// StorageClasses returns a SharedIndexInformer that lists and watches all storage classes // StorageClasses returns a SharedIndexInformer that lists and watches all storage classes
func (f *sharedInformerFactory) StorageClasses() StorageClassInformer { func (f *sharedInformerFactory) StorageClasses() StorageClassInformer {
return &storageClassInformer{sharedInformerFactory: f} return &storageClassInformer{sharedInformerFactory: f}
......
...@@ -22,8 +22,8 @@ import ( ...@@ -22,8 +22,8 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apis/batch" "k8s.io/kubernetes/pkg/apis/batch"
"k8s.io/kubernetes/pkg/apis/extensions" extensionsinternal "k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/apis/rbac" rbacinternal "k8s.io/kubernetes/pkg/apis/rbac"
"k8s.io/kubernetes/pkg/client/cache" "k8s.io/kubernetes/pkg/client/cache"
) )
...@@ -53,20 +53,20 @@ func (f *sharedInformerFactory) ForResource(resource unversioned.GroupResource) ...@@ -53,20 +53,20 @@ func (f *sharedInformerFactory) ForResource(resource unversioned.GroupResource)
case api.Resource("serviceaccounts"): case api.Resource("serviceaccounts"):
return &genericInformer{resource: resource, informer: f.ServiceAccounts().Informer()}, nil return &genericInformer{resource: resource, informer: f.ServiceAccounts().Informer()}, nil
case extensions.Resource("daemonsets"): case extensionsinternal.Resource("daemonsets"):
return &genericInformer{resource: resource, informer: f.DaemonSets().Informer()}, nil return &genericInformer{resource: resource, informer: f.DaemonSets().Informer()}, nil
case extensions.Resource("deployments"): case extensionsinternal.Resource("deployments"):
return &genericInformer{resource: resource, informer: f.Deployments().Informer()}, nil return &genericInformer{resource: resource, informer: f.Deployments().Informer()}, nil
case extensions.Resource("replicasets"): case extensionsinternal.Resource("replicasets"):
return &genericInformer{resource: resource, informer: f.ReplicaSets().Informer()}, nil return &genericInformer{resource: resource, informer: f.ReplicaSets().Informer()}, nil
case rbac.Resource("clusterrolebindings"): case rbacinternal.Resource("clusterrolebindings"):
return &genericInformer{resource: resource, informer: f.ClusterRoleBindings().Informer()}, nil return &genericInformer{resource: resource, informer: f.ClusterRoleBindings().Informer()}, nil
case rbac.Resource("clusterroles"): case rbacinternal.Resource("clusterroles"):
return &genericInformer{resource: resource, informer: f.ClusterRoles().Informer()}, nil return &genericInformer{resource: resource, informer: f.ClusterRoles().Informer()}, nil
case rbac.Resource("rolebindings"): case rbacinternal.Resource("rolebindings"):
return &genericInformer{resource: resource, informer: f.RoleBindings().Informer()}, nil return &genericInformer{resource: resource, informer: f.RoleBindings().Informer()}, nil
case rbac.Resource("roles"): case rbacinternal.Resource("roles"):
return &genericInformer{resource: resource, informer: f.Roles().Informer()}, nil return &genericInformer{resource: resource, informer: f.Roles().Informer()}, nil
case batch.Resource("jobs"): case batch.Resource("jobs"):
......
...@@ -19,8 +19,8 @@ package informers ...@@ -19,8 +19,8 @@ package informers
import ( import (
"reflect" "reflect"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apis/rbac" rbac "k8s.io/kubernetes/pkg/apis/rbac"
"k8s.io/kubernetes/pkg/client/cache" "k8s.io/kubernetes/pkg/client/cache"
"k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/watch" "k8s.io/kubernetes/pkg/watch"
...@@ -46,10 +46,10 @@ func (f *clusterRoleInformer) Informer() cache.SharedIndexInformer { ...@@ -46,10 +46,10 @@ func (f *clusterRoleInformer) Informer() cache.SharedIndexInformer {
} }
informer = cache.NewSharedIndexInformer( informer = cache.NewSharedIndexInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options api.ListOptions) (runtime.Object, error) { ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return f.client.Rbac().ClusterRoles().List(options) return f.client.Rbac().ClusterRoles().List(options)
}, },
WatchFunc: func(options api.ListOptions) (watch.Interface, error) { WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return f.client.Rbac().ClusterRoles().Watch(options) return f.client.Rbac().ClusterRoles().Watch(options)
}, },
}, },
...@@ -86,10 +86,10 @@ func (f *clusterRoleBindingInformer) Informer() cache.SharedIndexInformer { ...@@ -86,10 +86,10 @@ func (f *clusterRoleBindingInformer) Informer() cache.SharedIndexInformer {
} }
informer = cache.NewSharedIndexInformer( informer = cache.NewSharedIndexInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options api.ListOptions) (runtime.Object, error) { ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return f.client.Rbac().ClusterRoleBindings().List(options) return f.client.Rbac().ClusterRoleBindings().List(options)
}, },
WatchFunc: func(options api.ListOptions) (watch.Interface, error) { WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return f.client.Rbac().ClusterRoleBindings().Watch(options) return f.client.Rbac().ClusterRoleBindings().Watch(options)
}, },
}, },
...@@ -126,11 +126,11 @@ func (f *roleInformer) Informer() cache.SharedIndexInformer { ...@@ -126,11 +126,11 @@ func (f *roleInformer) Informer() cache.SharedIndexInformer {
} }
informer = cache.NewSharedIndexInformer( informer = cache.NewSharedIndexInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options api.ListOptions) (runtime.Object, error) { ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return f.client.Rbac().Roles(api.NamespaceAll).List(options) return f.client.Rbac().Roles(v1.NamespaceAll).List(options)
}, },
WatchFunc: func(options api.ListOptions) (watch.Interface, error) { WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return f.client.Rbac().Roles(api.NamespaceAll).Watch(options) return f.client.Rbac().Roles(v1.NamespaceAll).Watch(options)
}, },
}, },
&rbac.Role{}, &rbac.Role{},
...@@ -166,11 +166,11 @@ func (f *roleBindingInformer) Informer() cache.SharedIndexInformer { ...@@ -166,11 +166,11 @@ func (f *roleBindingInformer) Informer() cache.SharedIndexInformer {
} }
informer = cache.NewSharedIndexInformer( informer = cache.NewSharedIndexInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options api.ListOptions) (runtime.Object, error) { ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return f.client.Rbac().RoleBindings(api.NamespaceAll).List(options) return f.client.Rbac().RoleBindings(v1.NamespaceAll).List(options)
}, },
WatchFunc: func(options api.ListOptions) (watch.Interface, error) { WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return f.client.Rbac().RoleBindings(api.NamespaceAll).Watch(options) return f.client.Rbac().RoleBindings(v1.NamespaceAll).Watch(options)
}, },
}, },
&rbac.RoleBinding{}, &rbac.RoleBinding{},
......
...@@ -19,8 +19,8 @@ package informers ...@@ -19,8 +19,8 @@ package informers
import ( import (
"reflect" "reflect"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apis/storage" storage "k8s.io/kubernetes/pkg/apis/storage/v1beta1"
"k8s.io/kubernetes/pkg/client/cache" "k8s.io/kubernetes/pkg/client/cache"
"k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/watch" "k8s.io/kubernetes/pkg/watch"
...@@ -48,10 +48,10 @@ func (f *storageClassInformer) Informer() cache.SharedIndexInformer { ...@@ -48,10 +48,10 @@ func (f *storageClassInformer) Informer() cache.SharedIndexInformer {
} }
informer = cache.NewSharedIndexInformer( informer = cache.NewSharedIndexInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options api.ListOptions) (runtime.Object, error) { ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return f.client.Storage().StorageClasses().List(options) return f.client.Storage().StorageClasses().List(options)
}, },
WatchFunc: func(options api.ListOptions) (watch.Interface, error) { WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return f.client.Storage().StorageClasses().Watch(options) return f.client.Storage().StorageClasses().Watch(options)
}, },
}, },
......
...@@ -23,14 +23,14 @@ import ( ...@@ -23,14 +23,14 @@ import (
"sync" "sync"
"time" "time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors" "k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apis/batch" "k8s.io/kubernetes/pkg/api/v1"
batch "k8s.io/kubernetes/pkg/apis/batch/v1"
"k8s.io/kubernetes/pkg/client/cache" "k8s.io/kubernetes/pkg/client/cache"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" clientset "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5"
unversionedcore "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion" v1core "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5/typed/core/v1"
batchinternallisters "k8s.io/kubernetes/pkg/client/listers/batch/internalversion" batchv1listers "k8s.io/kubernetes/pkg/client/listers/batch/v1"
"k8s.io/kubernetes/pkg/client/record" "k8s.io/kubernetes/pkg/client/record"
"k8s.io/kubernetes/pkg/controller" "k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/pkg/controller/informers" "k8s.io/kubernetes/pkg/controller/informers"
...@@ -60,7 +60,7 @@ type JobController struct { ...@@ -60,7 +60,7 @@ type JobController struct {
expectations controller.ControllerExpectationsInterface expectations controller.ControllerExpectationsInterface
// A store of jobs // A store of jobs
jobLister batchinternallisters.JobLister jobLister batchv1listers.JobLister
// A store of pods, populated by the podController // A store of pods, populated by the podController
podStore cache.StoreToPodLister podStore cache.StoreToPodLister
...@@ -75,7 +75,7 @@ func NewJobController(podInformer cache.SharedIndexInformer, jobInformer informe ...@@ -75,7 +75,7 @@ func NewJobController(podInformer cache.SharedIndexInformer, jobInformer informe
eventBroadcaster := record.NewBroadcaster() eventBroadcaster := record.NewBroadcaster()
eventBroadcaster.StartLogging(glog.Infof) eventBroadcaster.StartLogging(glog.Infof)
// TODO: remove the wrapper when every clients have moved to use the clientset. // TODO: remove the wrapper when every clients have moved to use the clientset.
eventBroadcaster.StartRecordingToSink(&unversionedcore.EventSinkImpl{Interface: kubeClient.Core().Events("")}) eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: kubeClient.Core().Events("")})
if kubeClient != nil && kubeClient.Core().RESTClient().GetRateLimiter() != nil { if kubeClient != nil && kubeClient.Core().RESTClient().GetRateLimiter() != nil {
metrics.RegisterMetricAndTrackRateLimiterUsage("job_controller", kubeClient.Core().RESTClient().GetRateLimiter()) metrics.RegisterMetricAndTrackRateLimiterUsage("job_controller", kubeClient.Core().RESTClient().GetRateLimiter())
...@@ -85,11 +85,11 @@ func NewJobController(podInformer cache.SharedIndexInformer, jobInformer informe ...@@ -85,11 +85,11 @@ func NewJobController(podInformer cache.SharedIndexInformer, jobInformer informe
kubeClient: kubeClient, kubeClient: kubeClient,
podControl: controller.RealPodControl{ podControl: controller.RealPodControl{
KubeClient: kubeClient, KubeClient: kubeClient,
Recorder: eventBroadcaster.NewRecorder(api.EventSource{Component: "job-controller"}), Recorder: eventBroadcaster.NewRecorder(v1.EventSource{Component: "job-controller"}),
}, },
expectations: controller.NewControllerExpectations(), expectations: controller.NewControllerExpectations(),
queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "job"), queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "job"),
recorder: eventBroadcaster.NewRecorder(api.EventSource{Component: "job-controller"}), recorder: eventBroadcaster.NewRecorder(v1.EventSource{Component: "job-controller"}),
} }
jobInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ jobInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
...@@ -135,7 +135,7 @@ func (jm *JobController) Run(workers int, stopCh <-chan struct{}) { ...@@ -135,7 +135,7 @@ func (jm *JobController) Run(workers int, stopCh <-chan struct{}) {
} }
// getPodJob returns the job managing the given pod. // getPodJob returns the job managing the given pod.
func (jm *JobController) getPodJob(pod *api.Pod) *batch.Job { func (jm *JobController) getPodJob(pod *v1.Pod) *batch.Job {
jobs, err := jm.jobLister.GetPodJobs(pod) jobs, err := jm.jobLister.GetPodJobs(pod)
if err != nil { if err != nil {
glog.V(4).Infof("No jobs found for pod %v, job controller will avoid syncing", pod.Name) glog.V(4).Infof("No jobs found for pod %v, job controller will avoid syncing", pod.Name)
...@@ -150,7 +150,7 @@ func (jm *JobController) getPodJob(pod *api.Pod) *batch.Job { ...@@ -150,7 +150,7 @@ func (jm *JobController) getPodJob(pod *api.Pod) *batch.Job {
// When a pod is created, enqueue the controller that manages it and update it's expectations. // When a pod is created, enqueue the controller that manages it and update it's expectations.
func (jm *JobController) addPod(obj interface{}) { func (jm *JobController) addPod(obj interface{}) {
pod := obj.(*api.Pod) pod := obj.(*v1.Pod)
if pod.DeletionTimestamp != nil { if pod.DeletionTimestamp != nil {
// on a restart of the controller controller, it's possible a new pod shows up in a state that // on a restart of the controller controller, it's possible a new pod shows up in a state that
// is already pending deletion. Prevent the pod from being a creation observation. // is already pending deletion. Prevent the pod from being a creation observation.
...@@ -170,10 +170,10 @@ func (jm *JobController) addPod(obj interface{}) { ...@@ -170,10 +170,10 @@ func (jm *JobController) addPod(obj interface{}) {
// When a pod is updated, figure out what job/s manage it and wake them up. // When a pod is updated, figure out what job/s manage it and wake them up.
// If the labels of the pod have changed we need to awaken both the old // If the labels of the pod have changed we need to awaken both the old
// and new job. old and cur must be *api.Pod types. // and new job. old and cur must be *v1.Pod types.
func (jm *JobController) updatePod(old, cur interface{}) { func (jm *JobController) updatePod(old, cur interface{}) {
curPod := cur.(*api.Pod) curPod := cur.(*v1.Pod)
oldPod := old.(*api.Pod) oldPod := old.(*v1.Pod)
if curPod.ResourceVersion == oldPod.ResourceVersion { if curPod.ResourceVersion == oldPod.ResourceVersion {
// Periodic resync will send update events for all known pods. // Periodic resync will send update events for all known pods.
// Two different versions of the same pod will always have different RVs. // Two different versions of the same pod will always have different RVs.
...@@ -201,9 +201,9 @@ func (jm *JobController) updatePod(old, cur interface{}) { ...@@ -201,9 +201,9 @@ func (jm *JobController) updatePod(old, cur interface{}) {
} }
// When a pod is deleted, enqueue the job that manages the pod and update its expectations. // When a pod is deleted, enqueue the job that manages the pod and update its expectations.
// obj could be an *api.Pod, or a DeletionFinalStateUnknown marker item. // obj could be an *v1.Pod, or a DeletionFinalStateUnknown marker item.
func (jm *JobController) deletePod(obj interface{}) { func (jm *JobController) deletePod(obj interface{}) {
pod, ok := obj.(*api.Pod) pod, ok := obj.(*v1.Pod)
// When a delete is dropped, the relist will notice a pod in the store not // When a delete is dropped, the relist will notice a pod in the store not
// in the list, leading to the insertion of a tombstone object which contains // in the list, leading to the insertion of a tombstone object which contains
...@@ -215,7 +215,7 @@ func (jm *JobController) deletePod(obj interface{}) { ...@@ -215,7 +215,7 @@ func (jm *JobController) deletePod(obj interface{}) {
utilruntime.HandleError(fmt.Errorf("Couldn't get object from tombstone %+v", obj)) utilruntime.HandleError(fmt.Errorf("Couldn't get object from tombstone %+v", obj))
return return
} }
pod, ok = tombstone.Obj.(*api.Pod) pod, ok = tombstone.Obj.(*v1.Pod)
if !ok { if !ok {
utilruntime.HandleError(fmt.Errorf("Tombstone contained object that is not a pod %+v", obj)) utilruntime.HandleError(fmt.Errorf("Tombstone contained object that is not a pod %+v", obj))
return return
...@@ -346,7 +346,7 @@ func (jm *JobController) syncJob(key string) error { ...@@ -346,7 +346,7 @@ func (jm *JobController) syncJob(key string) error {
failed += active failed += active
active = 0 active = 0
job.Status.Conditions = append(job.Status.Conditions, newCondition(batch.JobFailed, "DeadlineExceeded", "Job was active longer than specified deadline")) job.Status.Conditions = append(job.Status.Conditions, newCondition(batch.JobFailed, "DeadlineExceeded", "Job was active longer than specified deadline"))
jm.recorder.Event(&job, api.EventTypeNormal, "DeadlineExceeded", "Job was active longer than specified deadline") jm.recorder.Event(&job, v1.EventTypeNormal, "DeadlineExceeded", "Job was active longer than specified deadline")
} else { } else {
if jobNeedsSync && job.DeletionTimestamp == nil { if jobNeedsSync && job.DeletionTimestamp == nil {
active = jm.manageJob(activePods, succeeded, &job) active = jm.manageJob(activePods, succeeded, &job)
...@@ -371,10 +371,10 @@ func (jm *JobController) syncJob(key string) error { ...@@ -371,10 +371,10 @@ func (jm *JobController) syncJob(key string) error {
if completions >= *job.Spec.Completions { if completions >= *job.Spec.Completions {
complete = true complete = true
if active > 0 { if active > 0 {
jm.recorder.Event(&job, api.EventTypeWarning, "TooManyActivePods", "Too many active pods running after completion count reached") jm.recorder.Event(&job, v1.EventTypeWarning, "TooManyActivePods", "Too many active pods running after completion count reached")
} }
if completions > *job.Spec.Completions { if completions > *job.Spec.Completions {
jm.recorder.Event(&job, api.EventTypeWarning, "TooManySucceededPods", "Too many succeeded pods running after completion count reached") jm.recorder.Event(&job, v1.EventTypeWarning, "TooManySucceededPods", "Too many succeeded pods running after completion count reached")
} }
} }
} }
...@@ -413,7 +413,7 @@ func pastActiveDeadline(job *batch.Job) bool { ...@@ -413,7 +413,7 @@ func pastActiveDeadline(job *batch.Job) bool {
func newCondition(conditionType batch.JobConditionType, reason, message string) batch.JobCondition { func newCondition(conditionType batch.JobConditionType, reason, message string) batch.JobCondition {
return batch.JobCondition{ return batch.JobCondition{
Type: conditionType, Type: conditionType,
Status: api.ConditionTrue, Status: v1.ConditionTrue,
LastProbeTime: unversioned.Now(), LastProbeTime: unversioned.Now(),
LastTransitionTime: unversioned.Now(), LastTransitionTime: unversioned.Now(),
Reason: reason, Reason: reason,
...@@ -422,16 +422,16 @@ func newCondition(conditionType batch.JobConditionType, reason, message string) ...@@ -422,16 +422,16 @@ func newCondition(conditionType batch.JobConditionType, reason, message string)
} }
// getStatus returns no of succeeded and failed pods running a job // getStatus returns no of succeeded and failed pods running a job
func getStatus(pods []*api.Pod) (succeeded, failed int32) { func getStatus(pods []*v1.Pod) (succeeded, failed int32) {
succeeded = int32(filterPods(pods, api.PodSucceeded)) succeeded = int32(filterPods(pods, v1.PodSucceeded))
failed = int32(filterPods(pods, api.PodFailed)) failed = int32(filterPods(pods, v1.PodFailed))
return return
} }
// manageJob is the core method responsible for managing the number of running // manageJob is the core method responsible for managing the number of running
// pods according to what is specified in the job.Spec. // pods according to what is specified in the job.Spec.
// Does NOT modify <activePods>. // Does NOT modify <activePods>.
func (jm *JobController) manageJob(activePods []*api.Pod, succeeded int32, job *batch.Job) int32 { func (jm *JobController) manageJob(activePods []*v1.Pod, succeeded int32, job *batch.Job) int32 {
var activeLock sync.Mutex var activeLock sync.Mutex
active := int32(len(activePods)) active := int32(len(activePods))
parallelism := *job.Spec.Parallelism parallelism := *job.Spec.Parallelism
...@@ -523,7 +523,7 @@ func (jm *JobController) updateJobStatus(job *batch.Job) error { ...@@ -523,7 +523,7 @@ func (jm *JobController) updateJobStatus(job *batch.Job) error {
} }
// filterPods returns pods based on their phase. // filterPods returns pods based on their phase.
func filterPods(pods []*api.Pod, phase api.PodPhase) int { func filterPods(pods []*v1.Pod, phase v1.PodPhase) int {
result := 0 result := 0
for i := range pods { for i := range pods {
if phase == pods[i].Status.Phase { if phase == pods[i].Status.Phase {
......
...@@ -17,13 +17,13 @@ limitations under the License. ...@@ -17,13 +17,13 @@ limitations under the License.
package job package job
import ( import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apis/batch" batch "k8s.io/kubernetes/pkg/apis/batch/v1"
) )
func IsJobFinished(j *batch.Job) bool { func IsJobFinished(j *batch.Job) bool {
for _, c := range j.Status.Conditions { for _, c := range j.Status.Conditions {
if (c.Type == batch.JobComplete || c.Type == batch.JobFailed) && c.Status == api.ConditionTrue { if (c.Type == batch.JobComplete || c.Type == batch.JobFailed) && c.Status == v1.ConditionTrue {
return true return true
} }
} }
......
...@@ -19,8 +19,8 @@ package job ...@@ -19,8 +19,8 @@ package job
import ( import (
"testing" "testing"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apis/batch" batch "k8s.io/kubernetes/pkg/apis/batch/v1"
) )
func TestIsJobFinished(t *testing.T) { func TestIsJobFinished(t *testing.T) {
...@@ -28,7 +28,7 @@ func TestIsJobFinished(t *testing.T) { ...@@ -28,7 +28,7 @@ func TestIsJobFinished(t *testing.T) {
Status: batch.JobStatus{ Status: batch.JobStatus{
Conditions: []batch.JobCondition{{ Conditions: []batch.JobCondition{{
Type: batch.JobComplete, Type: batch.JobComplete,
Status: api.ConditionTrue, Status: v1.ConditionTrue,
}}, }},
}, },
} }
...@@ -37,12 +37,12 @@ func TestIsJobFinished(t *testing.T) { ...@@ -37,12 +37,12 @@ func TestIsJobFinished(t *testing.T) {
t.Error("Job was expected to be finished") t.Error("Job was expected to be finished")
} }
job.Status.Conditions[0].Status = api.ConditionFalse job.Status.Conditions[0].Status = v1.ConditionFalse
if IsJobFinished(job) { if IsJobFinished(job) {
t.Error("Job was not expected to be finished") t.Error("Job was not expected to be finished")
} }
job.Status.Conditions[0].Status = api.ConditionUnknown job.Status.Conditions[0].Status = v1.ConditionUnknown
if IsJobFinished(job) { if IsJobFinished(job) {
t.Error("Job was not expected to be finished") t.Error("Job was not expected to be finished")
} }
......
...@@ -19,10 +19,10 @@ package namespace ...@@ -19,10 +19,10 @@ package namespace
import ( import (
"time" "time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/client/cache" "k8s.io/kubernetes/pkg/client/cache"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" clientset "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5"
"k8s.io/kubernetes/pkg/client/typed/dynamic" "k8s.io/kubernetes/pkg/client/typed/dynamic"
"k8s.io/kubernetes/pkg/controller" "k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/runtime"
...@@ -52,7 +52,7 @@ type NamespaceController struct { ...@@ -52,7 +52,7 @@ type NamespaceController struct {
// opCache is a cache to remember if a particular operation is not supported to aid dynamic client. // opCache is a cache to remember if a particular operation is not supported to aid dynamic client.
opCache *operationNotSupportedCache opCache *operationNotSupportedCache
// finalizerToken is the finalizer token managed by this controller // finalizerToken is the finalizer token managed by this controller
finalizerToken api.FinalizerName finalizerToken v1.FinalizerName
} }
// NewNamespaceController creates a new NamespaceController // NewNamespaceController creates a new NamespaceController
...@@ -61,7 +61,7 @@ func NewNamespaceController( ...@@ -61,7 +61,7 @@ func NewNamespaceController(
clientPool dynamic.ClientPool, clientPool dynamic.ClientPool,
groupVersionResourcesFn func() ([]unversioned.GroupVersionResource, error), groupVersionResourcesFn func() ([]unversioned.GroupVersionResource, error),
resyncPeriod time.Duration, resyncPeriod time.Duration,
finalizerToken api.FinalizerName) *NamespaceController { finalizerToken v1.FinalizerName) *NamespaceController {
// the namespace deletion code looks at the discovery document to enumerate the set of resources on the server. // the namespace deletion code looks at the discovery document to enumerate the set of resources on the server.
// it then finds all namespaced resources, and in response to namespace deletion, will call delete on all of them. // it then finds all namespaced resources, and in response to namespace deletion, will call delete on all of them.
...@@ -98,22 +98,22 @@ func NewNamespaceController( ...@@ -98,22 +98,22 @@ func NewNamespaceController(
// configure the backing store/controller // configure the backing store/controller
store, controller := cache.NewInformer( store, controller := cache.NewInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options api.ListOptions) (runtime.Object, error) { ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return kubeClient.Core().Namespaces().List(options) return kubeClient.Core().Namespaces().List(options)
}, },
WatchFunc: func(options api.ListOptions) (watch.Interface, error) { WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return kubeClient.Core().Namespaces().Watch(options) return kubeClient.Core().Namespaces().Watch(options)
}, },
}, },
&api.Namespace{}, &v1.Namespace{},
resyncPeriod, resyncPeriod,
cache.ResourceEventHandlerFuncs{ cache.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}) { AddFunc: func(obj interface{}) {
namespace := obj.(*api.Namespace) namespace := obj.(*v1.Namespace)
namespaceController.enqueueNamespace(namespace) namespaceController.enqueueNamespace(namespace)
}, },
UpdateFunc: func(oldObj, newObj interface{}) { UpdateFunc: func(oldObj, newObj interface{}) {
namespace := newObj.(*api.Namespace) namespace := newObj.(*v1.Namespace)
namespaceController.enqueueNamespace(namespace) namespaceController.enqueueNamespace(namespace)
}, },
}, },
...@@ -125,7 +125,7 @@ func NewNamespaceController( ...@@ -125,7 +125,7 @@ func NewNamespaceController(
} }
// enqueueNamespace adds an object to the controller work queue // enqueueNamespace adds an object to the controller work queue
// obj could be an *api.Namespace, or a DeletionFinalStateUnknown item. // obj could be an *v1.Namespace, or a DeletionFinalStateUnknown item.
func (nm *NamespaceController) enqueueNamespace(obj interface{}) { func (nm *NamespaceController) enqueueNamespace(obj interface{}) {
key, err := controller.KeyFunc(obj) key, err := controller.KeyFunc(obj)
if err != nil { if err != nil {
...@@ -190,7 +190,7 @@ func (nm *NamespaceController) syncNamespaceFromKey(key string) (err error) { ...@@ -190,7 +190,7 @@ func (nm *NamespaceController) syncNamespaceFromKey(key string) (err error) {
nm.queue.Add(key) nm.queue.Add(key)
return err return err
} }
namespace := obj.(*api.Namespace) namespace := obj.(*v1.Namespace)
return syncNamespace(nm.kubeClient, nm.clientPool, nm.opCache, nm.groupVersionResourcesFn, namespace, nm.finalizerToken) return syncNamespace(nm.kubeClient, nm.clientPool, nm.opCache, nm.groupVersionResourcesFn, namespace, nm.finalizerToken)
} }
......
...@@ -28,9 +28,10 @@ import ( ...@@ -28,9 +28,10 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors" "k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apimachinery/registered" "k8s.io/kubernetes/pkg/apimachinery/registered"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" clientset "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake" "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5/fake"
"k8s.io/kubernetes/pkg/client/restclient" "k8s.io/kubernetes/pkg/client/restclient"
"k8s.io/kubernetes/pkg/client/testing/core" "k8s.io/kubernetes/pkg/client/testing/core"
"k8s.io/kubernetes/pkg/client/typed/dynamic" "k8s.io/kubernetes/pkg/client/typed/dynamic"
...@@ -39,15 +40,15 @@ import ( ...@@ -39,15 +40,15 @@ import (
) )
func TestFinalized(t *testing.T) { func TestFinalized(t *testing.T) {
testNamespace := &api.Namespace{ testNamespace := &v1.Namespace{
Spec: api.NamespaceSpec{ Spec: v1.NamespaceSpec{
Finalizers: []api.FinalizerName{"a", "b"}, Finalizers: []v1.FinalizerName{"a", "b"},
}, },
} }
if finalized(testNamespace) { if finalized(testNamespace) {
t.Errorf("Unexpected result, namespace is not finalized") t.Errorf("Unexpected result, namespace is not finalized")
} }
testNamespace.Spec.Finalizers = []api.FinalizerName{} testNamespace.Spec.Finalizers = []v1.FinalizerName{}
if !finalized(testNamespace) { if !finalized(testNamespace) {
t.Errorf("Expected object to be finalized") t.Errorf("Expected object to be finalized")
} }
...@@ -55,16 +56,16 @@ func TestFinalized(t *testing.T) { ...@@ -55,16 +56,16 @@ func TestFinalized(t *testing.T) {
func TestFinalizeNamespaceFunc(t *testing.T) { func TestFinalizeNamespaceFunc(t *testing.T) {
mockClient := &fake.Clientset{} mockClient := &fake.Clientset{}
testNamespace := &api.Namespace{ testNamespace := &v1.Namespace{
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Name: "test", Name: "test",
ResourceVersion: "1", ResourceVersion: "1",
}, },
Spec: api.NamespaceSpec{ Spec: v1.NamespaceSpec{
Finalizers: []api.FinalizerName{"kubernetes", "other"}, Finalizers: []v1.FinalizerName{"kubernetes", "other"},
}, },
} }
finalizeNamespace(mockClient, testNamespace, api.FinalizerKubernetes) finalizeNamespace(mockClient, testNamespace, v1.FinalizerKubernetes)
actions := mockClient.Actions() actions := mockClient.Actions()
if len(actions) != 1 { if len(actions) != 1 {
t.Errorf("Expected 1 mock client action, but got %v", len(actions)) t.Errorf("Expected 1 mock client action, but got %v", len(actions))
...@@ -72,7 +73,7 @@ func TestFinalizeNamespaceFunc(t *testing.T) { ...@@ -72,7 +73,7 @@ func TestFinalizeNamespaceFunc(t *testing.T) {
if !actions[0].Matches("create", "namespaces") || actions[0].GetSubresource() != "finalize" { if !actions[0].Matches("create", "namespaces") || actions[0].GetSubresource() != "finalize" {
t.Errorf("Expected finalize-namespace action %v", actions[0]) t.Errorf("Expected finalize-namespace action %v", actions[0])
} }
finalizers := actions[0].(core.CreateAction).GetObject().(*api.Namespace).Spec.Finalizers finalizers := actions[0].(core.CreateAction).GetObject().(*v1.Namespace).Spec.Finalizers
if len(finalizers) != 1 { if len(finalizers) != 1 {
t.Errorf("There should be a single finalizer remaining") t.Errorf("There should be a single finalizer remaining")
} }
...@@ -84,28 +85,28 @@ func TestFinalizeNamespaceFunc(t *testing.T) { ...@@ -84,28 +85,28 @@ func TestFinalizeNamespaceFunc(t *testing.T) {
func testSyncNamespaceThatIsTerminating(t *testing.T, versions *unversioned.APIVersions) { func testSyncNamespaceThatIsTerminating(t *testing.T, versions *unversioned.APIVersions) {
now := unversioned.Now() now := unversioned.Now()
namespaceName := "test" namespaceName := "test"
testNamespacePendingFinalize := &api.Namespace{ testNamespacePendingFinalize := &v1.Namespace{
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Name: namespaceName, Name: namespaceName,
ResourceVersion: "1", ResourceVersion: "1",
DeletionTimestamp: &now, DeletionTimestamp: &now,
}, },
Spec: api.NamespaceSpec{ Spec: v1.NamespaceSpec{
Finalizers: []api.FinalizerName{"kubernetes"}, Finalizers: []v1.FinalizerName{"kubernetes"},
}, },
Status: api.NamespaceStatus{ Status: v1.NamespaceStatus{
Phase: api.NamespaceTerminating, Phase: v1.NamespaceTerminating,
}, },
} }
testNamespaceFinalizeComplete := &api.Namespace{ testNamespaceFinalizeComplete := &v1.Namespace{
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Name: namespaceName, Name: namespaceName,
ResourceVersion: "1", ResourceVersion: "1",
DeletionTimestamp: &now, DeletionTimestamp: &now,
}, },
Spec: api.NamespaceSpec{}, Spec: v1.NamespaceSpec{},
Status: api.NamespaceStatus{ Status: v1.NamespaceStatus{
Phase: api.NamespaceTerminating, Phase: v1.NamespaceTerminating,
}, },
} }
...@@ -126,7 +127,7 @@ func testSyncNamespaceThatIsTerminating(t *testing.T, versions *unversioned.APIV ...@@ -126,7 +127,7 @@ func testSyncNamespaceThatIsTerminating(t *testing.T, versions *unversioned.APIV
} }
scenarios := map[string]struct { scenarios := map[string]struct {
testNamespace *api.Namespace testNamespace *v1.Namespace
kubeClientActionSet sets.String kubeClientActionSet sets.String
dynamicClientActionSet sets.String dynamicClientActionSet sets.String
gvrError error gvrError error
...@@ -172,7 +173,7 @@ func testSyncNamespaceThatIsTerminating(t *testing.T, versions *unversioned.APIV ...@@ -172,7 +173,7 @@ func testSyncNamespaceThatIsTerminating(t *testing.T, versions *unversioned.APIV
return groupVersionResources, nil return groupVersionResources, nil
} }
err := syncNamespace(mockClient, clientPool, &operationNotSupportedCache{m: make(map[operationKey]bool)}, fn, testInput.testNamespace, api.FinalizerKubernetes) err := syncNamespace(mockClient, clientPool, &operationNotSupportedCache{m: make(map[operationKey]bool)}, fn, testInput.testNamespace, v1.FinalizerKubernetes)
if err != nil { if err != nil {
t.Errorf("scenario %s - Unexpected error when synching namespace %v", scenario, err) t.Errorf("scenario %s - Unexpected error when synching namespace %v", scenario, err)
} }
...@@ -202,14 +203,14 @@ func testSyncNamespaceThatIsTerminating(t *testing.T, versions *unversioned.APIV ...@@ -202,14 +203,14 @@ func testSyncNamespaceThatIsTerminating(t *testing.T, versions *unversioned.APIV
func TestRetryOnConflictError(t *testing.T) { func TestRetryOnConflictError(t *testing.T) {
mockClient := &fake.Clientset{} mockClient := &fake.Clientset{}
numTries := 0 numTries := 0
retryOnce := func(kubeClient clientset.Interface, namespace *api.Namespace) (*api.Namespace, error) { retryOnce := func(kubeClient clientset.Interface, namespace *v1.Namespace) (*v1.Namespace, error) {
numTries++ numTries++
if numTries <= 1 { if numTries <= 1 {
return namespace, errors.NewConflict(api.Resource("namespaces"), namespace.Name, fmt.Errorf("ERROR!")) return namespace, errors.NewConflict(api.Resource("namespaces"), namespace.Name, fmt.Errorf("ERROR!"))
} }
return namespace, nil return namespace, nil
} }
namespace := &api.Namespace{} namespace := &v1.Namespace{}
_, err := retryOnConflictError(mockClient, namespace, retryOnce) _, err := retryOnConflictError(mockClient, namespace, retryOnce)
if err != nil { if err != nil {
t.Errorf("Unexpected error %v", err) t.Errorf("Unexpected error %v", err)
...@@ -229,22 +230,22 @@ func TestSyncNamespaceThatIsTerminatingV1Beta1(t *testing.T) { ...@@ -229,22 +230,22 @@ func TestSyncNamespaceThatIsTerminatingV1Beta1(t *testing.T) {
func TestSyncNamespaceThatIsActive(t *testing.T) { func TestSyncNamespaceThatIsActive(t *testing.T) {
mockClient := &fake.Clientset{} mockClient := &fake.Clientset{}
testNamespace := &api.Namespace{ testNamespace := &v1.Namespace{
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Name: "test", Name: "test",
ResourceVersion: "1", ResourceVersion: "1",
}, },
Spec: api.NamespaceSpec{ Spec: v1.NamespaceSpec{
Finalizers: []api.FinalizerName{"kubernetes"}, Finalizers: []v1.FinalizerName{"kubernetes"},
}, },
Status: api.NamespaceStatus{ Status: v1.NamespaceStatus{
Phase: api.NamespaceActive, Phase: v1.NamespaceActive,
}, },
} }
fn := func() ([]unversioned.GroupVersionResource, error) { fn := func() ([]unversioned.GroupVersionResource, error) {
return testGroupVersionResources(), nil return testGroupVersionResources(), nil
} }
err := syncNamespace(mockClient, nil, &operationNotSupportedCache{m: make(map[operationKey]bool)}, fn, testNamespace, api.FinalizerKubernetes) err := syncNamespace(mockClient, nil, &operationNotSupportedCache{m: make(map[operationKey]bool)}, fn, testNamespace, v1.FinalizerKubernetes)
if err != nil { if err != nil {
t.Errorf("Unexpected error when synching namespace %v", err) t.Errorf("Unexpected error when synching namespace %v", err)
} }
......
...@@ -22,11 +22,10 @@ import ( ...@@ -22,11 +22,10 @@ import (
"sync" "sync"
"time" "time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors" "k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/v1" "k8s.io/kubernetes/pkg/api/v1"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" clientset "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5"
"k8s.io/kubernetes/pkg/client/typed/dynamic" "k8s.io/kubernetes/pkg/client/typed/dynamic"
"k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util/sets" "k8s.io/kubernetes/pkg/util/sets"
...@@ -80,12 +79,12 @@ func (o *operationNotSupportedCache) setNotSupported(key operationKey) { ...@@ -80,12 +79,12 @@ func (o *operationNotSupportedCache) setNotSupported(key operationKey) {
} }
// updateNamespaceFunc is a function that makes an update to a namespace // updateNamespaceFunc is a function that makes an update to a namespace
type updateNamespaceFunc func(kubeClient clientset.Interface, namespace *api.Namespace) (*api.Namespace, error) type updateNamespaceFunc func(kubeClient clientset.Interface, namespace *v1.Namespace) (*v1.Namespace, error)
// retryOnConflictError retries the specified fn if there was a conflict error // retryOnConflictError retries the specified fn if there was a conflict error
// it will return an error if the UID for an object changes across retry operations. // it will return an error if the UID for an object changes across retry operations.
// TODO RetryOnConflict should be a generic concept in client code // TODO RetryOnConflict should be a generic concept in client code
func retryOnConflictError(kubeClient clientset.Interface, namespace *api.Namespace, fn updateNamespaceFunc) (result *api.Namespace, err error) { func retryOnConflictError(kubeClient clientset.Interface, namespace *v1.Namespace, fn updateNamespaceFunc) (result *v1.Namespace, err error) {
latestNamespace := namespace latestNamespace := namespace
for { for {
result, err = fn(kubeClient, latestNamespace) result, err = fn(kubeClient, latestNamespace)
...@@ -107,32 +106,32 @@ func retryOnConflictError(kubeClient clientset.Interface, namespace *api.Namespa ...@@ -107,32 +106,32 @@ func retryOnConflictError(kubeClient clientset.Interface, namespace *api.Namespa
} }
// updateNamespaceStatusFunc will verify that the status of the namespace is correct // updateNamespaceStatusFunc will verify that the status of the namespace is correct
func updateNamespaceStatusFunc(kubeClient clientset.Interface, namespace *api.Namespace) (*api.Namespace, error) { func updateNamespaceStatusFunc(kubeClient clientset.Interface, namespace *v1.Namespace) (*v1.Namespace, error) {
if namespace.DeletionTimestamp.IsZero() || namespace.Status.Phase == api.NamespaceTerminating { if namespace.DeletionTimestamp.IsZero() || namespace.Status.Phase == v1.NamespaceTerminating {
return namespace, nil return namespace, nil
} }
newNamespace := api.Namespace{} newNamespace := v1.Namespace{}
newNamespace.ObjectMeta = namespace.ObjectMeta newNamespace.ObjectMeta = namespace.ObjectMeta
newNamespace.Status = namespace.Status newNamespace.Status = namespace.Status
newNamespace.Status.Phase = api.NamespaceTerminating newNamespace.Status.Phase = v1.NamespaceTerminating
return kubeClient.Core().Namespaces().UpdateStatus(&newNamespace) return kubeClient.Core().Namespaces().UpdateStatus(&newNamespace)
} }
// finalized returns true if the namespace.Spec.Finalizers is an empty list // finalized returns true if the namespace.Spec.Finalizers is an empty list
func finalized(namespace *api.Namespace) bool { func finalized(namespace *v1.Namespace) bool {
return len(namespace.Spec.Finalizers) == 0 return len(namespace.Spec.Finalizers) == 0
} }
// finalizeNamespaceFunc returns a function that knows how to finalize a namespace for specified token. // finalizeNamespaceFunc returns a function that knows how to finalize a namespace for specified token.
func finalizeNamespaceFunc(finalizerToken api.FinalizerName) updateNamespaceFunc { func finalizeNamespaceFunc(finalizerToken v1.FinalizerName) updateNamespaceFunc {
return func(kubeClient clientset.Interface, namespace *api.Namespace) (*api.Namespace, error) { return func(kubeClient clientset.Interface, namespace *v1.Namespace) (*v1.Namespace, error) {
return finalizeNamespace(kubeClient, namespace, finalizerToken) return finalizeNamespace(kubeClient, namespace, finalizerToken)
} }
} }
// finalizeNamespace removes the specified finalizerToken and finalizes the namespace // finalizeNamespace removes the specified finalizerToken and finalizes the namespace
func finalizeNamespace(kubeClient clientset.Interface, namespace *api.Namespace, finalizerToken api.FinalizerName) (*api.Namespace, error) { func finalizeNamespace(kubeClient clientset.Interface, namespace *v1.Namespace, finalizerToken v1.FinalizerName) (*v1.Namespace, error) {
namespaceFinalize := api.Namespace{} namespaceFinalize := v1.Namespace{}
namespaceFinalize.ObjectMeta = namespace.ObjectMeta namespaceFinalize.ObjectMeta = namespace.ObjectMeta
namespaceFinalize.Spec = namespace.Spec namespaceFinalize.Spec = namespace.Spec
finalizerSet := sets.NewString() finalizerSet := sets.NewString()
...@@ -141,9 +140,9 @@ func finalizeNamespace(kubeClient clientset.Interface, namespace *api.Namespace, ...@@ -141,9 +140,9 @@ func finalizeNamespace(kubeClient clientset.Interface, namespace *api.Namespace,
finalizerSet.Insert(string(namespace.Spec.Finalizers[i])) finalizerSet.Insert(string(namespace.Spec.Finalizers[i]))
} }
} }
namespaceFinalize.Spec.Finalizers = make([]api.FinalizerName, 0, len(finalizerSet)) namespaceFinalize.Spec.Finalizers = make([]v1.FinalizerName, 0, len(finalizerSet))
for _, value := range finalizerSet.List() { for _, value := range finalizerSet.List() {
namespaceFinalize.Spec.Finalizers = append(namespaceFinalize.Spec.Finalizers, api.FinalizerName(value)) namespaceFinalize.Spec.Finalizers = append(namespaceFinalize.Spec.Finalizers, v1.FinalizerName(value))
} }
namespace, err := kubeClient.Core().Namespaces().Finalize(&namespaceFinalize) namespace, err := kubeClient.Core().Namespaces().Finalize(&namespaceFinalize)
if err != nil { if err != nil {
...@@ -372,8 +371,8 @@ func syncNamespace( ...@@ -372,8 +371,8 @@ func syncNamespace(
clientPool dynamic.ClientPool, clientPool dynamic.ClientPool,
opCache *operationNotSupportedCache, opCache *operationNotSupportedCache,
groupVersionResourcesFn func() ([]unversioned.GroupVersionResource, error), groupVersionResourcesFn func() ([]unversioned.GroupVersionResource, error),
namespace *api.Namespace, namespace *v1.Namespace,
finalizerToken api.FinalizerName, finalizerToken v1.FinalizerName,
) error { ) error {
if namespace.DeletionTimestamp == nil { if namespace.DeletionTimestamp == nil {
return nil return nil
...@@ -409,10 +408,10 @@ func syncNamespace( ...@@ -409,10 +408,10 @@ func syncNamespace(
// if the namespace is already finalized, delete it // if the namespace is already finalized, delete it
if finalized(namespace) { if finalized(namespace) {
var opts *api.DeleteOptions var opts *v1.DeleteOptions
uid := namespace.UID uid := namespace.UID
if len(uid) > 0 { if len(uid) > 0 {
opts = &api.DeleteOptions{Preconditions: &api.Preconditions{UID: &uid}} opts = &v1.DeleteOptions{Preconditions: &v1.Preconditions{UID: &uid}}
} }
err = kubeClient.Core().Namespaces().Delete(namespace.Name, opts) err = kubeClient.Core().Namespaces().Delete(namespace.Name, opts)
if err != nil && !errors.IsNotFound(err) { if err != nil && !errors.IsNotFound(err) {
...@@ -483,14 +482,14 @@ func estimateGracefulTermination(kubeClient clientset.Interface, groupVersionRes ...@@ -483,14 +482,14 @@ func estimateGracefulTermination(kubeClient clientset.Interface, groupVersionRes
func estimateGracefulTerminationForPods(kubeClient clientset.Interface, ns string) (int64, error) { func estimateGracefulTerminationForPods(kubeClient clientset.Interface, ns string) (int64, error) {
glog.V(5).Infof("namespace controller - estimateGracefulTerminationForPods - namespace %s", ns) glog.V(5).Infof("namespace controller - estimateGracefulTerminationForPods - namespace %s", ns)
estimate := int64(0) estimate := int64(0)
items, err := kubeClient.Core().Pods(ns).List(api.ListOptions{}) items, err := kubeClient.Core().Pods(ns).List(v1.ListOptions{})
if err != nil { if err != nil {
return estimate, err return estimate, err
} }
for i := range items.Items { for i := range items.Items {
// filter out terminal pods // filter out terminal pods
phase := items.Items[i].Status.Phase phase := items.Items[i].Status.Phase
if api.PodSucceeded == phase || api.PodFailed == phase { if v1.PodSucceeded == phase || v1.PodFailed == phase {
continue continue
} }
if items.Items[i].Spec.TerminationGracePeriodSeconds != nil { if items.Items[i].Spec.TerminationGracePeriodSeconds != nil {
......
...@@ -22,9 +22,9 @@ import ( ...@@ -22,9 +22,9 @@ import (
"net" "net"
"sync" "sync"
"k8s.io/kubernetes/pkg/api"
apierrors "k8s.io/kubernetes/pkg/api/errors" apierrors "k8s.io/kubernetes/pkg/api/errors"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" "k8s.io/kubernetes/pkg/api/v1"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5"
"k8s.io/kubernetes/pkg/client/record" "k8s.io/kubernetes/pkg/client/record"
"k8s.io/kubernetes/pkg/util/sets" "k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/util/wait" "k8s.io/kubernetes/pkg/util/wait"
...@@ -50,8 +50,8 @@ type nodeAndCIDR struct { ...@@ -50,8 +50,8 @@ type nodeAndCIDR struct {
// CIDRAllocator is an interface implemented by things that know how to allocate/occupy/recycle CIDR for nodes. // CIDRAllocator is an interface implemented by things that know how to allocate/occupy/recycle CIDR for nodes.
type CIDRAllocator interface { type CIDRAllocator interface {
AllocateOrOccupyCIDR(node *api.Node) error AllocateOrOccupyCIDR(node *v1.Node) error
ReleaseCIDR(node *api.Node) error ReleaseCIDR(node *v1.Node) error
} }
type rangeAllocator struct { type rangeAllocator struct {
...@@ -72,9 +72,9 @@ type rangeAllocator struct { ...@@ -72,9 +72,9 @@ type rangeAllocator struct {
// Caller must ensure subNetMaskSize is not less than cluster CIDR mask size. // Caller must ensure subNetMaskSize is not less than cluster CIDR mask size.
// Caller must always pass in a list of existing nodes so the new allocator // Caller must always pass in a list of existing nodes so the new allocator
// can initialize its CIDR map. NodeList is only nil in testing. // can initialize its CIDR map. NodeList is only nil in testing.
func NewCIDRRangeAllocator(client clientset.Interface, clusterCIDR *net.IPNet, serviceCIDR *net.IPNet, subNetMaskSize int, nodeList *api.NodeList) (CIDRAllocator, error) { func NewCIDRRangeAllocator(client clientset.Interface, clusterCIDR *net.IPNet, serviceCIDR *net.IPNet, subNetMaskSize int, nodeList *v1.NodeList) (CIDRAllocator, error) {
eventBroadcaster := record.NewBroadcaster() eventBroadcaster := record.NewBroadcaster()
recorder := eventBroadcaster.NewRecorder(api.EventSource{Component: "cidrAllocator"}) recorder := eventBroadcaster.NewRecorder(v1.EventSource{Component: "cidrAllocator"})
eventBroadcaster.StartLogging(glog.Infof) eventBroadcaster.StartLogging(glog.Infof)
ra := &rangeAllocator{ ra := &rangeAllocator{
...@@ -145,7 +145,7 @@ func (r *rangeAllocator) removeNodeFromProcessing(nodeName string) { ...@@ -145,7 +145,7 @@ func (r *rangeAllocator) removeNodeFromProcessing(nodeName string) {
r.nodesInProcessing.Delete(nodeName) r.nodesInProcessing.Delete(nodeName)
} }
func (r *rangeAllocator) occupyCIDR(node *api.Node) error { func (r *rangeAllocator) occupyCIDR(node *v1.Node) error {
defer r.removeNodeFromProcessing(node.Name) defer r.removeNodeFromProcessing(node.Name)
if node.Spec.PodCIDR == "" { if node.Spec.PodCIDR == "" {
return nil return nil
...@@ -164,7 +164,7 @@ func (r *rangeAllocator) occupyCIDR(node *api.Node) error { ...@@ -164,7 +164,7 @@ func (r *rangeAllocator) occupyCIDR(node *api.Node) error {
// if it doesn't currently have one or mark the CIDR as used if the node already have one. // if it doesn't currently have one or mark the CIDR as used if the node already have one.
// WARNING: If you're adding any return calls or defer any more work from this function // WARNING: If you're adding any return calls or defer any more work from this function
// you have to handle correctly nodesInProcessing. // you have to handle correctly nodesInProcessing.
func (r *rangeAllocator) AllocateOrOccupyCIDR(node *api.Node) error { func (r *rangeAllocator) AllocateOrOccupyCIDR(node *v1.Node) error {
if node == nil { if node == nil {
return nil return nil
} }
...@@ -191,7 +191,7 @@ func (r *rangeAllocator) AllocateOrOccupyCIDR(node *api.Node) error { ...@@ -191,7 +191,7 @@ func (r *rangeAllocator) AllocateOrOccupyCIDR(node *api.Node) error {
} }
// ReleaseCIDR releases the CIDR of the removed node // ReleaseCIDR releases the CIDR of the removed node
func (r *rangeAllocator) ReleaseCIDR(node *api.Node) error { func (r *rangeAllocator) ReleaseCIDR(node *v1.Node) error {
if node == nil || node.Spec.PodCIDR == "" { if node == nil || node.Spec.PodCIDR == "" {
return nil return nil
} }
...@@ -225,7 +225,7 @@ func (r *rangeAllocator) filterOutServiceRange(serviceCIDR *net.IPNet) { ...@@ -225,7 +225,7 @@ func (r *rangeAllocator) filterOutServiceRange(serviceCIDR *net.IPNet) {
// Assigns CIDR to Node and sends an update to the API server. // Assigns CIDR to Node and sends an update to the API server.
func (r *rangeAllocator) updateCIDRAllocation(data nodeAndCIDR) error { func (r *rangeAllocator) updateCIDRAllocation(data nodeAndCIDR) error {
var err error var err error
var node *api.Node var node *v1.Node
defer r.removeNodeFromProcessing(data.nodeName) defer r.removeNodeFromProcessing(data.nodeName)
for rep := 0; rep < podCIDRUpdateRetry; rep++ { for rep := 0; rep < podCIDRUpdateRetry; rep++ {
// TODO: change it to using PATCH instead of full Node updates. // TODO: change it to using PATCH instead of full Node updates.
......
...@@ -21,8 +21,8 @@ import ( ...@@ -21,8 +21,8 @@ import (
"testing" "testing"
"time" "time"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake" "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5/fake"
"k8s.io/kubernetes/pkg/util/wait" "k8s.io/kubernetes/pkg/util/wait"
) )
...@@ -52,9 +52,9 @@ func TestAllocateOrOccupyCIDRSuccess(t *testing.T) { ...@@ -52,9 +52,9 @@ func TestAllocateOrOccupyCIDRSuccess(t *testing.T) {
{ {
description: "When there's no ServiceCIDR return first CIDR in range", description: "When there's no ServiceCIDR return first CIDR in range",
fakeNodeHandler: &FakeNodeHandler{ fakeNodeHandler: &FakeNodeHandler{
Existing: []*api.Node{ Existing: []*v1.Node{
{ {
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Name: "node0", Name: "node0",
}, },
}, },
...@@ -72,9 +72,9 @@ func TestAllocateOrOccupyCIDRSuccess(t *testing.T) { ...@@ -72,9 +72,9 @@ func TestAllocateOrOccupyCIDRSuccess(t *testing.T) {
{ {
description: "Correctly filter out ServiceCIDR", description: "Correctly filter out ServiceCIDR",
fakeNodeHandler: &FakeNodeHandler{ fakeNodeHandler: &FakeNodeHandler{
Existing: []*api.Node{ Existing: []*v1.Node{
{ {
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Name: "node0", Name: "node0",
}, },
}, },
...@@ -96,9 +96,9 @@ func TestAllocateOrOccupyCIDRSuccess(t *testing.T) { ...@@ -96,9 +96,9 @@ func TestAllocateOrOccupyCIDRSuccess(t *testing.T) {
{ {
description: "Correctly ignore already allocated CIDRs", description: "Correctly ignore already allocated CIDRs",
fakeNodeHandler: &FakeNodeHandler{ fakeNodeHandler: &FakeNodeHandler{
Existing: []*api.Node{ Existing: []*v1.Node{
{ {
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Name: "node0", Name: "node0",
}, },
}, },
...@@ -182,9 +182,9 @@ func TestAllocateOrOccupyCIDRFailure(t *testing.T) { ...@@ -182,9 +182,9 @@ func TestAllocateOrOccupyCIDRFailure(t *testing.T) {
{ {
description: "When there's no ServiceCIDR return first CIDR in range", description: "When there's no ServiceCIDR return first CIDR in range",
fakeNodeHandler: &FakeNodeHandler{ fakeNodeHandler: &FakeNodeHandler{
Existing: []*api.Node{ Existing: []*v1.Node{
{ {
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Name: "node0", Name: "node0",
}, },
}, },
...@@ -265,9 +265,9 @@ func TestReleaseCIDRSuccess(t *testing.T) { ...@@ -265,9 +265,9 @@ func TestReleaseCIDRSuccess(t *testing.T) {
{ {
description: "Correctly release preallocated CIDR", description: "Correctly release preallocated CIDR",
fakeNodeHandler: &FakeNodeHandler{ fakeNodeHandler: &FakeNodeHandler{
Existing: []*api.Node{ Existing: []*v1.Node{
{ {
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Name: "node0", Name: "node0",
}, },
}, },
...@@ -288,9 +288,9 @@ func TestReleaseCIDRSuccess(t *testing.T) { ...@@ -288,9 +288,9 @@ func TestReleaseCIDRSuccess(t *testing.T) {
{ {
description: "Correctly recycle CIDR", description: "Correctly recycle CIDR",
fakeNodeHandler: &FakeNodeHandler{ fakeNodeHandler: &FakeNodeHandler{
Existing: []*api.Node{ Existing: []*v1.Node{
{ {
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Name: "node0", Name: "node0",
}, },
}, },
...@@ -357,8 +357,8 @@ func TestReleaseCIDRSuccess(t *testing.T) { ...@@ -357,8 +357,8 @@ func TestReleaseCIDRSuccess(t *testing.T) {
} }
for _, cidrToRelease := range tc.cidrsToRelease { for _, cidrToRelease := range tc.cidrsToRelease {
nodeToRelease := api.Node{ nodeToRelease := v1.Node{
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Name: "node0", Name: "node0",
}, },
} }
......
...@@ -22,8 +22,9 @@ import ( ...@@ -22,8 +22,9 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors" "k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/client/cache" "k8s.io/kubernetes/pkg/client/cache"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" clientset "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5"
"k8s.io/kubernetes/pkg/client/record" "k8s.io/kubernetes/pkg/client/record"
"k8s.io/kubernetes/pkg/cloudprovider" "k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/fields" "k8s.io/kubernetes/pkg/fields"
...@@ -46,9 +47,9 @@ const ( ...@@ -46,9 +47,9 @@ const (
// if any pods were deleted, or were found pending deletion. // if any pods were deleted, or were found pending deletion.
func deletePods(kubeClient clientset.Interface, recorder record.EventRecorder, nodeName, nodeUID string, daemonStore cache.StoreToDaemonSetLister) (bool, error) { func deletePods(kubeClient clientset.Interface, recorder record.EventRecorder, nodeName, nodeUID string, daemonStore cache.StoreToDaemonSetLister) (bool, error) {
remaining := false remaining := false
selector := fields.OneTermEqualSelector(api.PodHostField, nodeName) selector := fields.OneTermEqualSelector(api.PodHostField, nodeName).String()
options := api.ListOptions{FieldSelector: selector} options := v1.ListOptions{FieldSelector: selector}
pods, err := kubeClient.Core().Pods(api.NamespaceAll).List(options) pods, err := kubeClient.Core().Pods(v1.NamespaceAll).List(options)
var updateErrList []error var updateErrList []error
if err != nil { if err != nil {
...@@ -56,7 +57,7 @@ func deletePods(kubeClient clientset.Interface, recorder record.EventRecorder, n ...@@ -56,7 +57,7 @@ func deletePods(kubeClient clientset.Interface, recorder record.EventRecorder, n
} }
if len(pods.Items) > 0 { if len(pods.Items) > 0 {
recordNodeEvent(recorder, nodeName, nodeUID, api.EventTypeNormal, "DeletingAllPods", fmt.Sprintf("Deleting all Pods from Node %v.", nodeName)) recordNodeEvent(recorder, nodeName, nodeUID, v1.EventTypeNormal, "DeletingAllPods", fmt.Sprintf("Deleting all Pods from Node %v.", nodeName))
} }
for _, pod := range pods.Items { for _, pod := range pods.Items {
...@@ -85,7 +86,7 @@ func deletePods(kubeClient clientset.Interface, recorder record.EventRecorder, n ...@@ -85,7 +86,7 @@ func deletePods(kubeClient clientset.Interface, recorder record.EventRecorder, n
} }
glog.V(2).Infof("Starting deletion of pod %v", pod.Name) glog.V(2).Infof("Starting deletion of pod %v", pod.Name)
recorder.Eventf(&pod, api.EventTypeNormal, "NodeControllerEviction", "Marking for deletion Pod %s from Node %s", pod.Name, nodeName) recorder.Eventf(&pod, v1.EventTypeNormal, "NodeControllerEviction", "Marking for deletion Pod %s from Node %s", pod.Name, nodeName)
if err := kubeClient.Core().Pods(pod.Namespace).Delete(pod.Name, nil); err != nil { if err := kubeClient.Core().Pods(pod.Namespace).Delete(pod.Name, nil); err != nil {
return false, err return false, err
} }
...@@ -100,7 +101,7 @@ func deletePods(kubeClient clientset.Interface, recorder record.EventRecorder, n ...@@ -100,7 +101,7 @@ func deletePods(kubeClient clientset.Interface, recorder record.EventRecorder, n
// setPodTerminationReason attempts to set a reason and message in the pod status, updates it in the apiserver, // setPodTerminationReason attempts to set a reason and message in the pod status, updates it in the apiserver,
// and returns an error if it encounters one. // and returns an error if it encounters one.
func setPodTerminationReason(kubeClient clientset.Interface, pod *api.Pod, nodeName string) (*api.Pod, error) { func setPodTerminationReason(kubeClient clientset.Interface, pod *v1.Pod, nodeName string) (*v1.Pod, error) {
if pod.Status.Reason == node.NodeUnreachablePodReason { if pod.Status.Reason == node.NodeUnreachablePodReason {
return pod, nil return pod, nil
} }
...@@ -108,7 +109,7 @@ func setPodTerminationReason(kubeClient clientset.Interface, pod *api.Pod, nodeN ...@@ -108,7 +109,7 @@ func setPodTerminationReason(kubeClient clientset.Interface, pod *api.Pod, nodeN
pod.Status.Reason = node.NodeUnreachablePodReason pod.Status.Reason = node.NodeUnreachablePodReason
pod.Status.Message = fmt.Sprintf(node.NodeUnreachablePodMessage, nodeName, pod.Name) pod.Status.Message = fmt.Sprintf(node.NodeUnreachablePodMessage, nodeName, pod.Name)
var updatedPod *api.Pod var updatedPod *v1.Pod
var err error var err error
if updatedPod, err = kubeClient.Core().Pods(pod.Namespace).UpdateStatus(pod); err != nil { if updatedPod, err = kubeClient.Core().Pods(pod.Namespace).UpdateStatus(pod); err != nil {
return nil, err return nil, err
...@@ -116,10 +117,10 @@ func setPodTerminationReason(kubeClient clientset.Interface, pod *api.Pod, nodeN ...@@ -116,10 +117,10 @@ func setPodTerminationReason(kubeClient clientset.Interface, pod *api.Pod, nodeN
return updatedPod, nil return updatedPod, nil
} }
func forcefullyDeletePod(c clientset.Interface, pod *api.Pod) error { func forcefullyDeletePod(c clientset.Interface, pod *v1.Pod) error {
var zero int64 var zero int64
glog.Infof("NodeController is force deleting Pod: %v:%v", pod.Namespace, pod.Name) glog.Infof("NodeController is force deleting Pod: %v:%v", pod.Namespace, pod.Name)
err := c.Core().Pods(pod.Namespace).Delete(pod.Name, &api.DeleteOptions{GracePeriodSeconds: &zero}) err := c.Core().Pods(pod.Namespace).Delete(pod.Name, &v1.DeleteOptions{GracePeriodSeconds: &zero})
if err == nil { if err == nil {
glog.V(4).Infof("forceful deletion of %s succeeded", pod.Name) glog.V(4).Infof("forceful deletion of %s succeeded", pod.Name)
} }
...@@ -138,14 +139,14 @@ func forcefullyDeleteNode(kubeClient clientset.Interface, nodeName string) error ...@@ -138,14 +139,14 @@ func forcefullyDeleteNode(kubeClient clientset.Interface, nodeName string) error
// maybeDeleteTerminatingPod non-gracefully deletes pods that are terminating // maybeDeleteTerminatingPod non-gracefully deletes pods that are terminating
// that should not be gracefully terminated. // that should not be gracefully terminated.
func (nc *NodeController) maybeDeleteTerminatingPod(obj interface{}) { func (nc *NodeController) maybeDeleteTerminatingPod(obj interface{}) {
pod, ok := obj.(*api.Pod) pod, ok := obj.(*v1.Pod)
if !ok { if !ok {
tombstone, ok := obj.(cache.DeletedFinalStateUnknown) tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
if !ok { if !ok {
glog.Errorf("Couldn't get object from tombstone %#v", obj) glog.Errorf("Couldn't get object from tombstone %#v", obj)
return return
} }
pod, ok = tombstone.Obj.(*api.Pod) pod, ok = tombstone.Obj.(*v1.Pod)
if !ok { if !ok {
glog.Errorf("Tombstone contained object that is not a Pod %#v", obj) glog.Errorf("Tombstone contained object that is not a Pod %#v", obj)
return return
...@@ -176,7 +177,7 @@ func (nc *NodeController) maybeDeleteTerminatingPod(obj interface{}) { ...@@ -176,7 +177,7 @@ func (nc *NodeController) maybeDeleteTerminatingPod(obj interface{}) {
// TODO(mikedanese): this can be removed when we no longer // TODO(mikedanese): this can be removed when we no longer
// guarantee backwards compatibility of master API to kubelets with // guarantee backwards compatibility of master API to kubelets with
// versions less than 1.1.0 // versions less than 1.1.0
node := nodeObj.(*api.Node) node := nodeObj.(*v1.Node)
v, err := version.Parse(node.Status.NodeInfo.KubeletVersion) v, err := version.Parse(node.Status.NodeInfo.KubeletVersion)
if err != nil { if err != nil {
glog.V(0).Infof("couldn't parse verions %q of minion: %v", node.Status.NodeInfo.KubeletVersion, err) glog.V(0).Infof("couldn't parse verions %q of minion: %v", node.Status.NodeInfo.KubeletVersion, err)
...@@ -191,7 +192,7 @@ func (nc *NodeController) maybeDeleteTerminatingPod(obj interface{}) { ...@@ -191,7 +192,7 @@ func (nc *NodeController) maybeDeleteTerminatingPod(obj interface{}) {
// update ready status of all pods running on given node from master // update ready status of all pods running on given node from master
// return true if success // return true if success
func markAllPodsNotReady(kubeClient clientset.Interface, node *api.Node) error { func markAllPodsNotReady(kubeClient clientset.Interface, node *v1.Node) error {
// Don't set pods to NotReady if the kubelet is running a version that // Don't set pods to NotReady if the kubelet is running a version that
// doesn't understand how to correct readiness. // doesn't understand how to correct readiness.
// TODO: Remove this check when we no longer guarantee backward compatibility // TODO: Remove this check when we no longer guarantee backward compatibility
...@@ -201,8 +202,8 @@ func markAllPodsNotReady(kubeClient clientset.Interface, node *api.Node) error { ...@@ -201,8 +202,8 @@ func markAllPodsNotReady(kubeClient clientset.Interface, node *api.Node) error {
} }
nodeName := node.Name nodeName := node.Name
glog.V(2).Infof("Update ready status of pods on node [%v]", nodeName) glog.V(2).Infof("Update ready status of pods on node [%v]", nodeName)
opts := api.ListOptions{FieldSelector: fields.OneTermEqualSelector(api.PodHostField, nodeName)} opts := v1.ListOptions{FieldSelector: fields.OneTermEqualSelector(api.PodHostField, nodeName).String()}
pods, err := kubeClient.Core().Pods(api.NamespaceAll).List(opts) pods, err := kubeClient.Core().Pods(v1.NamespaceAll).List(opts)
if err != nil { if err != nil {
return err return err
} }
...@@ -215,8 +216,8 @@ func markAllPodsNotReady(kubeClient clientset.Interface, node *api.Node) error { ...@@ -215,8 +216,8 @@ func markAllPodsNotReady(kubeClient clientset.Interface, node *api.Node) error {
} }
for i, cond := range pod.Status.Conditions { for i, cond := range pod.Status.Conditions {
if cond.Type == api.PodReady { if cond.Type == v1.PodReady {
pod.Status.Conditions[i].Status = api.ConditionFalse pod.Status.Conditions[i].Status = v1.ConditionFalse
glog.V(2).Infof("Updating ready status of pod %v to false", pod.Name) glog.V(2).Infof("Updating ready status of pod %v to false", pod.Name)
_, err := kubeClient.Core().Pods(pod.Namespace).UpdateStatus(&pod) _, err := kubeClient.Core().Pods(pod.Namespace).UpdateStatus(&pod)
if err != nil { if err != nil {
...@@ -237,7 +238,7 @@ func markAllPodsNotReady(kubeClient clientset.Interface, node *api.Node) error { ...@@ -237,7 +238,7 @@ func markAllPodsNotReady(kubeClient clientset.Interface, node *api.Node) error {
// in the nodeInfo of the given node is "outdated", meaning < 1.2.0. // in the nodeInfo of the given node is "outdated", meaning < 1.2.0.
// Older versions were inflexible and modifying pod.Status directly through // Older versions were inflexible and modifying pod.Status directly through
// the apiserver would result in unexpected outcomes. // the apiserver would result in unexpected outcomes.
func nodeRunningOutdatedKubelet(node *api.Node) bool { func nodeRunningOutdatedKubelet(node *v1.Node) bool {
v, err := version.Parse(node.Status.NodeInfo.KubeletVersion) v, err := version.Parse(node.Status.NodeInfo.KubeletVersion)
if err != nil { if err != nil {
glog.Errorf("couldn't parse version %q of node %v", node.Status.NodeInfo.KubeletVersion, err) glog.Errorf("couldn't parse version %q of node %v", node.Status.NodeInfo.KubeletVersion, err)
...@@ -265,7 +266,7 @@ func nodeExistsInCloudProvider(cloud cloudprovider.Interface, nodeName types.Nod ...@@ -265,7 +266,7 @@ func nodeExistsInCloudProvider(cloud cloudprovider.Interface, nodeName types.Nod
} }
func recordNodeEvent(recorder record.EventRecorder, nodeName, nodeUID, eventtype, reason, event string) { func recordNodeEvent(recorder record.EventRecorder, nodeName, nodeUID, eventtype, reason, event string) {
ref := &api.ObjectReference{ ref := &v1.ObjectReference{
Kind: "Node", Kind: "Node",
Name: nodeName, Name: nodeName,
UID: types.UID(nodeUID), UID: types.UID(nodeUID),
...@@ -275,8 +276,8 @@ func recordNodeEvent(recorder record.EventRecorder, nodeName, nodeUID, eventtype ...@@ -275,8 +276,8 @@ func recordNodeEvent(recorder record.EventRecorder, nodeName, nodeUID, eventtype
recorder.Eventf(ref, eventtype, reason, "Node %s event: %s", nodeName, event) recorder.Eventf(ref, eventtype, reason, "Node %s event: %s", nodeName, event)
} }
func recordNodeStatusChange(recorder record.EventRecorder, node *api.Node, new_status string) { func recordNodeStatusChange(recorder record.EventRecorder, node *v1.Node, new_status string) {
ref := &api.ObjectReference{ ref := &v1.ObjectReference{
Kind: "Node", Kind: "Node",
Name: node.Name, Name: node.Name,
UID: node.UID, UID: node.UID,
...@@ -285,5 +286,5 @@ func recordNodeStatusChange(recorder record.EventRecorder, node *api.Node, new_s ...@@ -285,5 +286,5 @@ func recordNodeStatusChange(recorder record.EventRecorder, node *api.Node, new_s
glog.V(2).Infof("Recording status change %s event message for node %s", new_status, node.Name) glog.V(2).Infof("Recording status change %s event message for node %s", new_status, node.Name)
// TODO: This requires a transaction, either both node status is updated // TODO: This requires a transaction, either both node status is updated
// and event is recorded or neither should happen, see issue #6055. // and event is recorded or neither should happen, see issue #6055.
recorder.Eventf(ref, api.EventTypeNormal, new_status, "Node %s status is now: %s", node.Name, new_status) recorder.Eventf(ref, v1.EventTypeNormal, new_status, "Node %s status is now: %s", node.Name, new_status)
} }
...@@ -26,8 +26,9 @@ import ( ...@@ -26,8 +26,9 @@ import (
apierrors "k8s.io/kubernetes/pkg/api/errors" apierrors "k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/resource" "k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake" "k8s.io/kubernetes/pkg/api/v1"
unversionedcore "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion" "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5/fake"
v1core "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5/typed/core/v1"
"k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util/clock" "k8s.io/kubernetes/pkg/util/clock"
utilnode "k8s.io/kubernetes/pkg/util/node" utilnode "k8s.io/kubernetes/pkg/util/node"
...@@ -43,14 +44,14 @@ type FakeNodeHandler struct { ...@@ -43,14 +44,14 @@ type FakeNodeHandler struct {
*fake.Clientset *fake.Clientset
// Input: Hooks determine if request is valid or not // Input: Hooks determine if request is valid or not
CreateHook func(*FakeNodeHandler, *api.Node) bool CreateHook func(*FakeNodeHandler, *v1.Node) bool
Existing []*api.Node Existing []*v1.Node
// Output // Output
CreatedNodes []*api.Node CreatedNodes []*v1.Node
DeletedNodes []*api.Node DeletedNodes []*v1.Node
UpdatedNodes []*api.Node UpdatedNodes []*v1.Node
UpdatedNodeStatuses []*api.Node UpdatedNodeStatuses []*v1.Node
RequestCount int RequestCount int
// Synchronization // Synchronization
...@@ -59,29 +60,29 @@ type FakeNodeHandler struct { ...@@ -59,29 +60,29 @@ type FakeNodeHandler struct {
} }
type FakeLegacyHandler struct { type FakeLegacyHandler struct {
unversionedcore.CoreInterface v1core.CoreV1Interface
n *FakeNodeHandler n *FakeNodeHandler
} }
func (c *FakeNodeHandler) getUpdatedNodesCopy() []*api.Node { func (c *FakeNodeHandler) getUpdatedNodesCopy() []*v1.Node {
c.lock.Lock() c.lock.Lock()
defer c.lock.Unlock() defer c.lock.Unlock()
updatedNodesCopy := make([]*api.Node, len(c.UpdatedNodes), len(c.UpdatedNodes)) updatedNodesCopy := make([]*v1.Node, len(c.UpdatedNodes), len(c.UpdatedNodes))
for i, ptr := range c.UpdatedNodes { for i, ptr := range c.UpdatedNodes {
updatedNodesCopy[i] = ptr updatedNodesCopy[i] = ptr
} }
return updatedNodesCopy return updatedNodesCopy
} }
func (c *FakeNodeHandler) Core() unversionedcore.CoreInterface { func (c *FakeNodeHandler) Core() v1core.CoreV1Interface {
return &FakeLegacyHandler{c.Clientset.Core(), c} return &FakeLegacyHandler{c.Clientset.Core(), c}
} }
func (m *FakeLegacyHandler) Nodes() unversionedcore.NodeInterface { func (m *FakeLegacyHandler) Nodes() v1core.NodeInterface {
return m.n return m.n
} }
func (m *FakeNodeHandler) Create(node *api.Node) (*api.Node, error) { func (m *FakeNodeHandler) Create(node *v1.Node) (*v1.Node, error) {
m.lock.Lock() m.lock.Lock()
defer func() { defer func() {
m.RequestCount++ m.RequestCount++
...@@ -101,7 +102,7 @@ func (m *FakeNodeHandler) Create(node *api.Node) (*api.Node, error) { ...@@ -101,7 +102,7 @@ func (m *FakeNodeHandler) Create(node *api.Node) (*api.Node, error) {
} }
} }
func (m *FakeNodeHandler) Get(name string) (*api.Node, error) { func (m *FakeNodeHandler) Get(name string) (*v1.Node, error) {
m.lock.Lock() m.lock.Lock()
defer func() { defer func() {
m.RequestCount++ m.RequestCount++
...@@ -122,13 +123,13 @@ func (m *FakeNodeHandler) Get(name string) (*api.Node, error) { ...@@ -122,13 +123,13 @@ func (m *FakeNodeHandler) Get(name string) (*api.Node, error) {
return nil, nil return nil, nil
} }
func (m *FakeNodeHandler) List(opts api.ListOptions) (*api.NodeList, error) { func (m *FakeNodeHandler) List(opts v1.ListOptions) (*v1.NodeList, error) {
m.lock.Lock() m.lock.Lock()
defer func() { defer func() {
m.RequestCount++ m.RequestCount++
m.lock.Unlock() m.lock.Unlock()
}() }()
var nodes []*api.Node var nodes []*v1.Node
for i := 0; i < len(m.UpdatedNodes); i++ { for i := 0; i < len(m.UpdatedNodes); i++ {
if !contains(m.UpdatedNodes[i], m.DeletedNodes) { if !contains(m.UpdatedNodes[i], m.DeletedNodes) {
nodes = append(nodes, m.UpdatedNodes[i]) nodes = append(nodes, m.UpdatedNodes[i])
...@@ -144,14 +145,14 @@ func (m *FakeNodeHandler) List(opts api.ListOptions) (*api.NodeList, error) { ...@@ -144,14 +145,14 @@ func (m *FakeNodeHandler) List(opts api.ListOptions) (*api.NodeList, error) {
nodes = append(nodes, m.CreatedNodes[i]) nodes = append(nodes, m.CreatedNodes[i])
} }
} }
nodeList := &api.NodeList{} nodeList := &v1.NodeList{}
for _, node := range nodes { for _, node := range nodes {
nodeList.Items = append(nodeList.Items, *node) nodeList.Items = append(nodeList.Items, *node)
} }
return nodeList, nil return nodeList, nil
} }
func (m *FakeNodeHandler) Delete(id string, opt *api.DeleteOptions) error { func (m *FakeNodeHandler) Delete(id string, opt *v1.DeleteOptions) error {
m.lock.Lock() m.lock.Lock()
defer func() { defer func() {
m.RequestCount++ m.RequestCount++
...@@ -164,11 +165,11 @@ func (m *FakeNodeHandler) Delete(id string, opt *api.DeleteOptions) error { ...@@ -164,11 +165,11 @@ func (m *FakeNodeHandler) Delete(id string, opt *api.DeleteOptions) error {
return nil return nil
} }
func (m *FakeNodeHandler) DeleteCollection(opt *api.DeleteOptions, listOpts api.ListOptions) error { func (m *FakeNodeHandler) DeleteCollection(opt *v1.DeleteOptions, listOpts v1.ListOptions) error {
return nil return nil
} }
func (m *FakeNodeHandler) Update(node *api.Node) (*api.Node, error) { func (m *FakeNodeHandler) Update(node *v1.Node) (*v1.Node, error) {
m.lock.Lock() m.lock.Lock()
defer func() { defer func() {
m.RequestCount++ m.RequestCount++
...@@ -185,7 +186,7 @@ func (m *FakeNodeHandler) Update(node *api.Node) (*api.Node, error) { ...@@ -185,7 +186,7 @@ func (m *FakeNodeHandler) Update(node *api.Node) (*api.Node, error) {
return node, nil return node, nil
} }
func (m *FakeNodeHandler) UpdateStatus(node *api.Node) (*api.Node, error) { func (m *FakeNodeHandler) UpdateStatus(node *v1.Node) (*v1.Node, error) {
m.lock.Lock() m.lock.Lock()
defer func() { defer func() {
m.RequestCount++ m.RequestCount++
...@@ -196,23 +197,23 @@ func (m *FakeNodeHandler) UpdateStatus(node *api.Node) (*api.Node, error) { ...@@ -196,23 +197,23 @@ func (m *FakeNodeHandler) UpdateStatus(node *api.Node) (*api.Node, error) {
return node, nil return node, nil
} }
func (m *FakeNodeHandler) PatchStatus(nodeName string, data []byte) (*api.Node, error) { func (m *FakeNodeHandler) PatchStatus(nodeName string, data []byte) (*v1.Node, error) {
m.RequestCount++ m.RequestCount++
return &api.Node{}, nil return &v1.Node{}, nil
} }
func (m *FakeNodeHandler) Watch(opts api.ListOptions) (watch.Interface, error) { func (m *FakeNodeHandler) Watch(opts v1.ListOptions) (watch.Interface, error) {
return watch.NewFake(), nil return watch.NewFake(), nil
} }
func (m *FakeNodeHandler) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (*api.Node, error) { func (m *FakeNodeHandler) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (*v1.Node, error) {
return nil, nil return nil, nil
} }
// FakeRecorder is used as a fake during testing. // FakeRecorder is used as a fake during testing.
type FakeRecorder struct { type FakeRecorder struct {
source api.EventSource source v1.EventSource
events []*api.Event events []*v1.Event
clock clock.Clock clock clock.Clock
} }
...@@ -228,7 +229,7 @@ func (f *FakeRecorder) PastEventf(obj runtime.Object, timestamp unversioned.Time ...@@ -228,7 +229,7 @@ func (f *FakeRecorder) PastEventf(obj runtime.Object, timestamp unversioned.Time
} }
func (f *FakeRecorder) generateEvent(obj runtime.Object, timestamp unversioned.Time, eventtype, reason, message string) { func (f *FakeRecorder) generateEvent(obj runtime.Object, timestamp unversioned.Time, eventtype, reason, message string) {
ref, err := api.GetReference(obj) ref, err := v1.GetReference(obj)
if err != nil { if err != nil {
return return
} }
...@@ -240,15 +241,15 @@ func (f *FakeRecorder) generateEvent(obj runtime.Object, timestamp unversioned.T ...@@ -240,15 +241,15 @@ func (f *FakeRecorder) generateEvent(obj runtime.Object, timestamp unversioned.T
} }
} }
func (f *FakeRecorder) makeEvent(ref *api.ObjectReference, eventtype, reason, message string) *api.Event { func (f *FakeRecorder) makeEvent(ref *v1.ObjectReference, eventtype, reason, message string) *v1.Event {
fmt.Println("make event") fmt.Println("make event")
t := unversioned.Time{Time: f.clock.Now()} t := unversioned.Time{Time: f.clock.Now()}
namespace := ref.Namespace namespace := ref.Namespace
if namespace == "" { if namespace == "" {
namespace = api.NamespaceDefault namespace = v1.NamespaceDefault
} }
return &api.Event{ return &v1.Event{
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Name: fmt.Sprintf("%v.%x", ref.Name, t.UnixNano()), Name: fmt.Sprintf("%v.%x", ref.Name, t.UnixNano()),
Namespace: namespace, Namespace: namespace,
}, },
...@@ -264,41 +265,41 @@ func (f *FakeRecorder) makeEvent(ref *api.ObjectReference, eventtype, reason, me ...@@ -264,41 +265,41 @@ func (f *FakeRecorder) makeEvent(ref *api.ObjectReference, eventtype, reason, me
func NewFakeRecorder() *FakeRecorder { func NewFakeRecorder() *FakeRecorder {
return &FakeRecorder{ return &FakeRecorder{
source: api.EventSource{Component: "nodeControllerTest"}, source: v1.EventSource{Component: "nodeControllerTest"},
events: []*api.Event{}, events: []*v1.Event{},
clock: clock.NewFakeClock(time.Now()), clock: clock.NewFakeClock(time.Now()),
} }
} }
func newNode(name string) *api.Node { func newNode(name string) *v1.Node {
return &api.Node{ return &v1.Node{
ObjectMeta: api.ObjectMeta{Name: name}, ObjectMeta: v1.ObjectMeta{Name: name},
Spec: api.NodeSpec{ Spec: v1.NodeSpec{
ExternalID: name, ExternalID: name,
}, },
Status: api.NodeStatus{ Status: v1.NodeStatus{
Capacity: api.ResourceList{ Capacity: v1.ResourceList{
api.ResourceName(api.ResourceCPU): resource.MustParse("10"), v1.ResourceName(v1.ResourceCPU): resource.MustParse("10"),
api.ResourceName(api.ResourceMemory): resource.MustParse("10G"), v1.ResourceName(v1.ResourceMemory): resource.MustParse("10G"),
}, },
}, },
} }
} }
func newPod(name, host string) *api.Pod { func newPod(name, host string) *v1.Pod {
pod := &api.Pod{ pod := &v1.Pod{
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Namespace: "default", Namespace: "default",
Name: name, Name: name,
}, },
Spec: api.PodSpec{ Spec: v1.PodSpec{
NodeName: host, NodeName: host,
}, },
Status: api.PodStatus{ Status: v1.PodStatus{
Conditions: []api.PodCondition{ Conditions: []v1.PodCondition{
{ {
Type: api.PodReady, Type: v1.PodReady,
Status: api.ConditionTrue, Status: v1.ConditionTrue,
}, },
}, },
}, },
...@@ -307,7 +308,7 @@ func newPod(name, host string) *api.Pod { ...@@ -307,7 +308,7 @@ func newPod(name, host string) *api.Pod {
return pod return pod
} }
func contains(node *api.Node, nodes []*api.Node) bool { func contains(node *v1.Node, nodes []*v1.Node) bool {
for i := 0; i < len(nodes); i++ { for i := 0; i < len(nodes); i++ {
if node.Name == nodes[i].Name { if node.Name == nodes[i].Name {
return true return true
...@@ -318,7 +319,7 @@ func contains(node *api.Node, nodes []*api.Node) bool { ...@@ -318,7 +319,7 @@ func contains(node *api.Node, nodes []*api.Node) bool {
// Returns list of zones for all Nodes stored in FakeNodeHandler // Returns list of zones for all Nodes stored in FakeNodeHandler
func getZones(nodeHandler *FakeNodeHandler) []string { func getZones(nodeHandler *FakeNodeHandler) []string {
nodes, _ := nodeHandler.List(api.ListOptions{}) nodes, _ := nodeHandler.List(v1.ListOptions{})
zones := sets.NewString() zones := sets.NewString()
for _, node := range nodes.Items { for _, node := range nodes.Items {
zones.Insert(utilnode.GetZoneKey(&node)) zones.Insert(utilnode.GetZoneKey(&node))
......
...@@ -22,11 +22,11 @@ import ( ...@@ -22,11 +22,11 @@ import (
inf "gopkg.in/inf.v0" inf "gopkg.in/inf.v0"
"k8s.io/kubernetes/pkg/api"
api_pod "k8s.io/kubernetes/pkg/api/pod"
"k8s.io/kubernetes/pkg/api/resource" "k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apis/apps" "k8s.io/kubernetes/pkg/api/v1"
api_pod "k8s.io/kubernetes/pkg/api/v1/pod"
apps "k8s.io/kubernetes/pkg/apis/apps/v1beta1"
"k8s.io/kubernetes/pkg/client/record" "k8s.io/kubernetes/pkg/client/record"
"k8s.io/kubernetes/pkg/types" "k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/util/sets" "k8s.io/kubernetes/pkg/util/sets"
...@@ -36,34 +36,34 @@ func dec(i int64, exponent int) *inf.Dec { ...@@ -36,34 +36,34 @@ func dec(i int64, exponent int) *inf.Dec {
return inf.NewDec(i, inf.Scale(-exponent)) return inf.NewDec(i, inf.Scale(-exponent))
} }
func newPVC(name string) api.PersistentVolumeClaim { func newPVC(name string) v1.PersistentVolumeClaim {
return api.PersistentVolumeClaim{ return v1.PersistentVolumeClaim{
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Name: name, Name: name,
}, },
Spec: api.PersistentVolumeClaimSpec{ Spec: v1.PersistentVolumeClaimSpec{
Resources: api.ResourceRequirements{ Resources: v1.ResourceRequirements{
Requests: api.ResourceList{ Requests: v1.ResourceList{
api.ResourceStorage: *resource.NewQuantity(1, resource.BinarySI), v1.ResourceStorage: *resource.NewQuantity(1, resource.BinarySI),
}, },
}, },
}, },
} }
} }
func newStatefulSetWithVolumes(replicas int, name string, petMounts []api.VolumeMount, podMounts []api.VolumeMount) *apps.StatefulSet { func newStatefulSetWithVolumes(replicas int, name string, petMounts []v1.VolumeMount, podMounts []v1.VolumeMount) *apps.StatefulSet {
mounts := append(petMounts, podMounts...) mounts := append(petMounts, podMounts...)
claims := []api.PersistentVolumeClaim{} claims := []v1.PersistentVolumeClaim{}
for _, m := range petMounts { for _, m := range petMounts {
claims = append(claims, newPVC(m.Name)) claims = append(claims, newPVC(m.Name))
} }
vols := []api.Volume{} vols := []v1.Volume{}
for _, m := range podMounts { for _, m := range podMounts {
vols = append(vols, api.Volume{ vols = append(vols, v1.Volume{
Name: m.Name, Name: m.Name,
VolumeSource: api.VolumeSource{ VolumeSource: v1.VolumeSource{
HostPath: &api.HostPathVolumeSource{ HostPath: &v1.HostPathVolumeSource{
Path: fmt.Sprintf("/tmp/%v", m.Name), Path: fmt.Sprintf("/tmp/%v", m.Name),
}, },
}, },
...@@ -75,19 +75,19 @@ func newStatefulSetWithVolumes(replicas int, name string, petMounts []api.Volume ...@@ -75,19 +75,19 @@ func newStatefulSetWithVolumes(replicas int, name string, petMounts []api.Volume
Kind: "StatefulSet", Kind: "StatefulSet",
APIVersion: "apps/v1beta1", APIVersion: "apps/v1beta1",
}, },
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Name: name, Name: name,
Namespace: api.NamespaceDefault, Namespace: v1.NamespaceDefault,
UID: types.UID("test"), UID: types.UID("test"),
}, },
Spec: apps.StatefulSetSpec{ Spec: apps.StatefulSetSpec{
Selector: &unversioned.LabelSelector{ Selector: &unversioned.LabelSelector{
MatchLabels: map[string]string{"foo": "bar"}, MatchLabels: map[string]string{"foo": "bar"},
}, },
Replicas: int32(replicas), Replicas: func() *int32 { i := int32(replicas); return &i }(),
Template: api.PodTemplateSpec{ Template: v1.PodTemplateSpec{
Spec: api.PodSpec{ Spec: v1.PodSpec{
Containers: []api.Container{ Containers: []v1.Container{
{ {
Name: "nginx", Name: "nginx",
Image: "nginx", Image: "nginx",
...@@ -103,16 +103,16 @@ func newStatefulSetWithVolumes(replicas int, name string, petMounts []api.Volume ...@@ -103,16 +103,16 @@ func newStatefulSetWithVolumes(replicas int, name string, petMounts []api.Volume
} }
} }
func runningPod(ns, name string) *api.Pod { func runningPod(ns, name string) *v1.Pod {
p := &api.Pod{Status: api.PodStatus{Phase: api.PodRunning}} p := &v1.Pod{Status: v1.PodStatus{Phase: v1.PodRunning}}
p.Namespace = ns p.Namespace = ns
p.Name = name p.Name = name
return p return p
} }
func newPodList(ps *apps.StatefulSet, num int) []*api.Pod { func newPodList(ps *apps.StatefulSet, num int) []*v1.Pod {
// knownPods are pods in the system // knownPods are pods in the system
knownPods := []*api.Pod{} knownPods := []*v1.Pod{}
for i := 0; i < num; i++ { for i := 0; i < num; i++ {
k, _ := newPCB(fmt.Sprintf("%v", i), ps) k, _ := newPCB(fmt.Sprintf("%v", i), ps)
knownPods = append(knownPods, k.pod) knownPods = append(knownPods, k.pod)
...@@ -121,16 +121,16 @@ func newPodList(ps *apps.StatefulSet, num int) []*api.Pod { ...@@ -121,16 +121,16 @@ func newPodList(ps *apps.StatefulSet, num int) []*api.Pod {
} }
func newStatefulSet(replicas int) *apps.StatefulSet { func newStatefulSet(replicas int) *apps.StatefulSet {
petMounts := []api.VolumeMount{ petMounts := []v1.VolumeMount{
{Name: "datadir", MountPath: "/tmp/zookeeper"}, {Name: "datadir", MountPath: "/tmp/zookeeper"},
} }
podMounts := []api.VolumeMount{ podMounts := []v1.VolumeMount{
{Name: "home", MountPath: "/home"}, {Name: "home", MountPath: "/home"},
} }
return newStatefulSetWithVolumes(replicas, "foo", petMounts, podMounts) return newStatefulSetWithVolumes(replicas, "foo", petMounts, podMounts)
} }
func checkPodForMount(pod *api.Pod, mountName string) error { func checkPodForMount(pod *v1.Pod, mountName string) error {
for _, c := range pod.Spec.Containers { for _, c := range pod.Spec.Containers {
for _, v := range c.VolumeMounts { for _, v := range c.VolumeMounts {
if v.Name == mountName { if v.Name == mountName {
...@@ -144,7 +144,7 @@ func checkPodForMount(pod *api.Pod, mountName string) error { ...@@ -144,7 +144,7 @@ func checkPodForMount(pod *api.Pod, mountName string) error {
func newFakePetClient() *fakePetClient { func newFakePetClient() *fakePetClient {
return &fakePetClient{ return &fakePetClient{
pets: []*pcb{}, pets: []*pcb{},
claims: []api.PersistentVolumeClaim{}, claims: []v1.PersistentVolumeClaim{},
recorder: &record.FakeRecorder{}, recorder: &record.FakeRecorder{},
petHealthChecker: &defaultPetHealthChecker{}, petHealthChecker: &defaultPetHealthChecker{},
} }
...@@ -152,7 +152,7 @@ func newFakePetClient() *fakePetClient { ...@@ -152,7 +152,7 @@ func newFakePetClient() *fakePetClient {
type fakePetClient struct { type fakePetClient struct {
pets []*pcb pets []*pcb
claims []api.PersistentVolumeClaim claims []v1.PersistentVolumeClaim
petsCreated int petsCreated int
petsDeleted int petsDeleted int
claimsCreated int claimsCreated int
...@@ -168,7 +168,7 @@ func (f *fakePetClient) Delete(p *pcb) error { ...@@ -168,7 +168,7 @@ func (f *fakePetClient) Delete(p *pcb) error {
for i, pet := range f.pets { for i, pet := range f.pets {
if p.pod.Name == pet.pod.Name { if p.pod.Name == pet.pod.Name {
found = true found = true
f.recorder.Eventf(pet.parent, api.EventTypeNormal, "SuccessfulDelete", "pod: %v", pet.pod.Name) f.recorder.Eventf(pet.parent, v1.EventTypeNormal, "SuccessfulDelete", "pod: %v", pet.pod.Name)
continue continue
} }
pets = append(pets, f.pets[i]) pets = append(pets, f.pets[i])
...@@ -199,7 +199,7 @@ func (f *fakePetClient) Create(p *pcb) error { ...@@ -199,7 +199,7 @@ func (f *fakePetClient) Create(p *pcb) error {
return fmt.Errorf("Create failed: pod %v already exists", p.pod.Name) return fmt.Errorf("Create failed: pod %v already exists", p.pod.Name)
} }
} }
f.recorder.Eventf(p.parent, api.EventTypeNormal, "SuccessfulCreate", "pod: %v", p.pod.Name) f.recorder.Eventf(p.parent, v1.EventTypeNormal, "SuccessfulCreate", "pod: %v", p.pod.Name)
f.pets = append(f.pets, p) f.pets = append(f.pets, p)
f.petsCreated++ f.petsCreated++
return nil return nil
...@@ -226,8 +226,8 @@ func (f *fakePetClient) Update(expected, wanted *pcb) error { ...@@ -226,8 +226,8 @@ func (f *fakePetClient) Update(expected, wanted *pcb) error {
return nil return nil
} }
func (f *fakePetClient) getPodList() []*api.Pod { func (f *fakePetClient) getPodList() []*v1.Pod {
p := []*api.Pod{} p := []*v1.Pod{}
for i, pet := range f.pets { for i, pet := range f.pets {
if pet.pod == nil { if pet.pod == nil {
continue continue
...@@ -251,10 +251,10 @@ func (f *fakePetClient) setHealthy(index int) error { ...@@ -251,10 +251,10 @@ func (f *fakePetClient) setHealthy(index int) error {
if len(f.pets) <= index { if len(f.pets) <= index {
return fmt.Errorf("Index out of range, len %v index %v", len(f.pets), index) return fmt.Errorf("Index out of range, len %v index %v", len(f.pets), index)
} }
f.pets[index].pod.Status.Phase = api.PodRunning f.pets[index].pod.Status.Phase = v1.PodRunning
f.pets[index].pod.Annotations[StatefulSetInitAnnotation] = "true" f.pets[index].pod.Annotations[StatefulSetInitAnnotation] = "true"
f.pets[index].pod.Status.Conditions = []api.PodCondition{ f.pets[index].pod.Status.Conditions = []v1.PodCondition{
{Type: api.PodReady, Status: api.ConditionTrue}, {Type: v1.PodReady, Status: v1.ConditionTrue},
} }
return nil return nil
} }
...@@ -262,7 +262,7 @@ func (f *fakePetClient) setHealthy(index int) error { ...@@ -262,7 +262,7 @@ func (f *fakePetClient) setHealthy(index int) error {
// isHealthy is a convenience wrapper around the default health checker. // isHealthy is a convenience wrapper around the default health checker.
// The first invocation returns not-healthy, but marks the pet healthy so // The first invocation returns not-healthy, but marks the pet healthy so
// subsequent invocations see it as healthy. // subsequent invocations see it as healthy.
func (f *fakePetClient) isHealthy(pod *api.Pod) bool { func (f *fakePetClient) isHealthy(pod *v1.Pod) bool {
if f.petHealthChecker.isHealthy(pod) { if f.petHealthChecker.isHealthy(pod) {
return true return true
} }
...@@ -280,11 +280,11 @@ func (f *fakePetClient) setDeletionTimestamp(index int) error { ...@@ -280,11 +280,11 @@ func (f *fakePetClient) setDeletionTimestamp(index int) error {
// SyncPVCs fakes pvc syncing. // SyncPVCs fakes pvc syncing.
func (f *fakePetClient) SyncPVCs(pet *pcb) error { func (f *fakePetClient) SyncPVCs(pet *pcb) error {
v := pet.pvcs v := pet.pvcs
updateClaims := map[string]api.PersistentVolumeClaim{} updateClaims := map[string]v1.PersistentVolumeClaim{}
for i, update := range v { for i, update := range v {
updateClaims[update.Name] = v[i] updateClaims[update.Name] = v[i]
} }
claimList := []api.PersistentVolumeClaim{} claimList := []v1.PersistentVolumeClaim{}
for i, existing := range f.claims { for i, existing := range f.claims {
if update, ok := updateClaims[existing.Name]; ok { if update, ok := updateClaims[existing.Name]; ok {
claimList = append(claimList, update) claimList = append(claimList, update)
...@@ -296,7 +296,7 @@ func (f *fakePetClient) SyncPVCs(pet *pcb) error { ...@@ -296,7 +296,7 @@ func (f *fakePetClient) SyncPVCs(pet *pcb) error {
for _, remaining := range updateClaims { for _, remaining := range updateClaims {
claimList = append(claimList, remaining) claimList = append(claimList, remaining)
f.claimsCreated++ f.claimsCreated++
f.recorder.Eventf(pet.parent, api.EventTypeNormal, "SuccessfulCreate", "pvc: %v", remaining.Name) f.recorder.Eventf(pet.parent, v1.EventTypeNormal, "SuccessfulCreate", "pvc: %v", remaining.Name)
} }
f.claims = claimList f.claims = claimList
return nil return nil
...@@ -309,12 +309,12 @@ func (f *fakePetClient) DeletePVCs(pet *pcb) error { ...@@ -309,12 +309,12 @@ func (f *fakePetClient) DeletePVCs(pet *pcb) error {
for _, c := range claimsToDelete { for _, c := range claimsToDelete {
deleteClaimNames.Insert(c.Name) deleteClaimNames.Insert(c.Name)
} }
pvcs := []api.PersistentVolumeClaim{} pvcs := []v1.PersistentVolumeClaim{}
for i, existing := range f.claims { for i, existing := range f.claims {
if deleteClaimNames.Has(existing.Name) { if deleteClaimNames.Has(existing.Name) {
deleteClaimNames.Delete(existing.Name) deleteClaimNames.Delete(existing.Name)
f.claimsDeleted++ f.claimsDeleted++
f.recorder.Eventf(pet.parent, api.EventTypeNormal, "SuccessfulDelete", "pvc: %v", existing.Name) f.recorder.Eventf(pet.parent, v1.EventTypeNormal, "SuccessfulDelete", "pvc: %v", existing.Name)
continue continue
} }
pvcs = append(pvcs, f.claims[i]) pvcs = append(pvcs, f.claims[i])
......
...@@ -23,9 +23,9 @@ import ( ...@@ -23,9 +23,9 @@ import (
"strings" "strings"
"github.com/golang/glog" "github.com/golang/glog"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/v1"
podapi "k8s.io/kubernetes/pkg/api/pod" podapi "k8s.io/kubernetes/pkg/api/v1/pod"
"k8s.io/kubernetes/pkg/apis/apps" apps "k8s.io/kubernetes/pkg/apis/apps/v1beta1"
"k8s.io/kubernetes/pkg/util/sets" "k8s.io/kubernetes/pkg/util/sets"
) )
...@@ -41,10 +41,10 @@ type identityMapper interface { ...@@ -41,10 +41,10 @@ type identityMapper interface {
// SetIdentity takes an id and assigns the given pet an identity based // SetIdentity takes an id and assigns the given pet an identity based
// on the stateful set spec. The is must be unique amongst members of the // on the stateful set spec. The is must be unique amongst members of the
// stateful set. // stateful set.
SetIdentity(id string, pet *api.Pod) SetIdentity(id string, pet *v1.Pod)
// Identity returns the identity of the pet. // Identity returns the identity of the pet.
Identity(pod *api.Pod) string Identity(pod *v1.Pod) string
} }
func newIdentityMappers(ps *apps.StatefulSet) []identityMapper { func newIdentityMappers(ps *apps.StatefulSet) []identityMapper {
...@@ -61,19 +61,19 @@ type NetworkIdentityMapper struct { ...@@ -61,19 +61,19 @@ type NetworkIdentityMapper struct {
} }
// SetIdentity sets network identity on the pet. // SetIdentity sets network identity on the pet.
func (n *NetworkIdentityMapper) SetIdentity(id string, pet *api.Pod) { func (n *NetworkIdentityMapper) SetIdentity(id string, pet *v1.Pod) {
pet.Annotations[podapi.PodHostnameAnnotation] = fmt.Sprintf("%v-%v", n.ps.Name, id) pet.Annotations[podapi.PodHostnameAnnotation] = fmt.Sprintf("%v-%v", n.ps.Name, id)
pet.Annotations[podapi.PodSubdomainAnnotation] = n.ps.Spec.ServiceName pet.Annotations[podapi.PodSubdomainAnnotation] = n.ps.Spec.ServiceName
return return
} }
// Identity returns the network identity of the pet. // Identity returns the network identity of the pet.
func (n *NetworkIdentityMapper) Identity(pet *api.Pod) string { func (n *NetworkIdentityMapper) Identity(pet *v1.Pod) string {
return n.String(pet) return n.String(pet)
} }
// String is a string function for the network identity of the pet. // String is a string function for the network identity of the pet.
func (n *NetworkIdentityMapper) String(pet *api.Pod) string { func (n *NetworkIdentityMapper) String(pet *v1.Pod) string {
hostname := pet.Annotations[podapi.PodHostnameAnnotation] hostname := pet.Annotations[podapi.PodHostnameAnnotation]
subdomain := pet.Annotations[podapi.PodSubdomainAnnotation] subdomain := pet.Annotations[podapi.PodSubdomainAnnotation]
return strings.Join([]string{hostname, subdomain, n.ps.Namespace}, ".") return strings.Join([]string{hostname, subdomain, n.ps.Namespace}, ".")
...@@ -85,13 +85,13 @@ type VolumeIdentityMapper struct { ...@@ -85,13 +85,13 @@ type VolumeIdentityMapper struct {
} }
// SetIdentity sets storge identity on the pet. // SetIdentity sets storge identity on the pet.
func (v *VolumeIdentityMapper) SetIdentity(id string, pet *api.Pod) { func (v *VolumeIdentityMapper) SetIdentity(id string, pet *v1.Pod) {
petVolumes := []api.Volume{} petVolumes := []v1.Volume{}
petClaims := v.GetClaims(id) petClaims := v.GetClaims(id)
// These volumes will all go down with the pod. If a name matches one of // These volumes will all go down with the pod. If a name matches one of
// the claims in the stateful set, it gets clobbered. // the claims in the stateful set, it gets clobbered.
podVolumes := map[string]api.Volume{} podVolumes := map[string]v1.Volume{}
for _, podVol := range pet.Spec.Volumes { for _, podVol := range pet.Spec.Volumes {
podVolumes[podVol.Name] = podVol podVolumes[podVol.Name] = podVol
} }
...@@ -105,10 +105,10 @@ func (v *VolumeIdentityMapper) SetIdentity(id string, pet *api.Pod) { ...@@ -105,10 +105,10 @@ func (v *VolumeIdentityMapper) SetIdentity(id string, pet *api.Pod) {
// TODO: Validate and reject this. // TODO: Validate and reject this.
glog.V(4).Infof("Overwriting existing volume source %v", podVol.Name) glog.V(4).Infof("Overwriting existing volume source %v", podVol.Name)
} }
newVol := api.Volume{ newVol := v1.Volume{
Name: name, Name: name,
VolumeSource: api.VolumeSource{ VolumeSource: v1.VolumeSource{
PersistentVolumeClaim: &api.PersistentVolumeClaimVolumeSource{ PersistentVolumeClaim: &v1.PersistentVolumeClaimVolumeSource{
ClaimName: claim.Name, ClaimName: claim.Name,
// TODO: Use source definition to set this value when we have one. // TODO: Use source definition to set this value when we have one.
ReadOnly: false, ReadOnly: false,
...@@ -129,13 +129,13 @@ func (v *VolumeIdentityMapper) SetIdentity(id string, pet *api.Pod) { ...@@ -129,13 +129,13 @@ func (v *VolumeIdentityMapper) SetIdentity(id string, pet *api.Pod) {
} }
// Identity returns the storage identity of the pet. // Identity returns the storage identity of the pet.
func (v *VolumeIdentityMapper) Identity(pet *api.Pod) string { func (v *VolumeIdentityMapper) Identity(pet *v1.Pod) string {
// TODO: Make this a hash? // TODO: Make this a hash?
return v.String(pet) return v.String(pet)
} }
// String is a string function for the network identity of the pet. // String is a string function for the network identity of the pet.
func (v *VolumeIdentityMapper) String(pet *api.Pod) string { func (v *VolumeIdentityMapper) String(pet *v1.Pod) string {
ids := []string{} ids := []string{}
petVols := sets.NewString() petVols := sets.NewString()
for _, petVol := range v.ps.Spec.VolumeClaimTemplates { for _, petVol := range v.ps.Spec.VolumeClaimTemplates {
...@@ -160,8 +160,8 @@ func (v *VolumeIdentityMapper) String(pet *api.Pod) string { ...@@ -160,8 +160,8 @@ func (v *VolumeIdentityMapper) String(pet *api.Pod) string {
// GetClaims returns the volume claims associated with the given id. // GetClaims returns the volume claims associated with the given id.
// The claims belong to the statefulset. The id should be unique within a statefulset. // The claims belong to the statefulset. The id should be unique within a statefulset.
func (v *VolumeIdentityMapper) GetClaims(id string) map[string]api.PersistentVolumeClaim { func (v *VolumeIdentityMapper) GetClaims(id string) map[string]v1.PersistentVolumeClaim {
petClaims := map[string]api.PersistentVolumeClaim{} petClaims := map[string]v1.PersistentVolumeClaim{}
for _, pvc := range v.ps.Spec.VolumeClaimTemplates { for _, pvc := range v.ps.Spec.VolumeClaimTemplates {
claim := pvc claim := pvc
// TODO: Name length checking in validation. // TODO: Name length checking in validation.
...@@ -177,12 +177,12 @@ func (v *VolumeIdentityMapper) GetClaims(id string) map[string]api.PersistentVol ...@@ -177,12 +177,12 @@ func (v *VolumeIdentityMapper) GetClaims(id string) map[string]api.PersistentVol
} }
// GetClaimsForPet returns the pvcs for the given pet. // GetClaimsForPet returns the pvcs for the given pet.
func (v *VolumeIdentityMapper) GetClaimsForPet(pet *api.Pod) []api.PersistentVolumeClaim { func (v *VolumeIdentityMapper) GetClaimsForPet(pet *v1.Pod) []v1.PersistentVolumeClaim {
// Strip out the "-(index)" from the pet name and use it to generate // Strip out the "-(index)" from the pet name and use it to generate
// claim names. // claim names.
id := strings.Split(pet.Name, "-") id := strings.Split(pet.Name, "-")
petID := id[len(id)-1] petID := id[len(id)-1]
pvcs := []api.PersistentVolumeClaim{} pvcs := []v1.PersistentVolumeClaim{}
for _, pvc := range v.GetClaims(petID) { for _, pvc := range v.GetClaims(petID) {
pvcs = append(pvcs, pvc) pvcs = append(pvcs, pvc)
} }
...@@ -196,25 +196,25 @@ type NameIdentityMapper struct { ...@@ -196,25 +196,25 @@ type NameIdentityMapper struct {
} }
// SetIdentity sets the pet namespace and name. // SetIdentity sets the pet namespace and name.
func (n *NameIdentityMapper) SetIdentity(id string, pet *api.Pod) { func (n *NameIdentityMapper) SetIdentity(id string, pet *v1.Pod) {
pet.Name = fmt.Sprintf("%v-%v", n.ps.Name, id) pet.Name = fmt.Sprintf("%v-%v", n.ps.Name, id)
pet.Namespace = n.ps.Namespace pet.Namespace = n.ps.Namespace
return return
} }
// Identity returns the name identity of the pet. // Identity returns the name identity of the pet.
func (n *NameIdentityMapper) Identity(pet *api.Pod) string { func (n *NameIdentityMapper) Identity(pet *v1.Pod) string {
return n.String(pet) return n.String(pet)
} }
// String is a string function for the name identity of the pet. // String is a string function for the name identity of the pet.
func (n *NameIdentityMapper) String(pet *api.Pod) string { func (n *NameIdentityMapper) String(pet *v1.Pod) string {
return fmt.Sprintf("%v/%v", pet.Namespace, pet.Name) return fmt.Sprintf("%v/%v", pet.Namespace, pet.Name)
} }
// identityHash computes a hash of the pet by running all the above identity // identityHash computes a hash of the pet by running all the above identity
// mappers. // mappers.
func identityHash(ps *apps.StatefulSet, pet *api.Pod) string { func identityHash(ps *apps.StatefulSet, pet *v1.Pod) string {
id := "" id := ""
for _, idMapper := range newIdentityMappers(ps) { for _, idMapper := range newIdentityMappers(ps) {
id += idMapper.Identity(pet) id += idMapper.Identity(pet)
...@@ -226,7 +226,7 @@ func identityHash(ps *apps.StatefulSet, pet *api.Pod) string { ...@@ -226,7 +226,7 @@ func identityHash(ps *apps.StatefulSet, pet *api.Pod) string {
// Note that this is *not* a literal copy, but a copy of the fields that // Note that this is *not* a literal copy, but a copy of the fields that
// contribute to the pet's identity. The returned boolean 'needsUpdate' will // contribute to the pet's identity. The returned boolean 'needsUpdate' will
// be false if the realPet already has the same identity as the expectedPet. // be false if the realPet already has the same identity as the expectedPet.
func copyPetID(realPet, expectedPet *pcb) (pod api.Pod, needsUpdate bool, err error) { func copyPetID(realPet, expectedPet *pcb) (pod v1.Pod, needsUpdate bool, err error) {
if realPet.pod == nil || expectedPet.pod == nil { if realPet.pod == nil || expectedPet.pod == nil {
return pod, false, fmt.Errorf("Need a valid to and from pet for copy") return pod, false, fmt.Errorf("Need a valid to and from pet for copy")
} }
......
...@@ -23,8 +23,8 @@ import ( ...@@ -23,8 +23,8 @@ import (
"testing" "testing"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/v1"
api_pod "k8s.io/kubernetes/pkg/api/pod" api_pod "k8s.io/kubernetes/pkg/api/v1/pod"
) )
func TestPetIDName(t *testing.T) { func TestPetIDName(t *testing.T) {
...@@ -150,10 +150,10 @@ func TestPetIDReset(t *testing.T) { ...@@ -150,10 +150,10 @@ func TestPetIDReset(t *testing.T) {
if identityHash(ps, firstPCB.pod) == identityHash(ps, secondPCB.pod) { if identityHash(ps, firstPCB.pod) == identityHash(ps, secondPCB.pod) {
t.Fatalf("Failed to generate uniquey identities:\n%+v\n%+v", firstPCB.pod.Spec, secondPCB.pod.Spec) t.Fatalf("Failed to generate uniquey identities:\n%+v\n%+v", firstPCB.pod.Spec, secondPCB.pod.Spec)
} }
userAdded := api.Volume{ userAdded := v1.Volume{
Name: "test", Name: "test",
VolumeSource: api.VolumeSource{ VolumeSource: v1.VolumeSource{
EmptyDir: &api.EmptyDirVolumeSource{Medium: api.StorageMediumMemory}, EmptyDir: &v1.EmptyDirVolumeSource{Medium: v1.StorageMediumMemory},
}, },
} }
firstPCB.pod.Spec.Volumes = append(firstPCB.pod.Spec.Volumes, userAdded) firstPCB.pod.Spec.Volumes = append(firstPCB.pod.Spec.Volumes, userAdded)
......
...@@ -21,8 +21,8 @@ import ( ...@@ -21,8 +21,8 @@ import (
"sort" "sort"
"github.com/golang/glog" "github.com/golang/glog"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apis/apps" apps "k8s.io/kubernetes/pkg/apis/apps/v1beta1"
"k8s.io/kubernetes/pkg/controller" "k8s.io/kubernetes/pkg/controller"
) )
...@@ -35,7 +35,7 @@ func newPCB(id string, ps *apps.StatefulSet) (*pcb, error) { ...@@ -35,7 +35,7 @@ func newPCB(id string, ps *apps.StatefulSet) (*pcb, error) {
for _, im := range newIdentityMappers(ps) { for _, im := range newIdentityMappers(ps) {
im.SetIdentity(id, petPod) im.SetIdentity(id, petPod)
} }
petPVCs := []api.PersistentVolumeClaim{} petPVCs := []v1.PersistentVolumeClaim{}
vMapper := &VolumeIdentityMapper{ps} vMapper := &VolumeIdentityMapper{ps}
for _, c := range vMapper.GetClaims(id) { for _, c := range vMapper.GetClaims(id) {
petPVCs = append(petPVCs, c) petPVCs = append(petPVCs, c)
...@@ -87,7 +87,7 @@ func (pt *petQueue) empty() bool { ...@@ -87,7 +87,7 @@ func (pt *petQueue) empty() bool {
} }
// NewPetQueue returns a queue for tracking pets // NewPetQueue returns a queue for tracking pets
func NewPetQueue(ps *apps.StatefulSet, podList []*api.Pod) *petQueue { func NewPetQueue(ps *apps.StatefulSet, podList []*v1.Pod) *petQueue {
pt := petQueue{pets: []*pcb{}, idMapper: &NameIdentityMapper{ps}} pt := petQueue{pets: []*pcb{}, idMapper: &NameIdentityMapper{ps}}
// Seed the queue with existing pets. Assume all pets are scheduled for // Seed the queue with existing pets. Assume all pets are scheduled for
// deletion, enqueuing a pet will "undelete" it. We always want to delete // deletion, enqueuing a pet will "undelete" it. We always want to delete
...@@ -118,7 +118,7 @@ type statefulSetIterator struct { ...@@ -118,7 +118,7 @@ type statefulSetIterator struct {
func (pi *statefulSetIterator) Next() bool { func (pi *statefulSetIterator) Next() bool {
var pet *pcb var pet *pcb
var err error var err error
if pi.petCount < pi.ps.Spec.Replicas { if pi.petCount < *(pi.ps.Spec.Replicas) {
pet, err = newPCB(fmt.Sprintf("%d", pi.petCount), pi.ps) pet, err = newPCB(fmt.Sprintf("%d", pi.petCount), pi.ps)
if err != nil { if err != nil {
pi.errs = append(pi.errs, err) pi.errs = append(pi.errs, err)
...@@ -139,7 +139,7 @@ func (pi *statefulSetIterator) Value() *pcb { ...@@ -139,7 +139,7 @@ func (pi *statefulSetIterator) Value() *pcb {
// NewStatefulSetIterator returns a new iterator. All pods in the given podList // NewStatefulSetIterator returns a new iterator. All pods in the given podList
// are used to seed the queue of the iterator. // are used to seed the queue of the iterator.
func NewStatefulSetIterator(ps *apps.StatefulSet, podList []*api.Pod) *statefulSetIterator { func NewStatefulSetIterator(ps *apps.StatefulSet, podList []*v1.Pod) *statefulSetIterator {
pi := &statefulSetIterator{ pi := &statefulSetIterator{
ps: ps, ps: ps,
queue: NewPetQueue(ps, podList), queue: NewPetQueue(ps, podList),
...@@ -150,7 +150,7 @@ func NewStatefulSetIterator(ps *apps.StatefulSet, podList []*api.Pod) *statefulS ...@@ -150,7 +150,7 @@ func NewStatefulSetIterator(ps *apps.StatefulSet, podList []*api.Pod) *statefulS
} }
// PodsByCreationTimestamp sorts a list of Pods by creation timestamp, using their names as a tie breaker. // PodsByCreationTimestamp sorts a list of Pods by creation timestamp, using their names as a tie breaker.
type PodsByCreationTimestamp []*api.Pod type PodsByCreationTimestamp []*v1.Pod
func (o PodsByCreationTimestamp) Len() int { return len(o) } func (o PodsByCreationTimestamp) Len() int { return len(o) }
func (o PodsByCreationTimestamp) Swap(i, j int) { o[i], o[j] = o[j], o[i] } func (o PodsByCreationTimestamp) Swap(i, j int) { o[i], o[j] = o[j], o[i] }
......
...@@ -21,14 +21,14 @@ import ( ...@@ -21,14 +21,14 @@ import (
"testing" "testing"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/util/sets" "k8s.io/kubernetes/pkg/util/sets"
) )
func TestPetQueueCreates(t *testing.T) { func TestPetQueueCreates(t *testing.T) {
replicas := 3 replicas := 3
ps := newStatefulSet(replicas) ps := newStatefulSet(replicas)
q := NewPetQueue(ps, []*api.Pod{}) q := NewPetQueue(ps, []*v1.Pod{})
for i := 0; i < replicas; i++ { for i := 0; i < replicas; i++ {
pet, _ := newPCB(fmt.Sprintf("%v", i), ps) pet, _ := newPCB(fmt.Sprintf("%v", i), ps)
q.enqueue(pet) q.enqueue(pet)
...@@ -107,7 +107,7 @@ func TestStatefulSetIteratorRelist(t *testing.T) { ...@@ -107,7 +107,7 @@ func TestStatefulSetIteratorRelist(t *testing.T) {
knownPods := newPodList(ps, 5) knownPods := newPodList(ps, 5)
for i := range knownPods { for i := range knownPods {
knownPods[i].Spec.NodeName = fmt.Sprintf("foo-node-%v", i) knownPods[i].Spec.NodeName = fmt.Sprintf("foo-node-%v", i)
knownPods[i].Status.Phase = api.PodRunning knownPods[i].Status.Phase = v1.PodRunning
} }
pi := NewStatefulSetIterator(ps, knownPods) pi := NewStatefulSetIterator(ps, knownPods)
...@@ -128,7 +128,7 @@ func TestStatefulSetIteratorRelist(t *testing.T) { ...@@ -128,7 +128,7 @@ func TestStatefulSetIteratorRelist(t *testing.T) {
} }
// Scale to 0 should delete all pods in system // Scale to 0 should delete all pods in system
ps.Spec.Replicas = 0 *(ps.Spec.Replicas) = 0
pi = NewStatefulSetIterator(ps, knownPods) pi = NewStatefulSetIterator(ps, knownPods)
i = 0 i = 0
for pi.Next() { for pi.Next() {
...@@ -143,7 +143,7 @@ func TestStatefulSetIteratorRelist(t *testing.T) { ...@@ -143,7 +143,7 @@ func TestStatefulSetIteratorRelist(t *testing.T) {
} }
// Relist with 0 replicas should no-op // Relist with 0 replicas should no-op
pi = NewStatefulSetIterator(ps, []*api.Pod{}) pi = NewStatefulSetIterator(ps, []*v1.Pod{})
if pi.Next() != false { if pi.Next() != false {
t.Errorf("Unexpected iteration without any replicas or pods in system") t.Errorf("Unexpected iteration without any replicas or pods in system")
} }
......
...@@ -20,10 +20,10 @@ import ( ...@@ -20,10 +20,10 @@ import (
"fmt" "fmt"
"strconv" "strconv"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors" "k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/apis/apps" "k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" apps "k8s.io/kubernetes/pkg/apis/apps/v1beta1"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5"
"k8s.io/kubernetes/pkg/client/record" "k8s.io/kubernetes/pkg/client/record"
"k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/runtime"
...@@ -52,9 +52,9 @@ const ( ...@@ -52,9 +52,9 @@ const (
// and parent fields to pass it around safely. // and parent fields to pass it around safely.
type pcb struct { type pcb struct {
// pod is the desired pet pod. // pod is the desired pet pod.
pod *api.Pod pod *v1.Pod
// pvcs is a list of desired persistent volume claims for the pet pod. // pvcs is a list of desired persistent volume claims for the pet pod.
pvcs []api.PersistentVolumeClaim pvcs []v1.PersistentVolumeClaim
// event is the lifecycle event associated with this update. // event is the lifecycle event associated with this update.
event petLifeCycleEvent event petLifeCycleEvent
// id is the identity index of this pet. // id is the identity index of this pet.
...@@ -106,7 +106,7 @@ func (p *petSyncer) Sync(pet *pcb) error { ...@@ -106,7 +106,7 @@ func (p *petSyncer) Sync(pet *pcb) error {
return err return err
} }
// if pet failed - we need to remove old one because of consistent naming // if pet failed - we need to remove old one because of consistent naming
if exists && realPet.pod.Status.Phase == api.PodFailed { if exists && realPet.pod.Status.Phase == v1.PodFailed {
glog.V(2).Infof("Deleting evicted pod %v/%v", realPet.pod.Namespace, realPet.pod.Name) glog.V(2).Infof("Deleting evicted pod %v/%v", realPet.pod.Namespace, realPet.pod.Name)
if err := p.petClient.Delete(realPet); err != nil { if err := p.petClient.Delete(realPet); err != nil {
return err return err
...@@ -175,7 +175,7 @@ type petClient interface { ...@@ -175,7 +175,7 @@ type petClient interface {
// apiServerPetClient is a statefulset aware Kubernetes client. // apiServerPetClient is a statefulset aware Kubernetes client.
type apiServerPetClient struct { type apiServerPetClient struct {
c internalclientset.Interface c clientset.Interface
recorder record.EventRecorder recorder record.EventRecorder
petHealthChecker petHealthChecker
} }
...@@ -242,12 +242,12 @@ func (p *apiServerPetClient) DeletePVCs(pet *pcb) error { ...@@ -242,12 +242,12 @@ func (p *apiServerPetClient) DeletePVCs(pet *pcb) error {
return nil return nil
} }
func (p *apiServerPetClient) getPVC(pvcName, pvcNamespace string) (*api.PersistentVolumeClaim, error) { func (p *apiServerPetClient) getPVC(pvcName, pvcNamespace string) (*v1.PersistentVolumeClaim, error) {
pvc, err := p.c.Core().PersistentVolumeClaims(pvcNamespace).Get(pvcName) pvc, err := p.c.Core().PersistentVolumeClaims(pvcNamespace).Get(pvcName)
return pvc, err return pvc, err
} }
func (p *apiServerPetClient) createPVC(pvc *api.PersistentVolumeClaim) error { func (p *apiServerPetClient) createPVC(pvc *v1.PersistentVolumeClaim) error {
_, err := p.c.Core().PersistentVolumeClaims(pvc.Namespace).Create(pvc) _, err := p.c.Core().PersistentVolumeClaims(pvc.Namespace).Create(pvc)
return err return err
} }
...@@ -280,17 +280,17 @@ func (p *apiServerPetClient) SyncPVCs(pet *pcb) error { ...@@ -280,17 +280,17 @@ func (p *apiServerPetClient) SyncPVCs(pet *pcb) error {
// event formats an event for the given runtime object. // event formats an event for the given runtime object.
func (p *apiServerPetClient) event(obj runtime.Object, reason, msg string, err error) { func (p *apiServerPetClient) event(obj runtime.Object, reason, msg string, err error) {
if err != nil { if err != nil {
p.recorder.Eventf(obj, api.EventTypeWarning, fmt.Sprintf("Failed%v", reason), fmt.Sprintf("%v, error: %v", msg, err)) p.recorder.Eventf(obj, v1.EventTypeWarning, fmt.Sprintf("Failed%v", reason), fmt.Sprintf("%v, error: %v", msg, err))
} else { } else {
p.recorder.Eventf(obj, api.EventTypeNormal, fmt.Sprintf("Successful%v", reason), msg) p.recorder.Eventf(obj, v1.EventTypeNormal, fmt.Sprintf("Successful%v", reason), msg)
} }
} }
// petHealthChecker is an interface to check pet health. It makes a boolean // petHealthChecker is an interface to check pet health. It makes a boolean
// decision based on the given pod. // decision based on the given pod.
type petHealthChecker interface { type petHealthChecker interface {
isHealthy(*api.Pod) bool isHealthy(*v1.Pod) bool
isDying(*api.Pod) bool isDying(*v1.Pod) bool
} }
// defaultPetHealthChecks does basic health checking. // defaultPetHealthChecks does basic health checking.
...@@ -299,11 +299,11 @@ type defaultPetHealthChecker struct{} ...@@ -299,11 +299,11 @@ type defaultPetHealthChecker struct{}
// isHealthy returns true if the pod is ready & running. If the pod has the // isHealthy returns true if the pod is ready & running. If the pod has the
// "pod.alpha.kubernetes.io/initialized" annotation set to "false", pod state is ignored. // "pod.alpha.kubernetes.io/initialized" annotation set to "false", pod state is ignored.
func (d *defaultPetHealthChecker) isHealthy(pod *api.Pod) bool { func (d *defaultPetHealthChecker) isHealthy(pod *v1.Pod) bool {
if pod == nil || pod.Status.Phase != api.PodRunning { if pod == nil || pod.Status.Phase != v1.PodRunning {
return false return false
} }
podReady := api.IsPodReady(pod) podReady := v1.IsPodReady(pod)
// User may have specified a pod readiness override through a debug annotation. // User may have specified a pod readiness override through a debug annotation.
initialized, ok := pod.Annotations[StatefulSetInitAnnotation] initialized, ok := pod.Annotations[StatefulSetInitAnnotation]
...@@ -321,6 +321,6 @@ func (d *defaultPetHealthChecker) isHealthy(pod *api.Pod) bool { ...@@ -321,6 +321,6 @@ func (d *defaultPetHealthChecker) isHealthy(pod *api.Pod) bool {
// isDying returns true if the pod has a non-nil deletion timestamp. Since the // isDying returns true if the pod has a non-nil deletion timestamp. Since the
// timestamp can only decrease, once this method returns true for a given pet, it // timestamp can only decrease, once this method returns true for a given pet, it
// will never return false. // will never return false.
func (d *defaultPetHealthChecker) isDying(pod *api.Pod) bool { func (d *defaultPetHealthChecker) isDying(pod *v1.Pod) bool {
return pod != nil && pod.DeletionTimestamp != nil return pod != nil && pod.DeletionTimestamp != nil
} }
...@@ -22,12 +22,12 @@ import ( ...@@ -22,12 +22,12 @@ import (
"sort" "sort"
"time" "time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apis/apps" "k8s.io/kubernetes/pkg/api/v1"
apps "k8s.io/kubernetes/pkg/apis/apps/v1beta1"
"k8s.io/kubernetes/pkg/client/cache" "k8s.io/kubernetes/pkg/client/cache"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" clientset "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5"
unversionedcore "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion" v1core "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5/typed/core/v1"
"k8s.io/kubernetes/pkg/client/record" "k8s.io/kubernetes/pkg/client/record"
"k8s.io/kubernetes/pkg/controller" "k8s.io/kubernetes/pkg/controller"
...@@ -52,7 +52,7 @@ const ( ...@@ -52,7 +52,7 @@ const (
// StatefulSetController controls statefulsets. // StatefulSetController controls statefulsets.
type StatefulSetController struct { type StatefulSetController struct {
kubeClient internalclientset.Interface kubeClient clientset.Interface
// newSyncer returns an interface capable of syncing a single pet. // newSyncer returns an interface capable of syncing a single pet.
// Abstracted out for testing. // Abstracted out for testing.
...@@ -83,11 +83,11 @@ type StatefulSetController struct { ...@@ -83,11 +83,11 @@ type StatefulSetController struct {
} }
// NewStatefulSetController creates a new statefulset controller. // NewStatefulSetController creates a new statefulset controller.
func NewStatefulSetController(podInformer cache.SharedIndexInformer, kubeClient internalclientset.Interface, resyncPeriod time.Duration) *StatefulSetController { func NewStatefulSetController(podInformer cache.SharedIndexInformer, kubeClient clientset.Interface, resyncPeriod time.Duration) *StatefulSetController {
eventBroadcaster := record.NewBroadcaster() eventBroadcaster := record.NewBroadcaster()
eventBroadcaster.StartLogging(glog.Infof) eventBroadcaster.StartLogging(glog.Infof)
eventBroadcaster.StartRecordingToSink(&unversionedcore.EventSinkImpl{Interface: kubeClient.Core().Events("")}) eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: kubeClient.Core().Events("")})
recorder := eventBroadcaster.NewRecorder(api.EventSource{Component: "statefulset"}) recorder := eventBroadcaster.NewRecorder(v1.EventSource{Component: "statefulset"})
pc := &apiServerPetClient{kubeClient, recorder, &defaultPetHealthChecker{}} pc := &apiServerPetClient{kubeClient, recorder, &defaultPetHealthChecker{}}
psc := &StatefulSetController{ psc := &StatefulSetController{
...@@ -112,11 +112,11 @@ func NewStatefulSetController(podInformer cache.SharedIndexInformer, kubeClient ...@@ -112,11 +112,11 @@ func NewStatefulSetController(podInformer cache.SharedIndexInformer, kubeClient
psc.psStore.Store, psc.psController = cache.NewInformer( psc.psStore.Store, psc.psController = cache.NewInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options api.ListOptions) (runtime.Object, error) { ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return psc.kubeClient.Apps().StatefulSets(api.NamespaceAll).List(options) return psc.kubeClient.Apps().StatefulSets(v1.NamespaceAll).List(options)
}, },
WatchFunc: func(options api.ListOptions) (watch.Interface, error) { WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return psc.kubeClient.Apps().StatefulSets(api.NamespaceAll).Watch(options) return psc.kubeClient.Apps().StatefulSets(v1.NamespaceAll).Watch(options)
}, },
}, },
&apps.StatefulSet{}, &apps.StatefulSet{},
...@@ -156,7 +156,7 @@ func (psc *StatefulSetController) Run(workers int, stopCh <-chan struct{}) { ...@@ -156,7 +156,7 @@ func (psc *StatefulSetController) Run(workers int, stopCh <-chan struct{}) {
// addPod adds the statefulset for the pod to the sync queue // addPod adds the statefulset for the pod to the sync queue
func (psc *StatefulSetController) addPod(obj interface{}) { func (psc *StatefulSetController) addPod(obj interface{}) {
pod := obj.(*api.Pod) pod := obj.(*v1.Pod)
glog.V(4).Infof("Pod %s created, labels: %+v", pod.Name, pod.Labels) glog.V(4).Infof("Pod %s created, labels: %+v", pod.Name, pod.Labels)
ps := psc.getStatefulSetForPod(pod) ps := psc.getStatefulSetForPod(pod)
if ps == nil { if ps == nil {
...@@ -168,8 +168,8 @@ func (psc *StatefulSetController) addPod(obj interface{}) { ...@@ -168,8 +168,8 @@ func (psc *StatefulSetController) addPod(obj interface{}) {
// updatePod adds the statefulset for the current and old pods to the sync queue. // updatePod adds the statefulset for the current and old pods to the sync queue.
// If the labels of the pod didn't change, this method enqueues a single statefulset. // If the labels of the pod didn't change, this method enqueues a single statefulset.
func (psc *StatefulSetController) updatePod(old, cur interface{}) { func (psc *StatefulSetController) updatePod(old, cur interface{}) {
curPod := cur.(*api.Pod) curPod := cur.(*v1.Pod)
oldPod := old.(*api.Pod) oldPod := old.(*v1.Pod)
if curPod.ResourceVersion == oldPod.ResourceVersion { if curPod.ResourceVersion == oldPod.ResourceVersion {
// Periodic resync will send update events for all known pods. // Periodic resync will send update events for all known pods.
// Two different versions of the same pod will always have different RVs. // Two different versions of the same pod will always have different RVs.
...@@ -189,7 +189,7 @@ func (psc *StatefulSetController) updatePod(old, cur interface{}) { ...@@ -189,7 +189,7 @@ func (psc *StatefulSetController) updatePod(old, cur interface{}) {
// deletePod enqueues the statefulset for the pod accounting for deletion tombstones. // deletePod enqueues the statefulset for the pod accounting for deletion tombstones.
func (psc *StatefulSetController) deletePod(obj interface{}) { func (psc *StatefulSetController) deletePod(obj interface{}) {
pod, ok := obj.(*api.Pod) pod, ok := obj.(*v1.Pod)
// When a delete is dropped, the relist will notice a pod in the store not // When a delete is dropped, the relist will notice a pod in the store not
// in the list, leading to the insertion of a tombstone object which contains // in the list, leading to the insertion of a tombstone object which contains
...@@ -201,7 +201,7 @@ func (psc *StatefulSetController) deletePod(obj interface{}) { ...@@ -201,7 +201,7 @@ func (psc *StatefulSetController) deletePod(obj interface{}) {
glog.Errorf("couldn't get object from tombstone %+v", obj) glog.Errorf("couldn't get object from tombstone %+v", obj)
return return
} }
pod, ok = tombstone.Obj.(*api.Pod) pod, ok = tombstone.Obj.(*v1.Pod)
if !ok { if !ok {
glog.Errorf("tombstone contained object that is not a pod %+v", obj) glog.Errorf("tombstone contained object that is not a pod %+v", obj)
return return
...@@ -214,18 +214,18 @@ func (psc *StatefulSetController) deletePod(obj interface{}) { ...@@ -214,18 +214,18 @@ func (psc *StatefulSetController) deletePod(obj interface{}) {
} }
// getPodsForStatefulSets returns the pods that match the selectors of the given statefulset. // getPodsForStatefulSets returns the pods that match the selectors of the given statefulset.
func (psc *StatefulSetController) getPodsForStatefulSet(ps *apps.StatefulSet) ([]*api.Pod, error) { func (psc *StatefulSetController) getPodsForStatefulSet(ps *apps.StatefulSet) ([]*v1.Pod, error) {
// TODO: Do we want the statefulset to fight with RCs? check parent statefulset annoation, or name prefix? // TODO: Do we want the statefulset to fight with RCs? check parent statefulset annoation, or name prefix?
sel, err := unversioned.LabelSelectorAsSelector(ps.Spec.Selector) sel, err := unversioned.LabelSelectorAsSelector(ps.Spec.Selector)
if err != nil { if err != nil {
return []*api.Pod{}, err return []*v1.Pod{}, err
} }
pods, err := psc.podStore.Pods(ps.Namespace).List(sel) pods, err := psc.podStore.Pods(ps.Namespace).List(sel)
if err != nil { if err != nil {
return []*api.Pod{}, err return []*v1.Pod{}, err
} }
// TODO: Do we need to copy? // TODO: Do we need to copy?
result := make([]*api.Pod, 0, len(pods)) result := make([]*v1.Pod, 0, len(pods))
for i := range pods { for i := range pods {
result = append(result, &(*pods[i])) result = append(result, &(*pods[i]))
} }
...@@ -233,7 +233,7 @@ func (psc *StatefulSetController) getPodsForStatefulSet(ps *apps.StatefulSet) ([ ...@@ -233,7 +233,7 @@ func (psc *StatefulSetController) getPodsForStatefulSet(ps *apps.StatefulSet) ([
} }
// getStatefulSetForPod returns the pet set managing the given pod. // getStatefulSetForPod returns the pet set managing the given pod.
func (psc *StatefulSetController) getStatefulSetForPod(pod *api.Pod) *apps.StatefulSet { func (psc *StatefulSetController) getStatefulSetForPod(pod *v1.Pod) *apps.StatefulSet {
ps, err := psc.psStore.GetPodStatefulSets(pod) ps, err := psc.psStore.GetPodStatefulSets(pod)
if err != nil { if err != nil {
glog.V(4).Infof("No StatefulSets found for pod %v, StatefulSet controller will avoid syncing", pod.Name) glog.V(4).Infof("No StatefulSets found for pod %v, StatefulSet controller will avoid syncing", pod.Name)
...@@ -320,7 +320,7 @@ func (psc *StatefulSetController) Sync(key string) error { ...@@ -320,7 +320,7 @@ func (psc *StatefulSetController) Sync(key string) error {
} }
// syncStatefulSet syncs a tuple of (statefulset, pets). // syncStatefulSet syncs a tuple of (statefulset, pets).
func (psc *StatefulSetController) syncStatefulSet(ps *apps.StatefulSet, pets []*api.Pod) (int, error) { func (psc *StatefulSetController) syncStatefulSet(ps *apps.StatefulSet, pets []*v1.Pod) (int, error) {
glog.V(2).Infof("Syncing StatefulSet %v/%v with %d pods", ps.Namespace, ps.Name, len(pets)) glog.V(2).Infof("Syncing StatefulSet %v/%v with %d pods", ps.Namespace, ps.Name, len(pets))
it := NewStatefulSetIterator(ps, pets) it := NewStatefulSetIterator(ps, pets)
......
...@@ -22,12 +22,12 @@ import ( ...@@ -22,12 +22,12 @@ import (
"reflect" "reflect"
"testing" "testing"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apis/apps" apps "k8s.io/kubernetes/pkg/apis/apps/v1beta1"
"k8s.io/kubernetes/pkg/client/cache" "k8s.io/kubernetes/pkg/client/cache"
fake_internal "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake" fake_internal "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5/fake"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/apps/internalversion" "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5/typed/apps/v1beta1"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/apps/internalversion/fake" "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5/typed/apps/v1beta1/fake"
"k8s.io/kubernetes/pkg/controller" "k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/pkg/util/errors" "k8s.io/kubernetes/pkg/util/errors"
) )
...@@ -50,7 +50,7 @@ func checkPets(ps *apps.StatefulSet, creates, deletes int, fc *fakePetClient, t ...@@ -50,7 +50,7 @@ func checkPets(ps *apps.StatefulSet, creates, deletes int, fc *fakePetClient, t
if fc.petsCreated != creates || fc.petsDeleted != deletes { if fc.petsCreated != creates || fc.petsDeleted != deletes {
t.Errorf("Found (creates: %d, deletes: %d), expected (creates: %d, deletes: %d)", fc.petsCreated, fc.petsDeleted, creates, deletes) t.Errorf("Found (creates: %d, deletes: %d), expected (creates: %d, deletes: %d)", fc.petsCreated, fc.petsDeleted, creates, deletes)
} }
gotClaims := map[string]api.PersistentVolumeClaim{} gotClaims := map[string]v1.PersistentVolumeClaim{}
for _, pvc := range fc.claims { for _, pvc := range fc.claims {
gotClaims[pvc.Name] = pvc gotClaims[pvc.Name] = pvc
} }
...@@ -88,7 +88,7 @@ func scaleStatefulSet(t *testing.T, ps *apps.StatefulSet, psc *StatefulSetContro ...@@ -88,7 +88,7 @@ func scaleStatefulSet(t *testing.T, ps *apps.StatefulSet, psc *StatefulSetContro
} }
func saturateStatefulSet(t *testing.T, ps *apps.StatefulSet, psc *StatefulSetController, fc *fakePetClient) { func saturateStatefulSet(t *testing.T, ps *apps.StatefulSet, psc *StatefulSetController, fc *fakePetClient) {
err := scaleStatefulSet(t, ps, psc, fc, int(ps.Spec.Replicas)) err := scaleStatefulSet(t, ps, psc, fc, int(*(ps.Spec.Replicas)))
if err != nil { if err != nil {
t.Errorf("Error scaleStatefulSet: %v", err) t.Errorf("Error scaleStatefulSet: %v", err)
} }
...@@ -119,7 +119,7 @@ func TestStatefulSetControllerDeletes(t *testing.T) { ...@@ -119,7 +119,7 @@ func TestStatefulSetControllerDeletes(t *testing.T) {
// Drain // Drain
errs := []error{} errs := []error{}
ps.Spec.Replicas = 0 *(ps.Spec.Replicas) = 0
knownPods := fc.getPodList() knownPods := fc.getPodList()
for i := replicas - 1; i >= 0; i-- { for i := replicas - 1; i >= 0; i-- {
if len(fc.pets) != i+1 { if len(fc.pets) != i+1 {
...@@ -143,7 +143,7 @@ func TestStatefulSetControllerRespectsTermination(t *testing.T) { ...@@ -143,7 +143,7 @@ func TestStatefulSetControllerRespectsTermination(t *testing.T) {
saturateStatefulSet(t, ps, psc, fc) saturateStatefulSet(t, ps, psc, fc)
fc.setDeletionTimestamp(replicas - 1) fc.setDeletionTimestamp(replicas - 1)
ps.Spec.Replicas = 2 *(ps.Spec.Replicas) = 2
_, err := psc.syncStatefulSet(ps, fc.getPodList()) _, err := psc.syncStatefulSet(ps, fc.getPodList())
if err != nil { if err != nil {
t.Errorf("Error syncing StatefulSet: %v", err) t.Errorf("Error syncing StatefulSet: %v", err)
...@@ -169,7 +169,7 @@ func TestStatefulSetControllerRespectsOrder(t *testing.T) { ...@@ -169,7 +169,7 @@ func TestStatefulSetControllerRespectsOrder(t *testing.T) {
saturateStatefulSet(t, ps, psc, fc) saturateStatefulSet(t, ps, psc, fc)
errs := []error{} errs := []error{}
ps.Spec.Replicas = 0 *(ps.Spec.Replicas) = 0
// Shuffle known list and check that pets are deleted in reverse // Shuffle known list and check that pets are deleted in reverse
knownPods := fc.getPodList() knownPods := fc.getPodList()
for i := range knownPods { for i := range knownPods {
...@@ -285,16 +285,16 @@ type fakeClient struct { ...@@ -285,16 +285,16 @@ type fakeClient struct {
statefulsetClient *fakeStatefulSetClient statefulsetClient *fakeStatefulSetClient
} }
func (c *fakeClient) Apps() internalversion.AppsInterface { func (c *fakeClient) Apps() v1beta1.AppsV1beta1Interface {
return &fakeApps{c, &fake.FakeApps{}} return &fakeApps{c, &fake.FakeAppsV1beta1{}}
} }
type fakeApps struct { type fakeApps struct {
*fakeClient *fakeClient
*fake.FakeApps *fake.FakeAppsV1beta1
} }
func (c *fakeApps) StatefulSets(namespace string) internalversion.StatefulSetInterface { func (c *fakeApps) StatefulSets(namespace string) v1beta1.StatefulSetInterface {
c.statefulsetClient.Namespace = namespace c.statefulsetClient.Namespace = namespace
return c.statefulsetClient return c.statefulsetClient
} }
......
...@@ -20,10 +20,10 @@ import ( ...@@ -20,10 +20,10 @@ import (
"fmt" "fmt"
"sync" "sync"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apis/apps" apps "k8s.io/kubernetes/pkg/apis/apps/v1beta1"
"k8s.io/kubernetes/pkg/client/cache" "k8s.io/kubernetes/pkg/client/cache"
appsclientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/apps/internalversion" appsclientset "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5/typed/apps/v1beta1"
"k8s.io/kubernetes/pkg/controller" "k8s.io/kubernetes/pkg/controller"
"github.com/golang/glog" "github.com/golang/glog"
...@@ -51,7 +51,7 @@ func updatePetCount(psClient appsclientset.StatefulSetsGetter, ps apps.StatefulS ...@@ -51,7 +51,7 @@ func updatePetCount(psClient appsclientset.StatefulSetsGetter, ps apps.StatefulS
var getErr error var getErr error
for i, ps := 0, &ps; ; i++ { for i, ps := 0, &ps; ; i++ {
glog.V(4).Infof(fmt.Sprintf("Updating replica count for StatefulSet: %s/%s, ", ps.Namespace, ps.Name) + glog.V(4).Infof(fmt.Sprintf("Updating replica count for StatefulSet: %s/%s, ", ps.Namespace, ps.Name) +
fmt.Sprintf("replicas %d->%d (need %d), ", ps.Status.Replicas, numPets, ps.Spec.Replicas)) fmt.Sprintf("replicas %d->%d (need %d), ", ps.Status.Replicas, numPets, *(ps.Spec.Replicas)))
ps.Status = apps.StatefulSetStatus{Replicas: int32(numPets)} ps.Status = apps.StatefulSetStatus{Replicas: int32(numPets)}
_, updateErr = psClient.StatefulSets(ps.Namespace).UpdateStatus(ps) _, updateErr = psClient.StatefulSets(ps.Namespace).UpdateStatus(ps)
...@@ -72,7 +72,7 @@ type unhealthyPetTracker struct { ...@@ -72,7 +72,7 @@ type unhealthyPetTracker struct {
} }
// Get returns a previously recorded blocking pet for the given statefulset. // Get returns a previously recorded blocking pet for the given statefulset.
func (u *unhealthyPetTracker) Get(ps *apps.StatefulSet, knownPets []*api.Pod) (*pcb, error) { func (u *unhealthyPetTracker) Get(ps *apps.StatefulSet, knownPets []*v1.Pod) (*pcb, error) {
u.storeLock.Lock() u.storeLock.Lock()
defer u.storeLock.Unlock() defer u.storeLock.Unlock()
......
...@@ -21,11 +21,11 @@ import ( ...@@ -21,11 +21,11 @@ import (
"net/http/httptest" "net/http/httptest"
"testing" "testing"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/testapi" "k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apimachinery/registered" "k8s.io/kubernetes/pkg/apimachinery/registered"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" clientset "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake" "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5/fake"
"k8s.io/kubernetes/pkg/client/restclient" "k8s.io/kubernetes/pkg/client/restclient"
"k8s.io/kubernetes/pkg/client/testing/core" "k8s.io/kubernetes/pkg/client/testing/core"
"k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/runtime"
...@@ -39,10 +39,10 @@ func newPetClient(client *clientset.Clientset) *apiServerPetClient { ...@@ -39,10 +39,10 @@ func newPetClient(client *clientset.Clientset) *apiServerPetClient {
} }
func makeTwoDifferntPCB() (pcb1, pcb2 *pcb) { func makeTwoDifferntPCB() (pcb1, pcb2 *pcb) {
userAdded := api.Volume{ userAdded := v1.Volume{
Name: "test", Name: "test",
VolumeSource: api.VolumeSource{ VolumeSource: v1.VolumeSource{
EmptyDir: &api.EmptyDirVolumeSource{Medium: api.StorageMediumMemory}, EmptyDir: &v1.EmptyDirVolumeSource{Medium: v1.StorageMediumMemory},
}, },
} }
ps := newStatefulSet(2) ps := newStatefulSet(2)
...@@ -88,14 +88,14 @@ func TestUpdatePetWithoutRetry(t *testing.T) { ...@@ -88,14 +88,14 @@ func TestUpdatePetWithoutRetry(t *testing.T) {
} }
for k, tc := range testCases { for k, tc := range testCases {
body := runtime.EncodeOrDie(testapi.Default.Codec(), &api.Pod{ObjectMeta: api.ObjectMeta{Name: "empty_pod"}}) body := runtime.EncodeOrDie(testapi.Default.Codec(), &v1.Pod{ObjectMeta: v1.ObjectMeta{Name: "empty_pod"}})
fakeHandler := utiltesting.FakeHandler{ fakeHandler := utiltesting.FakeHandler{
StatusCode: 200, StatusCode: 200,
ResponseBody: string(body), ResponseBody: string(body),
} }
testServer := httptest.NewServer(&fakeHandler) testServer := httptest.NewServer(&fakeHandler)
client := clientset.NewForConfigOrDie(&restclient.Config{Host: testServer.URL, ContentConfig: restclient.ContentConfig{GroupVersion: &registered.GroupOrDie(api.GroupName).GroupVersion}}) client := clientset.NewForConfigOrDie(&restclient.Config{Host: testServer.URL, ContentConfig: restclient.ContentConfig{GroupVersion: &registered.GroupOrDie(v1.GroupName).GroupVersion}})
petClient := newPetClient(client) petClient := newPetClient(client)
err := petClient.Update(tc.realPet, tc.expectedPet) err := petClient.Update(tc.realPet, tc.expectedPet)
...@@ -115,7 +115,7 @@ func TestUpdatePetWithFailure(t *testing.T) { ...@@ -115,7 +115,7 @@ func TestUpdatePetWithFailure(t *testing.T) {
testServer := httptest.NewServer(&fakeHandler) testServer := httptest.NewServer(&fakeHandler)
defer testServer.Close() defer testServer.Close()
client := clientset.NewForConfigOrDie(&restclient.Config{Host: testServer.URL, ContentConfig: restclient.ContentConfig{GroupVersion: &registered.GroupOrDie(api.GroupName).GroupVersion}}) client := clientset.NewForConfigOrDie(&restclient.Config{Host: testServer.URL, ContentConfig: restclient.ContentConfig{GroupVersion: &registered.GroupOrDie(v1.GroupName).GroupVersion}})
petClient := newPetClient(client) petClient := newPetClient(client)
pcb1, pcb2 := makeTwoDifferntPCB() pcb1, pcb2 := makeTwoDifferntPCB()
......
...@@ -27,15 +27,14 @@ import ( ...@@ -27,15 +27,14 @@ import (
"testing" "testing"
"time" "time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/resource" "k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/v1" "k8s.io/kubernetes/pkg/api/v1"
_ "k8s.io/kubernetes/pkg/apimachinery/registered" _ "k8s.io/kubernetes/pkg/apimachinery/registered"
"k8s.io/kubernetes/pkg/apis/autoscaling" autoscaling "k8s.io/kubernetes/pkg/apis/autoscaling/v1"
"k8s.io/kubernetes/pkg/apis/extensions" extensions "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake" "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5/fake"
unversionedcore "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion" v1core "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5/typed/core/v1"
"k8s.io/kubernetes/pkg/client/record" "k8s.io/kubernetes/pkg/client/record"
"k8s.io/kubernetes/pkg/client/restclient" "k8s.io/kubernetes/pkg/client/restclient"
"k8s.io/kubernetes/pkg/client/testing/core" "k8s.io/kubernetes/pkg/client/testing/core"
...@@ -84,7 +83,7 @@ type testCase struct { ...@@ -84,7 +83,7 @@ type testCase struct {
verifyCPUCurrent bool verifyCPUCurrent bool
reportedLevels []uint64 reportedLevels []uint64
reportedCPURequests []resource.Quantity reportedCPURequests []resource.Quantity
reportedPodReadiness []api.ConditionStatus reportedPodReadiness []v1.ConditionStatus
cmTarget *extensions.CustomMetricTargetList cmTarget *extensions.CustomMetricTargetList
scaleUpdated bool scaleUpdated bool
statusUpdated bool statusUpdated bool
...@@ -151,7 +150,7 @@ func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset { ...@@ -151,7 +150,7 @@ func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset {
obj := &autoscaling.HorizontalPodAutoscalerList{ obj := &autoscaling.HorizontalPodAutoscalerList{
Items: []autoscaling.HorizontalPodAutoscaler{ Items: []autoscaling.HorizontalPodAutoscaler{
{ {
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Name: hpaName, Name: hpaName,
Namespace: namespace, Namespace: namespace,
SelfLink: "experimental/v1/namespaces/" + namespace + "/horizontalpodautoscalers/" + hpaName, SelfLink: "experimental/v1/namespaces/" + namespace + "/horizontalpodautoscalers/" + hpaName,
...@@ -192,7 +191,7 @@ func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset { ...@@ -192,7 +191,7 @@ func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset {
defer tc.Unlock() defer tc.Unlock()
obj := &extensions.Scale{ obj := &extensions.Scale{
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Name: tc.resource.name, Name: tc.resource.name,
Namespace: namespace, Namespace: namespace,
}, },
...@@ -201,7 +200,7 @@ func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset { ...@@ -201,7 +200,7 @@ func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset {
}, },
Status: extensions.ScaleStatus{ Status: extensions.ScaleStatus{
Replicas: tc.initialReplicas, Replicas: tc.initialReplicas,
Selector: selector, Selector: selector.MatchLabels,
}, },
} }
return true, obj, nil return true, obj, nil
...@@ -212,7 +211,7 @@ func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset { ...@@ -212,7 +211,7 @@ func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset {
defer tc.Unlock() defer tc.Unlock()
obj := &extensions.Scale{ obj := &extensions.Scale{
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Name: tc.resource.name, Name: tc.resource.name,
Namespace: namespace, Namespace: namespace,
}, },
...@@ -221,7 +220,7 @@ func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset { ...@@ -221,7 +220,7 @@ func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset {
}, },
Status: extensions.ScaleStatus{ Status: extensions.ScaleStatus{
Replicas: tc.initialReplicas, Replicas: tc.initialReplicas,
Selector: selector, Selector: selector.MatchLabels,
}, },
} }
return true, obj, nil return true, obj, nil
...@@ -232,7 +231,7 @@ func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset { ...@@ -232,7 +231,7 @@ func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset {
defer tc.Unlock() defer tc.Unlock()
obj := &extensions.Scale{ obj := &extensions.Scale{
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Name: tc.resource.name, Name: tc.resource.name,
Namespace: namespace, Namespace: namespace,
}, },
...@@ -241,7 +240,7 @@ func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset { ...@@ -241,7 +240,7 @@ func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset {
}, },
Status: extensions.ScaleStatus{ Status: extensions.ScaleStatus{
Replicas: tc.initialReplicas, Replicas: tc.initialReplicas,
Selector: selector, Selector: selector.MatchLabels,
}, },
} }
return true, obj, nil return true, obj, nil
...@@ -251,36 +250,36 @@ func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset { ...@@ -251,36 +250,36 @@ func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset {
tc.Lock() tc.Lock()
defer tc.Unlock() defer tc.Unlock()
obj := &api.PodList{} obj := &v1.PodList{}
for i := 0; i < len(tc.reportedCPURequests); i++ { for i := 0; i < len(tc.reportedCPURequests); i++ {
podReadiness := api.ConditionTrue podReadiness := v1.ConditionTrue
if tc.reportedPodReadiness != nil { if tc.reportedPodReadiness != nil {
podReadiness = tc.reportedPodReadiness[i] podReadiness = tc.reportedPodReadiness[i]
} }
podName := fmt.Sprintf("%s-%d", podNamePrefix, i) podName := fmt.Sprintf("%s-%d", podNamePrefix, i)
pod := api.Pod{ pod := v1.Pod{
Status: api.PodStatus{ Status: v1.PodStatus{
Phase: api.PodRunning, Phase: v1.PodRunning,
Conditions: []api.PodCondition{ Conditions: []v1.PodCondition{
{ {
Type: api.PodReady, Type: v1.PodReady,
Status: podReadiness, Status: podReadiness,
}, },
}, },
}, },
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Name: podName, Name: podName,
Namespace: namespace, Namespace: namespace,
Labels: map[string]string{ Labels: map[string]string{
"name": podNamePrefix, "name": podNamePrefix,
}, },
}, },
Spec: api.PodSpec{ Spec: v1.PodSpec{
Containers: []api.Container{ Containers: []v1.Container{
{ {
Resources: api.ResourceRequirements{ Resources: v1.ResourceRequirements{
Requests: api.ResourceList{ Requests: v1.ResourceList{
api.ResourceCPU: tc.reportedCPURequests[i], v1.ResourceCPU: tc.reportedCPURequests[i],
}, },
}, },
}, },
...@@ -420,7 +419,7 @@ func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset { ...@@ -420,7 +419,7 @@ func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset {
tc.Lock() tc.Lock()
defer tc.Unlock() defer tc.Unlock()
obj := action.(core.CreateAction).GetObject().(*api.Event) obj := action.(core.CreateAction).GetObject().(*v1.Event)
if tc.verifyEvents { if tc.verifyEvents {
switch obj.Reason { switch obj.Reason {
case "SuccessfulRescale": case "SuccessfulRescale":
...@@ -460,8 +459,8 @@ func (tc *testCase) runTest(t *testing.T) { ...@@ -460,8 +459,8 @@ func (tc *testCase) runTest(t *testing.T) {
metricsClient := metrics.NewHeapsterMetricsClient(testClient, metrics.DefaultHeapsterNamespace, metrics.DefaultHeapsterScheme, metrics.DefaultHeapsterService, metrics.DefaultHeapsterPort) metricsClient := metrics.NewHeapsterMetricsClient(testClient, metrics.DefaultHeapsterNamespace, metrics.DefaultHeapsterScheme, metrics.DefaultHeapsterService, metrics.DefaultHeapsterPort)
broadcaster := record.NewBroadcasterForTests(0) broadcaster := record.NewBroadcasterForTests(0)
broadcaster.StartRecordingToSink(&unversionedcore.EventSinkImpl{Interface: testClient.Core().Events("")}) broadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: testClient.Core().Events("")})
recorder := broadcaster.NewRecorder(api.EventSource{Component: "horizontal-pod-autoscaler"}) recorder := broadcaster.NewRecorder(v1.EventSource{Component: "horizontal-pod-autoscaler"})
replicaCalc := &ReplicaCalculator{ replicaCalc := &ReplicaCalculator{
metricsClient: metricsClient, metricsClient: metricsClient,
...@@ -574,7 +573,7 @@ func TestScaleUpUnreadyLessScale(t *testing.T) { ...@@ -574,7 +573,7 @@ func TestScaleUpUnreadyLessScale(t *testing.T) {
verifyCPUCurrent: true, verifyCPUCurrent: true,
reportedLevels: []uint64{300, 500, 700}, reportedLevels: []uint64{300, 500, 700},
reportedCPURequests: []resource.Quantity{resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0")}, reportedCPURequests: []resource.Quantity{resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0")},
reportedPodReadiness: []api.ConditionStatus{api.ConditionFalse, api.ConditionTrue, api.ConditionTrue}, reportedPodReadiness: []v1.ConditionStatus{v1.ConditionFalse, v1.ConditionTrue, v1.ConditionTrue},
useMetricsApi: true, useMetricsApi: true,
} }
tc.runTest(t) tc.runTest(t)
...@@ -591,7 +590,7 @@ func TestScaleUpUnreadyNoScale(t *testing.T) { ...@@ -591,7 +590,7 @@ func TestScaleUpUnreadyNoScale(t *testing.T) {
verifyCPUCurrent: true, verifyCPUCurrent: true,
reportedLevels: []uint64{400, 500, 700}, reportedLevels: []uint64{400, 500, 700},
reportedCPURequests: []resource.Quantity{resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0")}, reportedCPURequests: []resource.Quantity{resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0")},
reportedPodReadiness: []api.ConditionStatus{api.ConditionTrue, api.ConditionFalse, api.ConditionFalse}, reportedPodReadiness: []v1.ConditionStatus{v1.ConditionTrue, v1.ConditionFalse, v1.ConditionFalse},
useMetricsApi: true, useMetricsApi: true,
} }
tc.runTest(t) tc.runTest(t)
...@@ -670,7 +669,7 @@ func TestScaleUpCMUnreadyLessScale(t *testing.T) { ...@@ -670,7 +669,7 @@ func TestScaleUpCMUnreadyLessScale(t *testing.T) {
}}, }},
}, },
reportedLevels: []uint64{50, 10, 30}, reportedLevels: []uint64{50, 10, 30},
reportedPodReadiness: []api.ConditionStatus{api.ConditionTrue, api.ConditionTrue, api.ConditionFalse}, reportedPodReadiness: []v1.ConditionStatus{v1.ConditionTrue, v1.ConditionTrue, v1.ConditionFalse},
reportedCPURequests: []resource.Quantity{resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0")}, reportedCPURequests: []resource.Quantity{resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0")},
} }
tc.runTest(t) tc.runTest(t)
...@@ -690,7 +689,7 @@ func TestScaleUpCMUnreadyNoScaleWouldScaleDown(t *testing.T) { ...@@ -690,7 +689,7 @@ func TestScaleUpCMUnreadyNoScaleWouldScaleDown(t *testing.T) {
}}, }},
}, },
reportedLevels: []uint64{50, 15, 30}, reportedLevels: []uint64{50, 15, 30},
reportedPodReadiness: []api.ConditionStatus{api.ConditionFalse, api.ConditionTrue, api.ConditionFalse}, reportedPodReadiness: []v1.ConditionStatus{v1.ConditionFalse, v1.ConditionTrue, v1.ConditionFalse},
reportedCPURequests: []resource.Quantity{resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0")}, reportedCPURequests: []resource.Quantity{resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0")},
} }
tc.runTest(t) tc.runTest(t)
...@@ -755,7 +754,7 @@ func TestScaleDownIgnoresUnreadyPods(t *testing.T) { ...@@ -755,7 +754,7 @@ func TestScaleDownIgnoresUnreadyPods(t *testing.T) {
reportedLevels: []uint64{100, 300, 500, 250, 250}, reportedLevels: []uint64{100, 300, 500, 250, 250},
reportedCPURequests: []resource.Quantity{resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0")}, reportedCPURequests: []resource.Quantity{resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0")},
useMetricsApi: true, useMetricsApi: true,
reportedPodReadiness: []api.ConditionStatus{api.ConditionTrue, api.ConditionTrue, api.ConditionTrue, api.ConditionFalse, api.ConditionFalse}, reportedPodReadiness: []v1.ConditionStatus{v1.ConditionTrue, v1.ConditionTrue, v1.ConditionTrue, v1.ConditionFalse, v1.ConditionFalse},
} }
tc.runTest(t) tc.runTest(t)
} }
......
...@@ -23,10 +23,9 @@ import ( ...@@ -23,10 +23,9 @@ import (
"time" "time"
"github.com/golang/glog" "github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/v1" "k8s.io/kubernetes/pkg/api/v1"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" clientset "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5"
unversionedcore "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion" v1core "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5/typed/core/v1"
"k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/labels"
heapster "k8s.io/heapster/metrics/api/v1/types" heapster "k8s.io/heapster/metrics/api/v1/types"
...@@ -46,7 +45,7 @@ type PodMetricsInfo map[string]float64 ...@@ -46,7 +45,7 @@ type PodMetricsInfo map[string]float64
type MetricsClient interface { type MetricsClient interface {
// GetResourceMetric gets the given resource metric (and an associated oldest timestamp) // GetResourceMetric gets the given resource metric (and an associated oldest timestamp)
// for all pods matching the specified selector in the given namespace // for all pods matching the specified selector in the given namespace
GetResourceMetric(resource api.ResourceName, namespace string, selector labels.Selector) (PodResourceInfo, time.Time, error) GetResourceMetric(resource v1.ResourceName, namespace string, selector labels.Selector) (PodResourceInfo, time.Time, error)
// GetRawMetric gets the given metric (and an associated oldest timestamp) // GetRawMetric gets the given metric (and an associated oldest timestamp)
// for all pods matching the specified selector in the given namespace // for all pods matching the specified selector in the given namespace
...@@ -63,8 +62,8 @@ const ( ...@@ -63,8 +62,8 @@ const (
var heapsterQueryStart = -5 * time.Minute var heapsterQueryStart = -5 * time.Minute
type HeapsterMetricsClient struct { type HeapsterMetricsClient struct {
services unversionedcore.ServiceInterface services v1core.ServiceInterface
podsGetter unversionedcore.PodsGetter podsGetter v1core.PodsGetter
heapsterScheme string heapsterScheme string
heapsterService string heapsterService string
heapsterPort string heapsterPort string
...@@ -80,7 +79,7 @@ func NewHeapsterMetricsClient(client clientset.Interface, namespace, scheme, ser ...@@ -80,7 +79,7 @@ func NewHeapsterMetricsClient(client clientset.Interface, namespace, scheme, ser
} }
} }
func (h *HeapsterMetricsClient) GetResourceMetric(resource api.ResourceName, namespace string, selector labels.Selector) (PodResourceInfo, time.Time, error) { func (h *HeapsterMetricsClient) GetResourceMetric(resource v1.ResourceName, namespace string, selector labels.Selector) (PodResourceInfo, time.Time, error) {
metricPath := fmt.Sprintf("/apis/metrics/v1alpha1/namespaces/%s/pods", namespace) metricPath := fmt.Sprintf("/apis/metrics/v1alpha1/namespaces/%s/pods", namespace)
params := map[string]string{"labelSelector": selector.String()} params := map[string]string{"labelSelector": selector.String()}
...@@ -132,7 +131,7 @@ func (h *HeapsterMetricsClient) GetResourceMetric(resource api.ResourceName, nam ...@@ -132,7 +131,7 @@ func (h *HeapsterMetricsClient) GetResourceMetric(resource api.ResourceName, nam
} }
func (h *HeapsterMetricsClient) GetRawMetric(metricName string, namespace string, selector labels.Selector) (PodMetricsInfo, time.Time, error) { func (h *HeapsterMetricsClient) GetRawMetric(metricName string, namespace string, selector labels.Selector) (PodMetricsInfo, time.Time, error) {
podList, err := h.podsGetter.Pods(namespace).List(api.ListOptions{LabelSelector: selector}) podList, err := h.podsGetter.Pods(namespace).List(v1.ListOptions{LabelSelector: selector.String()})
if err != nil { if err != nil {
return nil, time.Time{}, fmt.Errorf("failed to get pod list while fetching metrics: %v", err) return nil, time.Time{}, fmt.Errorf("failed to get pod list while fetching metrics: %v", err)
} }
......
...@@ -23,12 +23,11 @@ import ( ...@@ -23,12 +23,11 @@ import (
"testing" "testing"
"time" "time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/resource" "k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/v1" "k8s.io/kubernetes/pkg/api/v1"
_ "k8s.io/kubernetes/pkg/apimachinery/registered" _ "k8s.io/kubernetes/pkg/apimachinery/registered"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake" "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5/fake"
"k8s.io/kubernetes/pkg/client/restclient" "k8s.io/kubernetes/pkg/client/restclient"
"k8s.io/kubernetes/pkg/client/testing/core" "k8s.io/kubernetes/pkg/client/testing/core"
"k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/labels"
...@@ -76,7 +75,7 @@ type testCase struct { ...@@ -76,7 +75,7 @@ type testCase struct {
namespace string namespace string
selector labels.Selector selector labels.Selector
resourceName api.ResourceName resourceName v1.ResourceName
metricName string metricName string
} }
...@@ -93,10 +92,10 @@ func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset { ...@@ -93,10 +92,10 @@ func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset {
fakeClient := &fake.Clientset{} fakeClient := &fake.Clientset{}
fakeClient.AddReactor("list", "pods", func(action core.Action) (handled bool, ret runtime.Object, err error) { fakeClient.AddReactor("list", "pods", func(action core.Action) (handled bool, ret runtime.Object, err error) {
obj := &api.PodList{} obj := &v1.PodList{}
for i := 0; i < tc.replicas; i++ { for i := 0; i < tc.replicas; i++ {
podName := fmt.Sprintf("%s-%d", podNamePrefix, i) podName := fmt.Sprintf("%s-%d", podNamePrefix, i)
pod := buildPod(namespace, podName, podLabels, api.PodRunning, "1024") pod := buildPod(namespace, podName, podLabels, v1.PodRunning, "1024")
obj.Items = append(obj.Items, pod) obj.Items = append(obj.Items, pod)
} }
return true, obj, nil return true, obj, nil
...@@ -161,30 +160,30 @@ func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset { ...@@ -161,30 +160,30 @@ func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset {
return fakeClient return fakeClient
} }
func buildPod(namespace, podName string, podLabels map[string]string, phase api.PodPhase, request string) api.Pod { func buildPod(namespace, podName string, podLabels map[string]string, phase v1.PodPhase, request string) v1.Pod {
return api.Pod{ return v1.Pod{
ObjectMeta: api.ObjectMeta{ ObjectMeta: v1.ObjectMeta{
Name: podName, Name: podName,
Namespace: namespace, Namespace: namespace,
Labels: podLabels, Labels: podLabels,
}, },
Spec: api.PodSpec{ Spec: v1.PodSpec{
Containers: []api.Container{ Containers: []v1.Container{
{ {
Resources: api.ResourceRequirements{ Resources: v1.ResourceRequirements{
Requests: api.ResourceList{ Requests: v1.ResourceList{
api.ResourceCPU: resource.MustParse(request), v1.ResourceCPU: resource.MustParse(request),
}, },
}, },
}, },
}, },
}, },
Status: api.PodStatus{ Status: v1.PodStatus{
Phase: phase, Phase: phase,
Conditions: []api.PodCondition{ Conditions: []v1.PodCondition{
{ {
Type: api.PodReady, Type: v1.PodReady,
Status: api.ConditionTrue, Status: v1.ConditionTrue,
}, },
}, },
}, },
...@@ -231,7 +230,7 @@ func TestCPU(t *testing.T) { ...@@ -231,7 +230,7 @@ func TestCPU(t *testing.T) {
desiredResourceValues: PodResourceInfo{ desiredResourceValues: PodResourceInfo{
"test-pod-0": 5000, "test-pod-1": 5000, "test-pod-2": 5000, "test-pod-0": 5000, "test-pod-1": 5000, "test-pod-2": 5000,
}, },
resourceName: api.ResourceCPU, resourceName: v1.ResourceCPU,
targetTimestamp: 1, targetTimestamp: 1,
reportedPodMetrics: [][]int64{{5000}, {5000}, {5000}}, reportedPodMetrics: [][]int64{{5000}, {5000}, {5000}},
} }
...@@ -271,7 +270,7 @@ func TestCPUMoreMetrics(t *testing.T) { ...@@ -271,7 +270,7 @@ func TestCPUMoreMetrics(t *testing.T) {
"test-pod-0": 5000, "test-pod-1": 5000, "test-pod-2": 5000, "test-pod-0": 5000, "test-pod-1": 5000, "test-pod-2": 5000,
"test-pod-3": 5000, "test-pod-4": 5000, "test-pod-3": 5000, "test-pod-4": 5000,
}, },
resourceName: api.ResourceCPU, resourceName: v1.ResourceCPU,
targetTimestamp: 10, targetTimestamp: 10,
reportedPodMetrics: [][]int64{{1000, 2000, 2000}, {5000}, {1000, 1000, 1000, 2000}, {4000, 1000}, {5000}}, reportedPodMetrics: [][]int64{{1000, 2000, 2000}, {5000}, {1000, 1000, 1000, 2000}, {4000, 1000}, {5000}},
} }
...@@ -284,7 +283,7 @@ func TestCPUMissingMetrics(t *testing.T) { ...@@ -284,7 +283,7 @@ func TestCPUMissingMetrics(t *testing.T) {
desiredResourceValues: PodResourceInfo{ desiredResourceValues: PodResourceInfo{
"test-pod-0": 4000, "test-pod-0": 4000,
}, },
resourceName: api.ResourceCPU, resourceName: v1.ResourceCPU,
reportedPodMetrics: [][]int64{{4000}}, reportedPodMetrics: [][]int64{{4000}},
} }
tc.runTest(t) tc.runTest(t)
...@@ -314,7 +313,7 @@ func TestQpsSuperfluousMetrics(t *testing.T) { ...@@ -314,7 +313,7 @@ func TestQpsSuperfluousMetrics(t *testing.T) {
func TestCPUEmptyMetrics(t *testing.T) { func TestCPUEmptyMetrics(t *testing.T) {
tc := testCase{ tc := testCase{
replicas: 3, replicas: 3,
resourceName: api.ResourceCPU, resourceName: v1.ResourceCPU,
desiredError: fmt.Errorf("no metrics returned from heapster"), desiredError: fmt.Errorf("no metrics returned from heapster"),
reportedMetricsPoints: [][]metricPoint{}, reportedMetricsPoints: [][]metricPoint{},
reportedPodMetrics: [][]int64{}, reportedPodMetrics: [][]int64{},
...@@ -338,7 +337,7 @@ func TestQpsEmptyEntries(t *testing.T) { ...@@ -338,7 +337,7 @@ func TestQpsEmptyEntries(t *testing.T) {
func TestCPUZeroReplicas(t *testing.T) { func TestCPUZeroReplicas(t *testing.T) {
tc := testCase{ tc := testCase{
replicas: 0, replicas: 0,
resourceName: api.ResourceCPU, resourceName: v1.ResourceCPU,
desiredError: fmt.Errorf("no metrics returned from heapster"), desiredError: fmt.Errorf("no metrics returned from heapster"),
reportedPodMetrics: [][]int64{}, reportedPodMetrics: [][]int64{},
} }
...@@ -348,7 +347,7 @@ func TestCPUZeroReplicas(t *testing.T) { ...@@ -348,7 +347,7 @@ func TestCPUZeroReplicas(t *testing.T) {
func TestCPUEmptyMetricsForOnePod(t *testing.T) { func TestCPUEmptyMetricsForOnePod(t *testing.T) {
tc := testCase{ tc := testCase{
replicas: 3, replicas: 3,
resourceName: api.ResourceCPU, resourceName: v1.ResourceCPU,
desiredResourceValues: PodResourceInfo{ desiredResourceValues: PodResourceInfo{
"test-pod-0": 100, "test-pod-1": 700, "test-pod-0": 100, "test-pod-1": 700,
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment