Skip to content

Commit

Permalink
Linting: fix errors in modified files
Browse files Browse the repository at this point in the history
  • Loading branch information
giorio94 authored and adamjensenbot committed May 24, 2021
1 parent c367650 commit 3c19816
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion cmd/virtual-kubelet/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func runRootCommand(ctx context.Context, s *provider.Store, c *Opts) error {

eb := record.NewBroadcaster()

pc, err := module.NewPodController(module.PodControllerConfig{
pc, err := module.NewPodController(&module.PodControllerConfig{
PodClient: client.Client().CoreV1(),
PodInformer: podInformer,
EventRecorder: eb.NewRecorder(scheme.Scheme, corev1.EventSource{Component: path.Join(pNode.Name, "pod-controller")}),
Expand Down
2 changes: 1 addition & 1 deletion pkg/virtualKubelet/node/module/lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ func wireUpSystem(ctx context.Context, provider PodLifecycleHandler, f testFunct
}

var err error
sys.pc, err = NewPodController(sys.podControllerConfig)
sys.pc, err = NewPodController(&sys.podControllerConfig)
if err != nil {
return err
}
Expand Down
25 changes: 11 additions & 14 deletions pkg/virtualKubelet/node/module/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
pkgerrors "github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
kerrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/cache"
"k8s.io/klog"
Expand Down Expand Up @@ -93,14 +92,14 @@ func podsEqual(pod1, pod2 *corev1.Pod) bool {

// since the only mutable fields in pods containers and initContainers are the images,
// we check only them
for i, c := range pod1.Spec.Containers {
if pod2.Spec.Containers[i].Image != c.Image {
for i := range pod1.Spec.Containers {
if pod2.Spec.Containers[i].Image != pod1.Spec.Containers[i].Image {
containers = false
break
}
}
for i, c := range pod1.Spec.InitContainers {
if pod2.Spec.InitContainers[i].Image != c.Image {
for i := range pod1.Spec.InitContainers {
if pod2.Spec.InitContainers[i].Image != pod1.Spec.InitContainers[i].Image {
initContainers = false
break
}
Expand All @@ -119,7 +118,7 @@ func (pc *PodController) handleProviderError(ctx context.Context, origErr error,
// of type notFound and handles it properly (by deleting the local pod)
// if in further investigations we notice different error types,
// the related cases should be added here
switch kerrors.ReasonForError(origErr) {
switch errors.ReasonForError(origErr) {
case metav1.StatusReasonNotFound:
err := pc.client.Pods(pod.Namespace).Delete(context.TODO(), pod.Name, metav1.DeleteOptions{})
if err != nil {
Expand Down Expand Up @@ -215,14 +214,12 @@ func (pc *PodController) updatePodStatus(ctx context.Context, podFromKubernetes
func (pc *PodController) enqueuePodStatusUpdate(ctx context.Context, pod *corev1.Pod) {
if key, err := cache.MetaNamespaceKeyFunc(pod); err != nil {
klog.Error(err, "Error getting pod meta namespace key")
} else {
if obj, ok := pc.knownPods.Load(key); ok {
kpod := obj.(*knownPod)
kpod.Lock()
kpod.lastPodStatusReceivedFromProvider = pod
kpod.Unlock()
pc.syncPodStatusFromProvider.Enqueue(key)
}
} else if obj, ok := pc.knownPods.Load(key); ok {
kpod := obj.(*knownPod)
kpod.Lock()
kpod.lastPodStatusReceivedFromProvider = pod
kpod.Unlock()
pc.syncPodStatusFromProvider.Enqueue(key)
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/virtualKubelet/node/module/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func newTestController() *TestController {
rm := testutil.FakeResourceManager()
p := newMockProvider()
iFactory := kubeinformers.NewSharedInformerFactoryWithOptions(fk8s, 10*time.Minute)
podController, err := NewPodController(PodControllerConfig{
podController, err := NewPodController(&PodControllerConfig{
PodClient: fk8s.CoreV1(),
PodInformer: iFactory.Core().V1().Pods(),
EventRecorder: testutil.FakeEventRecorder(5),
Expand Down
2 changes: 1 addition & 1 deletion pkg/virtualKubelet/node/module/podcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ type PodControllerConfig struct {
}

// NewPodController creates a new pod controller with the provided config.
func NewPodController(cfg PodControllerConfig) (*PodController, error) {
func NewPodController(cfg *PodControllerConfig) (*PodController, error) {
if cfg.PodClient == nil {
return nil, errdefs.InvalidInput("missing core client")
}
Expand Down

0 comments on commit 3c19816

Please sign in to comment.