Merge pull request #107119 from hakman/remove_dockerless
Remove dockerless build tag and DockerLegacyService interface
This commit is contained in:
@@ -49,7 +49,6 @@ if [[ ${EXCLUDE_TYPECHECK:-} =~ ^[yY]$ ]]; then
|
||||
EXCLUDED_PATTERNS+=(
|
||||
"verify-typecheck.sh" # runs in separate typecheck job
|
||||
"verify-typecheck-providerless.sh" # runs in separate typecheck job
|
||||
"verify-typecheck-dockerless.sh" # runs in separate typecheck job
|
||||
)
|
||||
fi
|
||||
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2018 The Kubernetes 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.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||
|
||||
cd "${KUBE_ROOT}"
|
||||
# verify the dockerless build
|
||||
# https://github.com/kubernetes/enhancements/blob/master/keps/sig-node/1547-building-kubelet-without-docker/README.md
|
||||
hack/verify-typecheck.sh --skip-test --tags=dockerless --ignore-dirs=test
|
||||
|
||||
# verify using go list
|
||||
if _out="$(go list -mod=readonly -tags "dockerless" -e -json k8s.io/kubernetes/cmd/kubelet/... \
|
||||
| grep -e dockershim)"; then
|
||||
echo "${_out}" >&2
|
||||
echo "Verify typecheck for dockerless tag failed. Found restricted packages." >&2
|
||||
exit 1
|
||||
fi
|
||||
@@ -78,7 +78,6 @@ import (
|
||||
"k8s.io/kubernetes/pkg/kubelet/images"
|
||||
"k8s.io/kubernetes/pkg/kubelet/kubeletconfig"
|
||||
"k8s.io/kubernetes/pkg/kubelet/kuberuntime"
|
||||
"k8s.io/kubernetes/pkg/kubelet/legacy"
|
||||
"k8s.io/kubernetes/pkg/kubelet/lifecycle"
|
||||
"k8s.io/kubernetes/pkg/kubelet/logs"
|
||||
"k8s.io/kubernetes/pkg/kubelet/metrics"
|
||||
@@ -243,7 +242,6 @@ type Dependencies struct {
|
||||
KubeletConfigController *kubeletconfig.Controller
|
||||
RemoteRuntimeService internalapi.RuntimeService
|
||||
RemoteImageService internalapi.ImageManagerService
|
||||
dockerLegacyService legacy.DockerLegacyService
|
||||
// remove it after cadvisor.UsingLegacyCadvisorStats dropped.
|
||||
useLegacyCadvisorStats bool
|
||||
}
|
||||
@@ -608,7 +606,6 @@ func NewMainKubelet(kubeCfg *kubeletconfiginternal.KubeletConfiguration,
|
||||
|
||||
klet.resourceAnalyzer = serverstats.NewResourceAnalyzer(klet, kubeCfg.VolumeStatsAggPeriod.Duration, kubeDeps.Recorder)
|
||||
|
||||
klet.dockerLegacyService = kubeDeps.dockerLegacyService
|
||||
klet.runtimeService = kubeDeps.RemoteRuntimeService
|
||||
|
||||
if kubeDeps.KubeClient != nil {
|
||||
@@ -667,7 +664,6 @@ func NewMainKubelet(kubeCfg *kubeletconfiginternal.KubeletConfiguration,
|
||||
kubeDeps.RemoteRuntimeService,
|
||||
kubeDeps.RemoteImageService,
|
||||
kubeDeps.ContainerManager.InternalContainerLifecycle(),
|
||||
kubeDeps.dockerLegacyService,
|
||||
klet.containerLogManager,
|
||||
klet.runtimeClassManager,
|
||||
seccompDefault,
|
||||
@@ -1188,10 +1184,6 @@ type Kubelet struct {
|
||||
// experimental behavior is desired.
|
||||
experimentalHostUserNamespaceDefaulting bool
|
||||
|
||||
// dockerLegacyService contains some legacy methods for backward compatibility.
|
||||
// It should be set only when docker is using non json-file logging driver.
|
||||
dockerLegacyService legacy.DockerLegacyService
|
||||
|
||||
// StatsProvider provides the node and the container stats.
|
||||
StatsProvider *stats.Provider
|
||||
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
//go:build dockerless
|
||||
// +build dockerless
|
||||
|
||||
/*
|
||||
Copyright 2020 The Kubernetes 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.
|
||||
*/
|
||||
|
||||
package kubelet_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"k8s.io/kubernetes/pkg/kubelet"
|
||||
kubetypes "k8s.io/kubernetes/pkg/kubelet/types"
|
||||
)
|
||||
|
||||
func TestPreInitRuntimeService(t *testing.T) {
|
||||
err := kubelet.PreInitRuntimeService(nil, nil, nil, kubetypes.DockerContainerRuntime, "", "", "", "")
|
||||
if err == nil {
|
||||
t.Fatal("PreInitRuntimeService should fail when configured to use docker and compiled dockerless")
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
//go:build dockerless
|
||||
// +build dockerless
|
||||
|
||||
/*
|
||||
Copyright 2020 The Kubernetes 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.
|
||||
*/
|
||||
|
||||
package kubelet
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
kubeletconfiginternal "k8s.io/kubernetes/pkg/kubelet/apis/config"
|
||||
"k8s.io/kubernetes/pkg/kubelet/config"
|
||||
)
|
||||
|
||||
func runDockershim(kubeCfg *kubeletconfiginternal.KubeletConfiguration,
|
||||
kubeDeps *Dependencies,
|
||||
crOptions *config.ContainerRuntimeOptions,
|
||||
runtimeCgroups string,
|
||||
remoteRuntimeEndpoint string,
|
||||
remoteImageEndpoint string,
|
||||
nonMasqueradeCIDR string) error {
|
||||
|
||||
return fmt.Errorf("trying to use docker runtime when Kubelet was compiled without docker support")
|
||||
}
|
||||
@@ -1321,12 +1321,6 @@ func (kl *Kubelet) GetKubeletContainerLogs(ctx context.Context, podFullName, con
|
||||
return err
|
||||
}
|
||||
|
||||
if kl.dockerLegacyService != nil {
|
||||
// dockerLegacyService should only be non-nil when we actually need it, so
|
||||
// inject it into the runtimeService.
|
||||
// TODO(random-liu): Remove this hack after deprecating unsupported log driver.
|
||||
return kl.dockerLegacyService.GetContainerLogs(ctx, pod, containerID, logOptions, stdout, stderr)
|
||||
}
|
||||
return kl.containerRuntime.GetContainerLogs(ctx, pod, containerID, logOptions, stdout, stderr)
|
||||
}
|
||||
|
||||
|
||||
@@ -520,15 +520,7 @@ func (m *kubeGenericRuntimeManager) getPodContainerStatuses(uid kubetypes.UID, n
|
||||
cStatus.ExitCode != 0 && cStatus.Reason != "ContainerCannotRun"
|
||||
tMessage, checkLogs := getTerminationMessage(status, annotatedInfo.TerminationMessagePath, fallbackToLogs)
|
||||
if checkLogs {
|
||||
// if dockerLegacyService is populated, we're supposed to use it to fetch logs
|
||||
if m.legacyLogProvider != nil {
|
||||
tMessage, err = m.legacyLogProvider.GetContainerLogTail(uid, name, namespace, kubecontainer.ContainerID{Type: m.runtimeName, ID: c.Id})
|
||||
if err != nil {
|
||||
tMessage = fmt.Sprintf("Error reading termination message from logs: %v", err)
|
||||
}
|
||||
} else {
|
||||
tMessage = m.readLastStringFromContainerLogs(status.GetLogPath())
|
||||
}
|
||||
tMessage = m.readLastStringFromContainerLogs(status.GetLogPath())
|
||||
}
|
||||
// Enrich the termination message written by the application is not empty
|
||||
if len(tMessage) != 0 {
|
||||
|
||||
@@ -133,9 +133,6 @@ type kubeGenericRuntimeManager struct {
|
||||
// Internal lifecycle event handlers for container resource management.
|
||||
internalLifecycle cm.InternalContainerLifecycle
|
||||
|
||||
// A shim to legacy functions for backward compatibility.
|
||||
legacyLogProvider LegacyLogProvider
|
||||
|
||||
// Manage container logs.
|
||||
logManager logs.ContainerLogManager
|
||||
|
||||
@@ -168,12 +165,6 @@ type KubeGenericRuntime interface {
|
||||
kubecontainer.CommandRunner
|
||||
}
|
||||
|
||||
// LegacyLogProvider gives the ability to use unsupported docker log drivers (e.g. journald)
|
||||
type LegacyLogProvider interface {
|
||||
// GetContainerLogTail gets the last few lines of the logs for a specific container.
|
||||
GetContainerLogTail(uid kubetypes.UID, name, namespace string, containerID kubecontainer.ContainerID) (string, error)
|
||||
}
|
||||
|
||||
// NewKubeGenericRuntimeManager creates a new kubeGenericRuntimeManager
|
||||
func NewKubeGenericRuntimeManager(
|
||||
recorder record.EventRecorder,
|
||||
@@ -197,7 +188,6 @@ func NewKubeGenericRuntimeManager(
|
||||
runtimeService internalapi.RuntimeService,
|
||||
imageService internalapi.ImageManagerService,
|
||||
internalLifecycle cm.InternalContainerLifecycle,
|
||||
legacyLogProvider LegacyLogProvider,
|
||||
logManager logs.ContainerLogManager,
|
||||
runtimeClassManager *runtimeclass.Manager,
|
||||
seccompDefault bool,
|
||||
@@ -219,7 +209,6 @@ func NewKubeGenericRuntimeManager(
|
||||
runtimeService: newInstrumentedRuntimeService(runtimeService),
|
||||
imageService: newInstrumentedImageManagerService(imageService),
|
||||
internalLifecycle: internalLifecycle,
|
||||
legacyLogProvider: legacyLogProvider,
|
||||
logManager: logManager,
|
||||
runtimeClassManager: runtimeClassManager,
|
||||
logReduction: logreduction.NewLogReduction(identicalErrorDelay),
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
Copyright 2020 The Kubernetes 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.
|
||||
*/
|
||||
|
||||
package legacy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
||||
"k8s.io/kubernetes/pkg/kubelet/kuberuntime"
|
||||
)
|
||||
|
||||
// DockerLegacyService interface is used throughout `pkg/kubelet`.
|
||||
// It used to live in the `pkg/kubelet/dockershim` package. While we
|
||||
// would eventually like to remove it entirely, we need to give users some form
|
||||
// of warning.
|
||||
//
|
||||
// By including the interface in
|
||||
// `pkg/kubelet/legacy/logs.go`, we ensure the interface is
|
||||
// available to `pkg/kubelet`, even when we are building with the `dockerless`
|
||||
// tag (i.e. not compiling the dockershim).
|
||||
// While the interface always exists, there will be no implementations of the
|
||||
// interface when building with the `dockerless` tag. The lack of
|
||||
// implementations should not be an issue, as we only expect `pkg/kubelet` code
|
||||
// to need an implementation of the `DockerLegacyService` when we are using
|
||||
// docker. If we are using docker, but building with the `dockerless` tag, than
|
||||
// this will be just one of many things that breaks.
|
||||
type DockerLegacyService interface {
|
||||
// GetContainerLogs gets logs for a specific container.
|
||||
GetContainerLogs(context.Context, *v1.Pod, kubecontainer.ContainerID, *v1.PodLogOptions, io.Writer, io.Writer) error
|
||||
|
||||
// IsCRISupportedLogDriver checks whether the logging driver used by docker is
|
||||
// supported by native CRI integration.
|
||||
// TODO(resouer): remove this when deprecating unsupported log driver
|
||||
IsCRISupportedLogDriver() (bool, error)
|
||||
|
||||
kuberuntime.LegacyLogProvider
|
||||
}
|
||||
Reference in New Issue
Block a user