Commit Graph

430 Commits (01881d3f0cf031251ca3201b2ef0120f0818e78a)

Author SHA1 Message Date
Yu-Ju Hong 331628b7dc Move prometheus metrics for docker operations into dockershim 2017-09-25 10:03:17 -07:00
Kubernetes Submit Queue fc8a647f78 Merge pull request #52864 from dcbw/dockershim-fix-net-teardown
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>..

dockershim: fine-tune network-ready handling on sandbox teardown and removal

If sandbox teardown results in an error, GC will periodically attempt
to again remove the sandbox.  Until the sandbox is removed, pod
sandbox status calls will attempt to enter the pod's namespace and
retrieve the pod IP, but the first teardown attempt may have already
removed the network namespace, resulting in a pointless log error
message that the network namespace doesn't exist, or that nsenter
can't find eth0.

The network-ready mechanism originally attempted to suppress those
messages by ensuring that pod sandbox status skipped network checks
when networking was already torn down, but unfortunately the ready
value was cleared too early.

Also, don't tear down the pod network multiple times if the first
time we tore it down, it succeeded.



**What this PR does / why we need it**:

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #

**Special notes for your reviewer**:

**Release note**:

```release-note
```
2017-09-24 04:32:12 -07:00
Kubernetes Submit Queue ffe122d89c Merge pull request #52220 from yujuhong/rm-legacy-code
Automatic merge from submit-queue (batch tested with PRs 52240, 48145, 52220, 51698, 51777). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>..

dockershim: remove support for legacy containers

The code was first introduced in 1.6 to help pre-CRI-kubelet upgrade to
using the CRI implementation. They can safely be removed now.
2017-09-23 09:14:00 -07:00
Yu-Ju Hong 3837a016ef kubelet: remove the --docker-exec-handler flag
Stop supporting the "nsenter" exec handler. Only the Docker native exec
handler is supported.

The flag was deprecated in Kubernetes 1.6 and is safe to remove
in Kubernetes 1.9 according to the deprecation policy.
2017-09-22 12:13:31 -07:00
Dan Williams ddb5075842 dockershim: fine-tune network-ready handling on sandbox teardown and removal
If sandbox teardown results in an error, GC will periodically attempt
to again remove the sandbox.  Until the sandbox is removed, pod
sandbox status calls will attempt to enter the pod's namespace and
retrieve the pod IP, but the first teardown attempt may have already
removed the network namespace, resulting in a pointless log error
message that the network namespace doesn't exist, or that nsenter
can't find eth0.

The network-ready mechanism originally attempted to suppress those
messages by ensuring that pod sandbox status skipped network checks
when networking was already torn down, but unfortunately the ready
value was cleared too early.

Also, don't tear down the pod network multiple times if the first
time we tore it down, it succeeded.
2017-09-21 14:53:50 -05:00
Lantao Liu d387eab817 Fix CRI container/imagefs stats. 2017-09-18 07:48:20 +00:00
Kubernetes Submit Queue c6a9b1e198 Merge pull request #52125 from yujuhong/fix-file-sync
Automatic merge from submit-queue (batch tested with PRs 52339, 52343, 52125, 52360, 52301)

dockershim: check if f.Sync() returns an error and surface it

```release-note
dockershim: check the error when syncing the checkpoint.
```
2017-09-12 21:45:56 -07:00
Yu-Ju Hong aaf26b2eaa dockershim: remove support for legacy containers
The code was first introduced in 1.6 to help pre-CRI-kubelet upgrade to
using the CRI implementation. They can safely be removed now.
2017-09-11 08:44:27 -07:00
Pengfei Ni 4d5d97438b Use credentials from providers for docker sandbox image 2017-09-09 07:02:04 +08:00
Yu-Ju Hong a850614613 dockershim: check if f.Sync() returns an error and surface it 2017-09-07 16:05:02 -07:00
David Ashpole e5a6a79fd7 update cadvisor, docker, and runc godeps 2017-09-05 12:38:57 -07:00
Jan Safranek 0c767355d8 Implement mount propagation in docker shim 2017-09-01 21:36:33 +02:00
Kubernetes Submit Queue 2ab7ad14b4 Merge pull request #47991 from ncdc/fix-initial-exec-terminal-dimensions
Automatic merge from submit-queue

Fix initial exec terminal dimensions

**What this PR does / why we need it**:
Delay attempting to send a terminal resize request to docker until after
the exec has started; otherwise, the initial resize request will fail.

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #47990

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
2017-08-18 14:47:11 -07:00
Kubernetes Submit Queue e86f43bcab Merge pull request #50796 from yguo0905/hc
Automatic merge from submit-queue (batch tested with PRs 50563, 50698, 50796)

Disable Docker's health check until we officially support it

Ref: https://github.com/kubernetes/kubernetes/issues/50703

Tested locally.

Without this PR:

```
CONTAINER ID        IMAGE                                                  COMMAND                  CREATED             STATUS                     PORTS               NAMES
afdd796ddddc        gcr.io/ygg-gke-dev/nginx-healthcheck                   "nginx -g 'daemon ..."   5 minutes ago       Up 5 minutes (healthy)                       k8s_test-container_test-pod_default_8a1ad225-82bf-11e7-becb-480fcf514648_0
```

With this PR:
```
e3fb2437555f        gcr.io/ygg-gke-dev/nginx-healthcheck                   "nginx -g 'daemon ..."   10 seconds ago      Up 9 seconds                            k8s_test-container_test-pod_default_de82e83c-82c0-11e7-b3fc-480fcf514648_0
```

**Release note**:

```
Disable Docker's health check until we officially support it.
```

/assign @yujuhong 
/assign @dchen1107
2017-08-17 12:18:33 -07:00
Yang Guo fe06c7ec64 Disables Docker's health check 2017-08-16 16:12:09 -07:00
Kubernetes Submit Queue c743e68fb1 Merge pull request #50694 from dims/fix-make-cross-problem-with-helpers
Automatic merge from submit-queue (batch tested with PRs 50694, 50702)

Fix make cross build failure

**What this PR does / why we need it**:

had to fix the method getSecurityOpts in helpers_windows.go to
match the implementation in helpers_linux.go from commit:
bf01fa2f00


**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #

Fixes #50675

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
2017-08-15 14:28:24 -07:00
Davanum Srinivas 493ee8b285 Fix make cross build failure
had to fix the method getSecurityOpts in helpers_windows.go to
match the implementation in helpers_linux.go from commit:
bf01fa2f00

Fixes #50675
2017-08-15 14:25:35 -04:00
Michael Taufen 24bab4c20f move KubeletConfiguration out of componentconfig API group 2017-08-15 08:12:42 -07:00
Pengfei Ni ea4a3417e7 run hack/update-bazel.sh 2017-08-13 15:43:42 +08:00
Pengfei Ni c242432a3b Rename runtime/default to docker default 2017-08-13 15:42:15 +08:00
Pengfei Ni bf01fa2f00 Use seccomp from security context 2017-08-13 15:42:15 +08:00
Kubernetes Submit Queue b9b875f0d7 Merge pull request #46105 from sjenning/update-conatiner-resource-cri
Automatic merge from submit-queue (batch tested with PRs 49488, 50407, 46105, 50456, 50258)

Add UpdateContainerResources method to CRI

This is first step toward support for opinionated cpu pinning for certain guaranteed pods.

In order to do this, the kubelet needs to be able to dynamically update the cpuset at the container level, which is managed by the container runtime.  Thus the kubelet needs a method to communicate over the CRI so the runtime can then modify the container cgroup.

This is used in the situation where a core is added or removed from the shared pool to become a exclusive core for a new G pod.  The cpuset for all containers in the shared pool will need to be updated to add or remove that core.

Opening this up now so we can start discussion.  The need for a change to the CRI might be unexpected.

@derekwaynecarr @vishh @ConnorDoyle 

```release-note
NONE
```
2017-08-11 14:14:00 -07:00
Jeff Grafton a7f49c906d Use buildozer to delete licenses() rules except under third_party/ 2017-08-11 09:32:39 -07:00
Jeff Grafton 33276f06be Use buildozer to remove deprecated automanaged tags 2017-08-11 09:31:50 -07:00
Jeff Grafton cf55f9ed45 Autogenerate BUILD files 2017-08-11 09:30:23 -07:00
Pengfei Ni 9da9e2ab59 Create container log symlink for all containers 2017-08-11 17:36:28 +08:00
Seth Jennings 9fbf8f57dd add UpdateContainerResources function to CRI 2017-07-31 20:47:56 -05:00
Kubernetes Submit Queue 72c6251508 Merge pull request #47019 from jessfraz/allowPrivilegeEscalation
Automatic merge from submit-queue (batch tested with PRs 49651, 49707, 49662, 47019, 49747)

Add support for `no_new_privs` via AllowPrivilegeEscalation

**What this PR does / why we need it**:
Implements kubernetes/community#639
Fixes #38417

Adds `AllowPrivilegeEscalation` and `DefaultAllowPrivilegeEscalation` to `PodSecurityPolicy`.
Adds `AllowPrivilegeEscalation` to container `SecurityContext`.

Adds the proposed behavior to `kuberuntime`, `dockershim`, and `rkt`. Adds a bunch of unit tests to ensure the desired default behavior and that when `DefaultAllowPrivilegeEscalation` is explicitly set.

Tests pass locally with docker and rkt runtimes. There are also a few integration tests with a `setuid` binary for sanity.

**Release note**:

```release-note
Adds AllowPrivilegeEscalation to control whether a process can gain more privileges than it's parent process
```
2017-07-31 16:56:58 -07:00
Andy Goldstein a4811daf31 Fix initial exec terminal dimensions
Delay attempting to send a terminal resize request to docker until after
the exec has started; otherwise, the initial resize request will fail.
2017-07-31 11:52:27 -04:00
Kubernetes Submit Queue f2dc80bfe5 Merge pull request #48822 from caseydavenport/drive-by-fix-todo
Automatic merge from submit-queue (batch tested with PRs 47738, 49196, 48907, 48533, 48822)

Fix TODO: rename podInfraContainerID to sandboxID

**What this PR does / why we need it**:

Code-cleanup in kubelet to use consistent naming for sandbox ID. Not super urgent, but thought it would be nice to knock off some TODOs. 

**Which issue this PR fixes**

Fixes a TODO in the code, no associated issue.

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
2017-07-28 03:10:37 -07:00
Jess Frazelle 0f349cc61f
allowPrivilegeEscalation: modify api types & add functionality
Signed-off-by: Jess Frazelle <acidburn@google.com>
2017-07-24 12:52:41 -04:00
Casey Davenport 78709456ab Fix TODO: rename podInfraContainerID to podSandboxID 2017-07-20 17:45:55 -07:00
Kubernetes Submit Queue feed4aa12a Merge pull request #49234 from mengqiy/master
Automatic merge from submit-queue (batch tested with PRs 49107, 47177, 49234, 49224, 49227)

Move util/exec to vendor

Move util/exec to vendor.
Update import paths.
Update godep

Part of #48209

Associate PR against `k8s.io/utils` repo: https://github.com/kubernetes/utils/pull/5

```release-note
NONE
```

/assign @apelisse
2017-07-20 15:08:22 -07:00
Kubernetes Submit Queue 84f773850e Merge pull request #49107 from edevil/try_remove_old_log
Automatic merge from submit-queue (batch tested with PRs 49107, 47177, 49234, 49224, 49227)

Make sure the previous symlink file is deleted before trying to create a new one

**What this PR does / why we need it**:

It deletes possibly existing symlinks to container log files.

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #

fixes #49105

**Special notes for your reviewer**:

**Release note**:

```release-note
```
2017-07-20 15:08:17 -07:00
ymqytw 9b393a83d4 update godep 2017-07-20 11:03:49 -07:00
ymqytw 3dfc8bf7f3 update import 2017-07-20 11:03:49 -07:00
André Cruz 89012ccb23 Fix test 2017-07-19 17:14:35 +01:00
André Cruz 9f81cf096b Make sure the previous symlink file is deleted
before trying to create a new one.
2017-07-18 12:06:31 +01:00
Jeff Grafton 3962b5dccf Fix compilation failure in dockershim for windows 2017-07-14 18:15:26 -07:00
Yang Guo bf2ced837c Updates Docker Engine API 2017-07-13 12:55:07 -07:00
Kubernetes Submit Queue fa72912897 Merge pull request #48742 from yujuhong/rm-unused
Automatic merge from submit-queue (batch tested with PRs 48405, 48742, 48748, 48571, 48482)

dockershim: clean up unused security context code

Most of the code in the `dockershim/securitycontext` package are
unused and can be removed. This PR migrates the rest of the code,
cleans it up (e.g., remove references to kubernetes API objects),
and removes the package entirely.
2017-07-12 08:05:15 -07:00
Yu-Ju Hong e6ad8f8e48 dockershim: clean up unused security context code
Also remove references to kubernetes api objects
2017-07-10 17:48:26 -07:00
Tim Allclair a2f2e1d491 Name change: s/timstclair/tallclair/ 2017-07-10 14:05:46 -07:00
ymqytw ce561b2044 fix cross build for windows 2017-07-05 12:42:41 -07:00
ymqytw f0ce897277 move term to kubectl/util 2017-06-30 15:00:24 -07:00
Kubernetes Submit Queue 1cca341b17 Merge pull request #47850 from dcbw/checkpoint-hostnetwork
Automatic merge from submit-queue (batch tested with PRs 47850, 47835, 46197, 47250, 48284)

dockershim: checkpoint HostNetwork property

To ensure kubelet doesn't attempt network teardown on HostNetwork
containers that no longer exist but are still checkpointed, make
sure we preserve the HostNetwork property in checkpoints.  If
the checkpoint indicates the container was a HostNetwork one,
don't tear down the network since that would fail anyway.

Related: https://github.com/kubernetes/kubernetes/issues/44307#issuecomment-299548609

@freehan @kubernetes/sig-network-misc
2017-06-29 15:16:37 -07:00
Kubernetes Submit Queue c9ad8dcde0 Merge pull request #47900 from yiqinguo/yiqinguo_add_type_judgment
Automatic merge from submit-queue

Add type conversion judgment

If do not type conversion judgment, there may be panic.

**Release note**:
```release-note
NONE
```
2017-06-29 04:00:18 -07:00
Dong Liu 4df4ea2bea Move seccomp helper methods and tests to platform-specific files. 2017-06-23 09:49:06 +08:00
Chao Xu 60604f8818 run hack/update-all 2017-06-22 11:31:03 -07:00
Chao Xu f4989a45a5 run root-rewrite-v1-..., compile 2017-06-22 10:25:57 -07:00
yiqinguo d170b0ca80 Add type conversion judgment 2017-06-22 20:17:28 +08:00
Dan Williams 5100925a90 dockershim: checkpoint HostNetwork property
To ensure kubelet doesn't attempt network teardown on HostNetwork
containers that no longer exist but are still checkpointed, make
sure we preserve the HostNetwork property in checkpoints.  If
the checkpoint indicates the container was a HostNetwork one,
don't tear down the network since that would fail anyway.

Related: https://github.com/kubernetes/kubernetes/issues/44307#issuecomment-299548609
2017-06-21 13:10:47 -05:00
mbohlool 70c4fe7f4f update generated files 2017-06-21 04:09:08 -07:00
mbohlool c91a12d205 Remove all references to types.UnixUserID and types.UnixGroupID 2017-06-21 04:09:07 -07:00
Derek Carr 4a5a221d8f parse executable not found error 2017-06-13 23:31:56 -04:00
Kubernetes Submit Queue 22dc980aa4 Merge pull request #46823 from dcbw/fix-up-runtime-GetNetNS2
Automatic merge from submit-queue (batch tested with PRs 46441, 43987, 46921, 46823, 47276)

kubelet/network: report but tolerate errors returned from GetNetNS() v2

Runtimes should never return "" and nil errors, since network plugin
drivers need to treat netns differently in different cases. So return
errors when we can't get the netns, and fix up the plugins to do the
right thing.

Namely, we don't need a NetNS on pod network teardown. We do need
a netns for pod Status checks and for network setup.

V2: don't return errors from getIP(), since they will block pod status :(  Just log them.  But even so, this still fixes the original problem by ensuring we don't log errors when the network isn't ready.

@freehan @yujuhong 

Fixes: https://github.com/kubernetes/kubernetes/issues/42735
Fixes: https://github.com/kubernetes/kubernetes/issues/44307
2017-06-13 13:55:50 -07:00
Dan Williams f76cc7642c dockershim: don't spam logs with pod IP errors before networking is ready
GenericPLEG's 1s relist() loop races against pod network setup.  It
may be called after the infra container has started but before
network setup is done, since PLEG and the runtime's SyncPod() run
in different goroutines.

Track network setup status and don't bother trying to read the pod's
IP address if networking is not yet ready.

See also: https://bugzilla.redhat.com/show_bug.cgi?id=1434950

Mar 22 12:18:17 ip-172-31-43-89 atomic-openshift-node: E0322
   12:18:17.651013   25624 docker_manager.go:378] NetworkPlugin
   cni failed on the status hook for pod 'pausepods22' - Unexpected
   command output Device "eth0" does not exist.
2017-06-12 15:07:38 -05:00
Dan Williams 45dffed8ac kubelet/network: return but tolerate errors returned from GetNetNS()
Runtimes should never return "" and nil errors, since network plugin
drivers need to treat netns differently in different cases.  So return
errors when we can't get the netns, and fix up the plugins to do the
right thing.

Namely, we don't need a NetNS on pod network teardown.  We do need
a netns for pod Status checks and for network setup.
2017-06-12 14:46:13 -05:00
Dan Williams 72710b7542 Revert "Return empty network namespace if the infra container has exited"
This reverts commit fee4c9a7d9.

This is not the correct fix for the problem; and it causes other problems
like continuous:

docker_sandbox.go:234] NetworkPlugin cni failed on the status hook for pod
"someotherdc-1-deploy_default": Unexpected command output nsenter: cannot
open : No such file or directory with error: exit status 1

Because GetNetNS() is returning an empty network namespace.  That is
not helpful nor should really be allowed; that's what the error return
from GetNetNS() is for.
2017-06-12 14:46:13 -05:00
Dong Liu a82b8f1094 Fix hostconfig device map logic in dockershim. 2017-06-12 11:15:46 +08:00
Pengfei Ni 22e99504d7 Update CRI references 2017-06-09 10:16:40 +08:00
Dong Liu 5936e81b2e Add determinePodIPBySandboxID. 2017-06-02 08:03:07 -05:00
Dong Liu 6d07fc2f44 Add updateCreateConfig. 2017-06-02 05:59:21 -05:00
Dong Liu 9c2309b7cb Add os dependent getSecurityOpts helper method. 2017-06-02 05:59:20 -05:00
Dawn Chen 78c1649f5b Revert "kubelet/network: report but tolerate errors returned from GetNetNS()" 2017-05-31 17:16:32 -07:00
Kubernetes Submit Queue 3702352aa9 Merge pull request #43879 from dcbw/fix-up-runtime-GetNetNS
Automatic merge from submit-queue (batch tested with PRs 46076, 43879, 44897, 46556, 46654)

kubelet/network: report but tolerate errors returned from GetNetNS()

Runtimes should never return "" and nil errors, since network plugin
drivers need to treat netns differently in different cases.  So return
errors when we can't get the netns, and fix up the plugins to do the
right thing.

Namely, we don't need a NetNS on pod network teardown.  We do need
a netns for pod Status checks and for network setup.

@kubernetes/rh-networking @kubernetes/sig-network-bugs @DirectXMan12
2017-05-30 23:19:59 -07:00
Kubernetes Submit Queue 20ec8912d0 Merge pull request #45421 from allencloud/change-to-use-make-slice-to-store-objects
Automatic merge from submit-queue

use make slice to store objects to improve efficiency

Signed-off-by: allencloud <allen.sun@daocloud.io>



**What this PR does / why we need it**:

we we know the slice length in advance, I think we had better use make to create the specified length of slice. This will improve some kind of performance. Since if we create a slice with []type{}, we did not know how much space runtime should reserve, since slice implementation should be continuous in memory. While when we make a slice with specified length, runtime would reserve a continuous memory space which will not result in slice movement in case of current space is not enough.

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #
NONE

**Special notes for your reviewer**:
NONE

**Release note**:

```release-note
NONE
```
2017-05-30 06:27:18 -07:00
Kubernetes Submit Queue 761a75218c Merge pull request #46236 from abgworrall/abw-45738
Automatic merge from submit-queue (batch tested with PRs 46252, 45524, 46236, 46277, 46522)

Support sandbox images from private registries

**What this PR does / why we need it**:

The --pod-infra-container-image parameter allows the user to specify
an arbitrary image to be used as the pod infra container (AKA
sandbox), an internal piece of the dockershim implementation of the
Container Runtime Interface.

The dockershim does not have access to any of the pod-level image pull
credentials configuration, so if the user specifies an image from a
private registry, the image pull will fail.

This change allows the dockershim to read local docker configuration
(e.g. /root/.docker/config.json) and use it when pulling the pod infra
container image.

**Which issue this PR fixes**: fixes #45738

**Special notes for your reviewer**:
The changes to fake_client for writing local config files deserve some
attention.

**Release note**:

```release-note
NONE
```
2017-05-26 19:47:59 -07:00
Kubernetes Submit Queue e903c58c9e Merge pull request #45614 from yujuhong/container-metrics
Automatic merge from submit-queue (batch tested with PRs 45809, 46515, 46484, 46516, 45614)

CRI: add methods for container stats

**What this PR does / why we need it**:
Define methods in CRI to get container stats.

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: 
Part of  https://github.com/kubernetes/features/issues/290; addresses #27097

**Special notes for your reviewer**:
This PR defines the *minimum required* container metrics for the existing components to function, loosely based on the previous discussion on [core metrics](https://github.com/kubernetes/community/blob/master/contributors/design-proposals/core-metrics-pipeline.md) as well as the existing cadvisor/summary APIs.
 
Two new RPC calls are added to the RuntimeService: `ContainerStats` and `ListContainerStats`. The former retrieves stats for a given container, while the latter gets stats for all containers in one call.
 
The stats gathering time of each subsystem can vary substantially (e.g., cpu vs. disk), so even though the on-demand model preferred due to its simplicity, we’d rather give the container runtime more flexibility to determine the collection frequency for each subsystem*. As a trade-off, each piece of stats for the subsystem must contain a timestamp to let kubelet know how fresh/recent the stats are. In the future, we should also recommend a guideline for how recent the stats should be in order to ensure the reliability (e.g., eviction) and the responsiveness (e.g., autoscaling) of the kubernetes cluster.
 
The next step is to plumb this through kubelet so that kubelet can choose consume container stats from CRI or cadvisor. 
 
**Alternatively, we can add calls to get stats of individual subsystems. However, kubelet does not have the complete knowledge of the runtime environment, so this would only lead to unnecessary complexity in kubelet.*


**Release note**:

```release-note
Augment CRI to support retrieving container stats from the runtime.
```
2017-05-26 16:59:08 -07:00
Kubernetes Submit Queue 6d6413175f Merge pull request #46417 from resouer/fix-digest-nit
Automatic merge from submit-queue (batch tested with PRs 42256, 46479, 45436, 46440, 46417)

Log out digest when digest is invalid

Notice this in frakti: missing image ref when logging it out.

**Release note**:

```release-note
NONE
```
2017-05-26 15:59:05 -07:00
Adam Worrall d44c458a19 Support sandbox images from private registries
**What this PR does / why we need it**:

The --pod-infra-container-image parameter allows the user to specify
an arbitrary image to be used as the pod infra container (AKA
sandbox), an internal piece of the dockershim implementation of the
Container Runtime Interface.

The dockershim does not have access to any of the pod-level image pull
credentials configuration, so if the user specifies an image from a
private registry, the image pull will fail.

This change allows the dockershim to read local docker configuration
(e.g. /root/.docker/config.json) and use it when pulling the pod infra
container image.

**Which issue this PR fixes**: fixes #45738

**Special notes for your reviewer**:
The changes to fake_client for writing local config files deserve some
attention.

**Release note**:

```release-note
NONE
```
2017-05-26 12:17:10 -07:00
Kubernetes Submit Queue 5e853709a7 Merge pull request #46089 from karataliu/wincri1
Automatic merge from submit-queue (batch tested with PRs 46124, 46434, 46089, 45589, 46045)

Support TCP type runtime endpoint for kubelet

**What this PR does / why we need it**:
Currently the grpc server for kubelet and dockershim has a hardcoded endpoint: unix socket '/var/run/dockershim.sock', which is not applicable on non-unix OS.

This PR is to support TCP endpoint type besides unix socket.

**Which issue this PR fixes** 
This is a first attempt to address issue https://github.com/kubernetes/kubernetes/issues/45927

**Special notes for your reviewer**:
Before this change, running on Windows node results in:
```
Container Manager is unsupported in this build
```

After adding the cm stub, error becomes:
```
listen unix /var/run/dockershim.sock: socket: An address incompatible with the requested protocol was used.
```

This PR is to fix those two issues.

After this change, still meets 'seccomp' related issue when running on Windows node, needs more updates later.

**Release note**:
2017-05-25 21:40:02 -07:00
Harry Zhang 4f4b161fc7 Log out digest when digest is invalid 2017-05-25 16:46:56 +08:00
Dong Liu fb26c9100a Support TCP type runtime endpoint for kubelet. 2017-05-25 09:16:11 +08:00
Yu-Ju Hong 417e9c8cea Update all relevant interfaces and create stubs 2017-05-24 15:21:16 -07:00
Dan Williams 02200ba752 dockershim: don't spam logs with pod IP errors before networking is ready
GenericPLEG's 1s relist() loop races against pod network setup.  It
may be called after the infra container has started but before
network setup is done, since PLEG and the runtime's SyncPod() run
in different goroutines.

Track network setup status and don't bother trying to read the pod's
IP address if networking is not yet ready.

See also: https://bugzilla.redhat.com/show_bug.cgi?id=1434950

Mar 22 12:18:17 ip-172-31-43-89 atomic-openshift-node: E0322
   12:18:17.651013   25624 docker_manager.go:378] NetworkPlugin
   cni failed on the status hook for pod 'pausepods22' - Unexpected
   command output Device "eth0" does not exist.
2017-05-23 22:42:41 -05:00
Dan Williams 9e1385b450 kubelet/network: return but tolerate errors returned from GetNetNS()
Runtimes should never return "" and nil errors, since network plugin
drivers need to treat netns differently in different cases.  So return
errors when we can't get the netns, and fix up the plugins to do the
right thing.

Namely, we don't need a NetNS on pod network teardown.  We do need
a netns for pod Status checks and for network setup.
2017-05-23 22:33:12 -05:00
Dan Williams 2036868a7d Revert "Return empty network namespace if the infra container has exited"
This reverts commit fee4c9a7d9.

This is not the correct fix for the problem; and it causes other problems
like continuous:

docker_sandbox.go:234] NetworkPlugin cni failed on the status hook for pod
"someotherdc-1-deploy_default": Unexpected command output nsenter: cannot
open : No such file or directory with error: exit status 1

Because GetNetNS() is returning an empty network namespace.  That is
not helpful nor should really be allowed; that's what the error return
from GetNetNS() is for.
2017-05-23 22:33:12 -05:00
zhengjiajin c79b0c797f fix typo in kubelet 2017-05-23 19:54:10 +08:00
Clayton Coleman 3e095d12b4
Refactor move of client-go/util/clock to apimachinery 2017-05-20 14:19:48 -04:00
Kubernetes Submit Queue f82bdca459 Merge pull request #44326 from xlgao-zju/forcibly-remove
Automatic merge from submit-queue (batch tested with PRs 44326, 45768)

[CRI] Forcibly remove container

Forcibly remove the running containers in `RemoveContainer`. Since we should forcibly remove the running containers in `RemovePodSandbox`. See [here](https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/api/v1alpha1/runtime/api.proto#L35).

cc @feiskyer @Random-Liu 

Signed-off-by: Xianglin Gao <xlgao@zju.edu.cn>
2017-05-16 10:39:05 -07:00
Kubernetes Submit Queue 576d1d243e Merge pull request #45408 from Carlory/fix-typo
Automatic merge from submit-queue

fix typo in docker_container.go

Signed-off-by: Carlory <fanbaofa@gmail.com>



**What this PR does / why we need it**:
fix typo in docker_container.go

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #
NONE

**Special notes for your reviewer**:
NONE

**Release note**:

```release-note
NONE
```
2017-05-16 09:06:38 -07:00
Kubernetes Submit Queue e11963194e Merge pull request #45808 from Crazykev/quick-fix
Automatic merge from submit-queue (batch tested with PRs 45171, 43947, 45788, 45822, 45808)

[CRI] Continue remove image when can't find image id with ImageRef

Signed-off-by: Crazykev <crazykev@zju.edu.cn>



**What this PR does / why we need it**: 
Should try to remove imageRef as repo:tag when can't find it as imageID.
/cc @feiskyer @Random-Liu  PTAL
also /cc @xlgao-zju @heartlock

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #

**Special notes for your reviewer**:

**Release note**:

```release-note
None
```
2017-05-15 14:24:51 -07:00
Kubernetes Submit Queue f6bcd28cd7 Merge pull request #41331 from dshulyak/import_remotecommand
Automatic merge from submit-queue (batch tested with PRs 41331, 45591, 45600, 45176, 45658)

Move client/unversioned/remotecommand to client-go

Module remotecommand originally part of kubernetes/pkg/client/unversioned was moved
to client-go/tools, and will be used as authoritative in kubectl, e2e and other places.

Module remotecommand relies on util/exec module which was copied to client-go/pkg/util
2017-05-15 13:25:42 -07:00
Dmitry Shulyak a713604b24 Use streaming constants from pkg/api/v1 instead of pkg/api 2017-05-15 17:00:14 +03:00
Dmitry Shulyak 2612e0c78a Move client/unversioned/remotecommand to client-go
Module remotecommand originally part of kubernetes/pkg/client/unversioned was moved
to client-go/tools, and will be used as authoritative in kubectl, e2e and other places.

Module remotecommand relies on util/exec module which will be copied to client-go/pkg/util
2017-05-15 16:28:56 +03:00
Crazykev 1369a263f5 continue remove image when can't find image id with ref
Signed-off-by: Crazykev <crazykev@zju.edu.cn>
2017-05-15 19:12:29 +08:00
Pengfei Ni 2b4956c208 dockershim: get sysctls from sandbox config instead of annotations 2017-05-15 12:53:32 +08:00
heartlock 8e702347ad set LogPath in dockershim
Signed-off-by: heartlock <21521209@zju.edu.cn>
2017-05-13 03:24:44 +00:00
Michael Taufen cbad320205 Reorganize kubelet tree so apis can be independently versioned 2017-05-12 10:02:33 -07:00
Kubernetes Submit Queue e1bb9a5177 Merge pull request #45667 from yujuhong/mv-pull-tests
Automatic merge from submit-queue (batch tested with PRs 45691, 45667, 45698, 45715)

dockertools: migrate the unit tests and delete the package
2017-05-12 04:09:41 -07:00
Yu-Ju Hong fccf34ccb6 Remove various references of dockertools
Also update the bazel files.
2017-05-11 10:01:41 -07:00
Yu-Ju Hong 4b72d229f7 Migrate unit tests for image pulling credentials and error handling
Also remove the dockertools package completely.
2017-05-11 10:01:41 -07:00
Crazykev ebb5c3d13d return success if ImageNotFound in RemoveImage()
Signed-off-by: Crazykev <crazykev@zju.edu.cn>
2017-05-11 23:00:34 +08:00
Xianglin Gao 0144803c07 Forcibly remove container
Signed-off-by: Xianglin Gao <xlgao@zju.edu.cn>
2017-05-11 18:39:37 +08:00
Kubernetes Submit Queue 51a3413371 Merge pull request #45307 from yujuhong/mv-docker-client
Automatic merge from submit-queue (batch tested with PRs 45453, 45307, 44987)

Migrate the docker client code from dockertools to dockershim

Move docker client code from dockertools to dockershim/libdocker. This includes
DockerInterface (renamed to Interface), FakeDockerClient, etc.

This is part of #43234
2017-05-09 20:23:44 -07:00
Kubernetes Submit Queue 60e02711d4 Merge pull request #44126 from xiangpengzhao/fix-const
Automatic merge from submit-queue (batch tested with PRs 45508, 44258, 44126, 45441, 45320)

Use existing global var criSupportedLogDrivers

**What this PR does / why we need it**:
Use existing global var `criSupportedLogDrivers` defined in docker_service.go. If CRI supports other log drivers in the future, we will only need to modify that global var.

cc @Random-Liu
2017-05-08 16:34:44 -07:00
Yu-Ju Hong cf3635c876 Update bazel BUID files 2017-05-05 11:48:08 -07:00
Yu-Ju Hong 389c140eaf Move docker client code from dockertools to dockershim/dockerlib
The code affected include DockerInterface (renamed to Interface),
FakeDockerClient, etc.
2017-05-05 11:48:08 -07:00
allencloud 503c19aec3 use make slice to store objects to improve efficiency
Signed-off-by: allencloud <allen.sun@daocloud.io>
2017-05-05 23:25:56 +08:00
Jamie Hannaford 9440a68744 Use dedicated Unix User and Group ID types 2017-05-05 14:07:38 +02:00
Carlory 849454cd72 fix typo in docker_container.go
Signed-off-by: Carlory <fanbaofa@gmail.com>
2017-05-05 10:38:44 +00:00
Kubernetes Submit Queue 3a259d38b2 Merge pull request #45292 from yujuhong/seccomp_test
Automatic merge from submit-queue (batch tested with PRs 44068, 45292)

Add the seccomp profile loading test to dockershim

The test was originally in docker_manager_test.go (now removed). I
copied and adapated the logic for the new test. Also move the origina
test fixtures needed for the test.

ref: the original test is at https://github.com/kubernetes/kubernetes/blob/v1.6.2/pkg/kubelet/dockertools/docker_manager_linux_test.go#L294

This is part of #43234
2017-05-03 20:50:00 -07:00
Kubernetes Submit Queue 08a825c9e9 Merge pull request #44068 from mkumatag/k8s_add_apiversion
Automatic merge from submit-queue

Use Docker API Version instead of docker version

**What this PR does / why we need it**:

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #
Fixes #42492
**Special notes for your reviewer**:

**Release note**:

`Update cadvisor to latest head to use docker APIversion exposed by cadvisor`
2017-05-03 20:21:45 -07:00
xiangpengzhao 9af3b0a406 Use existed global var criSupportedLogDrivers and helper function IsCRISupportedLogDriver 2017-05-04 10:25:21 +08:00
Kubernetes Submit Queue 84f41f3388 Merge pull request #41733 from feiskyer/images
Automatic merge from submit-queue (batch tested with PRs 45314, 45250, 41733)

CRI: add ImageFsInfo API

**What this PR does / why we need it**:

kubelet currently relies on cadvisor to get the ImageFS info for supported runtimes, i.e., docker and rkt. This PR adds ImageFsInfo API to CRI so kubelet could get the ImageFS correctly for all runtimes.

**Which issue this PR fixes** 

First step for  #33048 ~~also reverts temporary ImageStats in #33870~~.

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
2017-05-03 18:47:04 -07:00
Yu-Ju Hong 3cd6b21b77 Add the seccomp profile loading test to dockershim
The test was originally in docker_manager_test.go (now removed). I
copied and adapated the logic for the new test.

Also move the original test fixtures needed for the test.
2017-05-03 12:55:56 -07:00
Yu-Ju Hong 51188e6f70 Update bazel files 2017-05-03 11:22:06 -07:00
Yu-Ju Hong 5644587e07 More dockertools cleanup
Move some constants/functions to dockershim and remove unused tests.
2017-05-03 11:22:06 -07:00
Pengfei Ni 5f7de0ab97 Add ImageFsInfo API for ImageManagerService 2017-05-03 15:17:45 +08:00
Kubernetes Submit Queue 2371a70b7a Merge pull request #45166 from feiskyer/namespace-network
Automatic merge from submit-queue (batch tested with PRs 45013, 45166)

CRI: remove PodSandboxStatus.Linux.Namespaces.Network

**What this PR does / why we need it**:

PodSandboxStatus.Linux.Namespaces.Network is not used, so this PR removes it from CRI.

**Which issue this PR fixes**

Closes: #44972

**Special notes for your reviewer**:

**Release note**:

```release-note
Remove PodSandboxStatus.Linux.Namespaces.Network from CRI.
```

/assign @Random-Liu @yujuhong
2017-05-02 23:46:03 -07:00
Pengfei Ni d301f22863 CRI: remove PodSandboxStatus.Linux.Namespaces.Network
Closes: #44972
2017-05-02 10:34:41 +08:00
Yu-Ju Hong c35c00f3f1 update bazel 2017-05-01 17:32:58 -07:00
Yu-Ju Hong 951b2d922b move securitycontext from dockertools to dockershim 2017-05-01 17:32:38 -07:00
Yu-Ju Hong b209f47562 Move exported constants/functions from dockertools to dockershim
Previously we exported many constants and functions in dockertools to
share with the dockershim package. This change moves such
constants/functions to dockershim and unexport them.

This change involves only mechnical changes and should not have any
functional impact.
2017-05-01 17:25:11 -07:00
Yu-Ju Hong 93ecaf6812 Move exec.go from dockertools to dockershim 2017-05-01 16:00:46 -07:00
Pengfei Ni ac76766a92 CRI: move apparmor annotations to container security context 2017-05-01 20:55:16 +08:00
Lee Verberne d22dd0fa35 Implement shared PID namespace in the dockershim 2017-04-27 23:43:53 +00:00
Manjunath A Kumatagi f8063879a0 Use Docker API Version instead of docker version 2017-04-27 10:05:22 -04:00
Chao Xu d4850b6c2b move pkg/api/v1/helpers.go to subpackage 2017-04-14 14:25:11 -07:00
Mike Danese a05c3c0efd autogenerated 2017-04-14 10:40:57 -07:00
Kubernetes Submit Queue 4653a9b280 Merge pull request #41543 from dshulyak/decouple_remotecommand
Automatic merge from submit-queue (batch tested with PRs 44406, 41543, 44071, 44374, 44299)

Decouple remotecommand

Refactored unversioned/remotecommand to decouple it from undesirable dependencies:

- term package now is not required, and functionality required to resize terminal size can be plugged in directly in kubectl
- in order to remove dependency on kubelet package - constants from kubelet/server/remotecommand were moved to separate util package (pkg/util/remotecommand)
- remotecommand_test.go moved to pkg/client/tests module
2017-04-13 19:52:05 -07:00
Dmitry Shulyak f50480c714 Decouple remotecommand client from term/kubelet dependencies
In order to move client/unversioned/remotecommand to client-go as a followup
for this change we have to decouple it from tons of dependencies
2017-04-13 15:56:40 +03:00
Andy Goldstein 00e11566f2 Make the dockershim root directory configurable
Make the dockershim root directory configurable so things like
integration tests (e.g. in OpenShift) can run as non-root.
2017-04-12 09:06:21 -04:00
supereagle b98c36394d update docker version parser for its new versioning scheme 2017-04-07 14:53:44 +08:00
Kubernetes Submit Queue 27cf62ac29 Merge pull request #43940 from xlgao-zju/rm-all-containers
Automatic merge from submit-queue (batch tested with PRs 42025, 44169, 43940)

[CRI] Remove all containers in the sandbox

Remove all containers in the sandbox, when we remove the sandbox.

/cc @feiskyer @Random-Liu 

Signed-off-by: Xianglin Gao <xlgao@zju.edu.cn>
2017-04-06 17:00:23 -07:00
Kubernetes Submit Queue 62c7c66ff4 Merge pull request #42772 from timchenxiaoyu/sometypo
Automatic merge from submit-queue (batch tested with PRs 44097, 42772, 43880, 44031, 44066)

fix some typo

fix some typo

**Release note**:

```NONE
```
2017-04-05 16:41:20 -07:00
Pengfei Ni 023fe48c98 Do not clear hostPid for host-networked container 2017-04-05 22:34:30 +08:00
Xianglin Gao b9c1d6c7c8 Remove all containers in the sandbox
Signed-off-by: Xianglin Gao <xlgao@zju.edu.cn>
2017-04-05 13:36:30 +08:00
Yu-Ju Hong 19c8b2fb0e Check the error before parsing the apiversion 2017-04-04 09:38:44 -07:00
Kubernetes Submit Queue 6c6f4f0185 Merge pull request #43925 from Random-Liu/fix-dockershim-dns-options
Automatic merge from submit-queue

[CRI] Use DNSOptions passed by CRI in dockershim.

When @xlgao-zju is working on the CRI validation test, he found that dockershim is not using the DNSOptions passed in CRI. https://github.com/kubernetes-incubator/cri-tools/pull/30#issuecomment-290644357

This PR fixed the issue. I've manually tried, for `ClusterFirst` DNSPolicy, the resolv.conf will be:
```
nameserver 8.8.8.8
search corp.google.com prod.google.com prodz.google.com google.com
options ndots:5
```

For `Default` DNSPolicy, the resolv.conf will be:
```
nameserver 127.0.1.1
search corp.google.com prod.google.com prodz.google.com google.com
```

@xlgao-zju You should be able to test after this PR is merged.

/cc @yujuhong @feiskyer
2017-04-03 11:58:23 -07:00
Random-Liu b1ce4b7a1d Use DNSOptions passed by CRI in dockershim. 2017-04-03 10:24:42 -07:00
Xianglin Gao e5b3e0879d make func modifySandboxNamespaceOptions() more robust
Signed-off-by: Xianglin Gao <xlgao@zju.edu.cn>
2017-03-31 14:14:10 +08:00
Kubernetes Submit Queue a7788aff24 Merge pull request #43057 from feiskyer/docker-version
Automatic merge from submit-queue

kubelet: check and enforce minimum docker api version

**What this PR does / why we need it**:

This PR adds enforcing a minimum docker api version (same with what we have do for dockertools).

**Which issue this PR fixes** 

Fixes #42696.

**Release note**:

```release-note
NONE
```
2017-03-26 21:34:04 -07:00
Kubernetes Submit Queue 73a3c05f06 Merge pull request #43428 from feiskyer/typo
Automatic merge from submit-queue (batch tested with PRs 43378, 43216, 43384, 43083, 43428)

Fix tiny typo

**What this PR does / why we need it**:

**Which issue this PR fixes**

Fix type typo introduced by PR #43368.


**Release note**:

```release-note
NONE
```
2017-03-25 21:22:28 -07:00
Kubernetes Submit Queue a4986e38e6 Merge pull request #42556 from resouer/fix-id
Automatic merge from submit-queue (batch tested with PRs 42522, 42545, 42556, 42006, 42631)

Use pod sandbox id in checkpoint

**What this PR does / why we need it**: we should log out sandbox id when checkpoint error

**Release note**:

```NONE
```
2017-03-24 15:10:32 -07:00
Pengfei Ni a16758396c Fix tiny typo 2017-03-21 14:22:33 +08:00
Kubernetes Submit Queue 948e3754f8 Merge pull request #43368 from feiskyer/dns-policy
Automatic merge from submit-queue (batch tested with PRs 43398, 43368)

CRI: add support for dns cluster first policy

**What this PR does / why we need it**:

PR #29378 introduces ClusterFirstWithHostNet policy but only dockertools was updated to support the feature. 

This PR updates kuberuntime to support it for all runtimes.


**Which issue this PR fixes** 

fixes #43352

**Special notes for your reviewer**:

Candidate for v1.6.

**Release note**:

```release-note
NONE
```

cc @thockin @luxas @vefimova @Random-Liu
2017-03-20 13:54:33 -07:00
Pengfei Ni 95c3782043 Rewrite resolv.conf for dockershim
PR #29378 introduces ClusterFirstWithHostNet, but docker doesn't support
setting dns options togather with hostnetwork. This commit rewrites
resolv.conf same as dockertools.
2017-03-20 18:45:39 +08:00
Pengfei Ni 99ed3202f3 Run hack/update-bazel.sh 2017-03-20 17:48:36 +08:00
Pengfei Ni 53b5f2df48 Add unit test for MakePortsAndBindings 2017-03-20 17:47:38 +08:00
Pengfei Ni 2ddaaec199 dockershim: process protocol correctly for port mapping 2017-03-20 16:52:24 +08:00
Kubernetes Submit Queue 222f69cf3c Merge pull request #43030 from yujuhong/rm_corrupted_checkpoint
Automatic merge from submit-queue (batch tested with PRs 42747, 43030)

dockershim: remove corrupted sandbox checkpoints

This is a workaround to ensure that kubelet doesn't block forever when
the checkpoint is corrupted.

This is a workaround for #43021
2017-03-14 22:56:20 -07:00
Yu-Ju Hong 48afc7d4e0 dockershim: call sync() after writing the checkpoint
This ensures the checkpoint files are persisted.
2017-03-14 18:36:51 -07:00
Pengfei Ni 91616f666a kubelet: check and enforce minimum docker api version 2017-03-15 09:28:06 +08:00
Yu-Ju Hong 035afab901 dockershim: remove corrupted sandbox checkpoints
This is a workaround to ensure that kubelet doesn't block forever when
the checkpoint is corrupted.
2017-03-13 15:41:01 -07:00
Kubernetes Submit Queue 9cfc4f1a10 Merge pull request #42739 from yujuhong/created_time
Automatic merge from submit-queue (batch tested with PRs 42762, 42739, 42425, 42778)

FakeDockerClient: add creation timestamp

This fixes #42736
2017-03-09 02:51:38 -08:00
Kubernetes Submit Queue 4cf553f78e Merge pull request #42767 from Random-Liu/cleanup-infra-container-on-error
Automatic merge from submit-queue (batch tested with PRs 42768, 42760, 42771, 42767)

Stop sandbox container when hit network error.

Fixes https://github.com/kubernetes/kubernetes/issues/42698.

This PR stops the sandbox container when hitting a network error.
This PR also adds a unit test for it.

I'm not sure whether we should try teardown pod network after `SetUpPod` failure. We don't do that in dockertools https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/dockertools/docker_manager.go#L2276.

@yujuhong @freehan
2017-03-09 00:08:01 -08:00
Kubernetes Submit Queue 6fac75c80a Merge pull request #42768 from yujuhong/fix_sandbox_listing
Automatic merge from submit-queue

dockershim: Fix the race condition in ListPodSandbox

In ListPodSandbox(), we
 1. List all sandbox docker containers
 2. List all sandbox checkpoints. If the checkpoint does not have a
    corresponding container in (1), we return partial result based on
    the checkpoint.

The problem is that new PodSandboxes can be created between step (1) and
(2). In those cases, we will see the checkpoints, but not the sandbox
containers. This leads to strange behavior because the partial result
from the checkpoint does not include some critical information. For
example, the creation timestamp'd be zero, and that would cause kubelet's
garbage collector to immediately remove the sandbox.

This change fixes that by getting the list of checkpoints before listing
all the containers (since in RunPodSandbox we create them in the reverse
order).
2017-03-08 21:33:31 -08:00
timchenxiaoyu 0bfbd40d4c fix some typo 2017-03-09 09:34:43 +08:00