Skip to content

Commit

Permalink
Switch to newest kubernetes sdk
Browse files Browse the repository at this point in the history
Preparation to switch to workqueue, to work around [1].  The Informer is
written in a way that new updates are starving when the the process loop
holds the lock too long.

[1] golang/go#13086
  • Loading branch information
rmohr committed Jan 11, 2017
1 parent cef1b1b commit 05e4e2d
Show file tree
Hide file tree
Showing 25 changed files with 209 additions and 166 deletions.
6 changes: 3 additions & 3 deletions cmd/virt-api/virt-api.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/emicklei/go-restful"
"github.com/emicklei/go-restful/swagger"
"golang.org/x/net/context"
"k8s.io/client-go/1.5/pkg/api/unversioned"
"k8s.io/client-go/pkg/runtime/schema"
"kubevirt.io/kubevirt/pkg/api/v1"
"kubevirt.io/kubevirt/pkg/logging"
"kubevirt.io/kubevirt/pkg/virt-api/rest"
Expand All @@ -23,8 +23,8 @@ func main() {
flag.Parse()

ctx := context.Background()
gvr := unversioned.GroupVersionResource{Group: v1.GroupVersion.Group, Version: v1.GroupVersion.Version, Resource: "vms"}
gvk := unversioned.GroupVersionKind{Group: v1.GroupVersion.Group, Version: v1.GroupVersion.Version, Kind: "VM"}
gvr := schema.GroupVersionResource{Group: v1.GroupVersion.Group, Version: v1.GroupVersion.Version, Resource: "vms"}
gvk := schema.GroupVersionKind{Group: v1.GroupVersion.Group, Version: v1.GroupVersion.Version, Kind: "VM"}

// FIXME the whole NewResponseHandler is just a hack, see the method itself for details
err := rest.AddGenericResourceProxy(rest.WebService, ctx, gvr, &v1.VM{}, rest.NewResponseHandler(gvk, &v1.VM{}))
Expand Down
2 changes: 1 addition & 1 deletion cmd/virt-controller/virt-controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/emicklei/go-restful"
"github.com/facebookgo/inject"
"k8s.io/client-go/1.5/tools/cache"
"k8s.io/client-go/tools/cache"
"kubevirt.io/kubevirt/pkg/kubecli"
"kubevirt.io/kubevirt/pkg/logging"
"kubevirt.io/kubevirt/pkg/util"
Expand Down
14 changes: 7 additions & 7 deletions cmd/virt-handler/virt-handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import (
"flag"
"fmt"
libvirtapi "github.com/rgbkrk/libvirt-go"
kubecorev1 "k8s.io/client-go/1.5/kubernetes/typed/core/v1"
"k8s.io/client-go/1.5/pkg/api"
kubev1 "k8s.io/client-go/1.5/pkg/api/v1"
"k8s.io/client-go/1.5/pkg/fields"
"k8s.io/client-go/1.5/pkg/labels"
"k8s.io/client-go/1.5/tools/cache"
"k8s.io/client-go/1.5/tools/record"
kubecorev1 "k8s.io/client-go/kubernetes/typed/core/v1"
"k8s.io/client-go/pkg/api"
kubev1 "k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/pkg/fields"
"k8s.io/client-go/pkg/labels"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/tools/record"
"kubevirt.io/kubevirt/pkg/api/v1"
"kubevirt.io/kubevirt/pkg/kubecli"
"kubevirt.io/kubevirt/pkg/logging"
Expand Down
23 changes: 12 additions & 11 deletions pkg/api/types.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
package api

import (
"k8s.io/client-go/1.5/pkg/api"
"k8s.io/client-go/1.5/pkg/api/meta"
"k8s.io/client-go/1.5/pkg/api/unversioned"
"k8s.io/client-go/pkg/api"
"k8s.io/client-go/pkg/api/meta"
metav1 "k8s.io/client-go/pkg/apis/meta/v1"
"k8s.io/client-go/pkg/runtime/schema"
)

type VM struct {
unversioned.TypeMeta
metav1.TypeMeta
ObjectMeta api.ObjectMeta
Spec VMSpec
Status VMStatus
}

type VMList struct {
unversioned.TypeMeta
unversioned.ListMeta
metav1.TypeMeta
metav1.ListMeta
VMs []VM
}

Expand All @@ -33,7 +34,7 @@ type VMStatus struct {
}

// Required to satisfy Object interface
func (v *VM) GetObjectKind() unversioned.ObjectKind {
func (v *VM) GetObjectKind() schema.ObjectKind {
return &v.TypeMeta
}

Expand All @@ -43,12 +44,12 @@ func (v *VM) GetObjectMeta() meta.Object {
}

// Required to satisfy Object interface
func (vl *VMList) GetObjectKind() unversioned.ObjectKind {
func (vl *VMList) GetObjectKind() schema.ObjectKind {
return &vl.TypeMeta
}

// Required to satisfy ListMetaAccessor interface
func (vl *VMList) GetListMeta() unversioned.List {
func (vl *VMList) GetListMeta() metav1.List {
return &vl.ListMeta
}

Expand All @@ -68,8 +69,8 @@ const (
type VMCondition struct {
Type VMConditionType `json:"type"`
Status api.ConditionStatus `json:"status"`
LastProbeTime unversioned.Time `json:"lastProbeTime,omitempty"`
LastTransitionTime unversioned.Time `json:"lastTransitionTime,omitempty"`
LastProbeTime metav1.Time `json:"lastProbeTime,omitempty"`
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
Reason string `json:"reason,omitempty"`
Message string `json:"message,omitempty"`
}
4 changes: 2 additions & 2 deletions pkg/api/v1/mapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/satori/go.uuid"
kubeapi "k8s.io/client-go/1.5/pkg/api"
"k8s.io/client-go/1.5/pkg/types"
kubeapi "k8s.io/client-go/pkg/api"
"k8s.io/client-go/pkg/types"
"kubevirt.io/kubevirt/pkg/api"
)

Expand Down
47 changes: 25 additions & 22 deletions pkg/api/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ import (
"encoding/json"
"github.com/jeevatkm/go-model"
"github.com/satori/go.uuid"
kubeapi "k8s.io/client-go/1.5/pkg/api"
"k8s.io/client-go/1.5/pkg/api/meta"
"k8s.io/client-go/1.5/pkg/api/unversioned"
"k8s.io/client-go/1.5/pkg/api/v1"
"k8s.io/client-go/1.5/pkg/apimachinery/announced"
"k8s.io/client-go/1.5/pkg/runtime"
"k8s.io/client-go/1.5/pkg/types"
kubeapi "k8s.io/client-go/pkg/api"
"k8s.io/client-go/pkg/api/meta"
"k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/pkg/apimachinery/announced"
metav1 "k8s.io/client-go/pkg/apis/meta/v1"
"k8s.io/client-go/pkg/runtime"
"k8s.io/client-go/pkg/runtime/schema"
"k8s.io/client-go/pkg/types"
"kubevirt.io/kubevirt/pkg/api"
"kubevirt.io/kubevirt/pkg/precond"
"reflect"
Expand All @@ -26,15 +27,17 @@ import (
const GroupName = "kubevirt.io"

// GroupVersion is group version used to register these objects
var GroupVersion = unversioned.GroupVersion{Group: GroupName, Version: "v1alpha1"}
var GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"}

// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(GroupVersion,
&VM{},
&VMList{},
&kubeapi.ListOptions{},
&v1.ListOptions{},
&kubeapi.DeleteOptions{},
&v1.DeleteOptions{},
)
return nil
}
Expand Down Expand Up @@ -120,17 +123,17 @@ func init() {
}

type VM struct {
unversioned.TypeMeta `json:",inline"`
ObjectMeta kubeapi.ObjectMeta `json:"metadata,omitempty"`
Spec VMSpec `json:"spec,omitempty" valid:"required"`
Status VMStatus `json:"status"`
metav1.TypeMeta `json:",inline"`
ObjectMeta kubeapi.ObjectMeta `json:"metadata,omitempty"`
Spec VMSpec `json:"spec,omitempty" valid:"required"`
Status VMStatus `json:"status"`
}

// VMList is a list of VMs
type VMList struct {
unversioned.TypeMeta `json:",inline"`
ListMeta unversioned.ListMeta `json:"metadata,omitempty"`
Items []VM `json:"items"`
metav1.TypeMeta `json:",inline"`
ListMeta metav1.ListMeta `json:"metadata,omitempty"`
Items []VM `json:"items"`
}

// VMSpec is a description of a VM
Expand All @@ -149,7 +152,7 @@ type VMStatus struct {
}

// Required to satisfy Object interface
func (v *VM) GetObjectKind() unversioned.ObjectKind {
func (v *VM) GetObjectKind() schema.ObjectKind {
return &v.TypeMeta
}

Expand All @@ -159,12 +162,12 @@ func (v *VM) GetObjectMeta() meta.Object {
}

// Required to satisfy Object interface
func (vl *VMList) GetObjectKind() unversioned.ObjectKind {
func (vl *VMList) GetObjectKind() schema.ObjectKind {
return &vl.TypeMeta
}

// Required to satisfy ListMetaAccessor interface
func (vl *VMList) GetListMeta() unversioned.List {
func (vl *VMList) GetListMeta() metav1.List {
return &vl.ListMeta
}

Expand Down Expand Up @@ -207,8 +210,8 @@ const (
type VMCondition struct {
Type VMConditionType `json:"type"`
Status v1.ConditionStatus `json:"status"`
LastProbeTime unversioned.Time `json:"lastProbeTime,omitempty"`
LastTransitionTime unversioned.Time `json:"lastTransitionTime,omitempty"`
LastProbeTime metav1.Time `json:"lastProbeTime,omitempty"`
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
Reason string `json:"reason,omitempty"`
Message string `json:"message,omitempty"`
}
Expand Down Expand Up @@ -255,7 +258,7 @@ func NewVM(name string, uid types.UID) *VM {
Namespace: kubeapi.NamespaceDefault,
},
Status: VMStatus{},
TypeMeta: unversioned.TypeMeta{
TypeMeta: metav1.TypeMeta{
APIVersion: GroupVersion.String(),
Kind: "VM",
},
Expand Down Expand Up @@ -285,7 +288,7 @@ func NewMinimalVM(vmName string) *VM {
Name: vmName,
Namespace: kubeapi.NamespaceDefault,
},
TypeMeta: unversioned.TypeMeta{
TypeMeta: metav1.TypeMeta{
APIVersion: GroupVersion.String(),
Kind: "VM",
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/healthz/healthz.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package healthz
import (
"fmt"
"github.com/emicklei/go-restful"
"k8s.io/client-go/1.5/pkg/util/json"
"k8s.io/client-go/pkg/util/json"
"kubevirt.io/kubevirt/pkg/kubecli"
"net/http"
)
Expand All @@ -16,7 +16,7 @@ func KubeConnectionHealthzFunc(_ *restful.Request, response *restful.Response) {
return
}

body, err := cli.Core().GetRESTClient().Get().AbsPath("/version").Do().Raw()
body, err := cli.Core().RESTClient().Get().AbsPath("/version").Do().Raw()
if err != nil {
unhealthy(err, response)
return
Expand Down
Loading

0 comments on commit 05e4e2d

Please sign in to comment.