treewide: switch to gomod and bump everything

This switches version resolution from fietsje to gomod and updates
all Go dependencies. It also bumps rules_go (required by gVisor) and
switches the Gazelle naming convention from go_default_xxx to the
standard Bazel convention of the default target having the package
name.

Since Kubernetes dropped upstream Bazel support and doesn't check in
all generated files I manually pregenerated the OpenAPI spec. This
should be fixed, but because of the already-huge scope of this CL
and the rebase complexity this is not in here.

Change-Id: Iec8ea613d06946882426c2f9fad5bda7e8aaf833
Reviewed-on: https://review.monogon.dev/c/monogon/+/639
Reviewed-by: Sergiusz Bazanski <serge@monogon.tech>
Reviewed-by: Leopold Schabel <leo@nexantic.com>
diff --git a/third_party/go/patches/k8s-drop-legacy-log-path.patch b/third_party/go/patches/k8s-drop-legacy-log-path.patch
index af7b007..356a681 100644
--- a/third_party/go/patches/k8s-drop-legacy-log-path.patch
+++ b/third_party/go/patches/k8s-drop-legacy-log-path.patch
@@ -1,21 +1,6 @@
-Copyright 2020 The Monogon Project Authors.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-
-From 227ccd88e378a002b7c23703eec96aa1d25949eb Mon Sep 17 00:00:00 2001
-From: Lorenz Brun <lorenz@brun.one>
-Date: Wed, 3 Feb 2021 16:47:38 +0100
+From b2d875981cec8eda9c041f858004f613ea928895 Mon Sep 17 00:00:00 2001
+From: Lorenz Brun <lorenz@monogon.tech>
+Date: Wed, 16 Mar 2022 18:10:09 +0100
 Subject: [PATCH] Drop legacy log path
 
 ---
@@ -23,14 +8,14 @@
  .../kuberuntime/kuberuntime_container.go      | 32 ---------------
  pkg/kubelet/kuberuntime/kuberuntime_gc.go     | 39 -------------------
  pkg/kubelet/runonce.go                        |  8 ----
- test/e2e_node/log_path_test.go                | 19 +--------
- 5 files changed, 1 insertion(+), 104 deletions(-)
+ test/e2e_node/log_path_test.go                | 18 ---------
+ 5 files changed, 104 deletions(-)
 
 diff --git a/pkg/kubelet/kubelet.go b/pkg/kubelet/kubelet.go
-index 902dc7532e1..2d582f65b19 100644
+index 2013c871a60..c3fd4221544 100644
 --- a/pkg/kubelet/kubelet.go
 +++ b/pkg/kubelet/kubelet.go
-@@ -1250,13 +1250,6 @@ func (kl *Kubelet) initializeModules() error {
+@@ -1379,13 +1379,6 @@ func (kl *Kubelet) initializeModules() error {
  		return err
  	}
  
@@ -45,10 +30,10 @@
  	kl.imageManager.Start()
  
 diff --git a/pkg/kubelet/kuberuntime/kuberuntime_container.go b/pkg/kubelet/kuberuntime/kuberuntime_container.go
-index af361122c35..d5b2d245219 100644
+index 9c762ac309e..d1148cc7de5 100644
 --- a/pkg/kubelet/kuberuntime/kuberuntime_container.go
 +++ b/pkg/kubelet/kuberuntime/kuberuntime_container.go
-@@ -190,25 +190,6 @@ func (m *kubeGenericRuntimeManager) startContainer(podSandboxID string, podSandb
+@@ -254,25 +254,6 @@ func (m *kubeGenericRuntimeManager) startContainer(podSandboxID string, podSandb
  	}
  	m.recordContainerEvent(pod, container, containerID, v1.EventTypeNormal, events.StartedContainer, fmt.Sprintf("Started container %s", container.Name))
  
@@ -66,15 +51,15 @@
 -	// to create it in the first place. it happens when journald logging driver is used with docker.
 -	if _, err := m.osInterface.Stat(containerLog); !os.IsNotExist(err) {
 -		if err := m.osInterface.Symlink(containerLog, legacySymlink); err != nil {
--			klog.Errorf("Failed to create legacy symbolic link %q to container %q log %q: %v",
--				legacySymlink, containerID, containerLog, err)
+-			klog.ErrorS(err, "Failed to create legacy symbolic link", "path", legacySymlink,
+-				"containerID", containerID, "containerLogPath", containerLog)
 -		}
 -	}
 -
  	// Step 4: execute the post start hook.
  	if container.Lifecycle != nil && container.Lifecycle.PostStart != nil {
  		kubeContainerID := kubecontainer.ContainerID{
-@@ -861,19 +842,6 @@ func (m *kubeGenericRuntimeManager) removeContainerLog(containerID string) error
+@@ -967,19 +948,6 @@ func (m *kubeGenericRuntimeManager) removeContainerLog(containerID string) error
  		return err
  	}
  
@@ -95,7 +80,7 @@
  }
  
 diff --git a/pkg/kubelet/kuberuntime/kuberuntime_gc.go b/pkg/kubelet/kuberuntime/kuberuntime_gc.go
-index 8c4f786db9b..b5b104ee6a6 100644
+index 610026661b7..a09dec91fbb 100644
 --- a/pkg/kubelet/kuberuntime/kuberuntime_gc.go
 +++ b/pkg/kubelet/kuberuntime/kuberuntime_gc.go
 @@ -18,7 +18,6 @@ package kuberuntime
@@ -106,7 +91,7 @@
  	"path/filepath"
  	"sort"
  	"time"
-@@ -346,44 +345,6 @@ func (cgc *containerGC) evictPodLogsDirectories(allSourcesReady bool) error {
+@@ -347,44 +346,6 @@ func (cgc *containerGC) evictPodLogsDirectories(allSourcesReady bool) error {
  			}
  		}
  	}
@@ -121,7 +106,7 @@
 -				if err != nil {
 -					// TODO: we should handle container not found (i.e. container was deleted) case differently
 -					// once https://github.com/kubernetes/kubernetes/issues/63336 is resolved
--					klog.Infof("Error getting ContainerStatus for containerID %q: %v", containerID, err)
+-					klog.InfoS("Error getting ContainerStatus for containerID", "containerID", containerID, "err", err)
 -				} else if status.State != runtimeapi.ContainerState_CONTAINER_EXITED {
 -					// Here is how container log rotation works (see containerLogManager#rotateLatestLog):
 -					//
@@ -134,17 +119,17 @@
 -					// See https://github.com/kubernetes/kubernetes/issues/52172
 -					//
 -					// We only remove unhealthy symlink for dead containers
--					klog.V(5).Infof("Container %q is still running, not removing symlink %q.", containerID, logSymlink)
+-					klog.V(5).InfoS("Container is still running, not removing symlink", "containerID", containerID, "path", logSymlink)
 -					continue
 -				}
 -			} else {
--				klog.V(4).Infof("unable to obtain container Id: %v", err)
+-				klog.V(4).InfoS("Unable to obtain container ID", "err", err)
 -			}
 -			err := osInterface.Remove(logSymlink)
 -			if err != nil {
--				klog.Errorf("Failed to remove container log dead symlink %q: %v", logSymlink, err)
+-				klog.ErrorS(err, "Failed to remove container log dead symlink", "path", logSymlink)
 -			} else {
--				klog.V(4).Infof("removed symlink %s", logSymlink)
+-				klog.V(4).InfoS("Removed symlink", "path", logSymlink)
 -			}
 -		}
 -	}
@@ -152,40 +137,36 @@
  }
  
 diff --git a/pkg/kubelet/runonce.go b/pkg/kubelet/runonce.go
-index 1da9c225186..d6a5a63e92d 100644
+index 19b8a4f6a7b..2f0aad713e3 100644
 --- a/pkg/kubelet/runonce.go
 +++ b/pkg/kubelet/runonce.go
-@@ -18,7 +18,6 @@ package kubelet
- 
+@@ -19,7 +19,6 @@ package kubelet
  import (
+ 	"context"
  	"fmt"
 -	"os"
  	"time"
  
- 	"k8s.io/api/core/v1"
-@@ -48,13 +47,6 @@ func (kl *Kubelet) RunOnce(updates <-chan kubetypes.PodUpdate) ([]RunPodResult,
+ 	v1 "k8s.io/api/core/v1"
+@@ -49,13 +48,6 @@ func (kl *Kubelet) RunOnce(updates <-chan kubetypes.PodUpdate) ([]RunPodResult,
  		return nil, err
  	}
  
 -	// If the container logs directory does not exist, create it.
 -	if _, err := os.Stat(ContainerLogsDir); err != nil {
 -		if err := kl.os.MkdirAll(ContainerLogsDir, 0755); err != nil {
--			klog.Errorf("Failed to create directory %q: %v", ContainerLogsDir, err)
+-			klog.ErrorS(err, "Failed to create directory", "path", ContainerLogsDir)
 -		}
 -	}
 -
  	select {
  	case u := <-updates:
- 		klog.Infof("processing manifest with %d pods", len(u.Pods))
+ 		klog.InfoS("Processing manifest with pods", "numPods", len(u.Pods))
 diff --git a/test/e2e_node/log_path_test.go b/test/e2e_node/log_path_test.go
-index 41646f326a5..6568d31e242 100644
+index cfdd9823cb1..35f3b7be465 100644
 --- a/test/e2e_node/log_path_test.go
 +++ b/test/e2e_node/log_path_test.go
-@@ -18,11 +18,10 @@ package e2enode
- 
- import (
- 	"context"
-+
+@@ -22,8 +22,6 @@ import (
  	v1 "k8s.io/api/core/v1"
  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
  	"k8s.io/apimachinery/pkg/util/uuid"
@@ -194,7 +175,7 @@
  	"k8s.io/kubernetes/test/e2e/framework"
  	e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
  	e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
-@@ -138,22 +137,6 @@ var _ = framework.KubeDescribe("ContainerLogPath [NodeConformance]", func() {
+@@ -144,22 +142,6 @@ var _ = SIGDescribe("ContainerLogPath [NodeConformance]", func() {
  				err := createAndWaitPod(makeLogPod(logPodName, logString))
  				framework.ExpectNoError(err, "Failed waiting for pod: %s to enter success state", logPodName)
  			})