mirror of https://github.com/k3s-io/k3s
dockershim: clean up comments
parent
868f6e1c5c
commit
b73dfe02b5
|
@ -79,7 +79,8 @@ func (ds *dockerService) ListContainers(filter *runtimeApi.ContainerFilter) ([]*
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateContainer creates a new container in the given PodSandbox
|
// CreateContainer creates a new container in the given PodSandbox
|
||||||
// Note: docker doesn't use LogPath yet.
|
// Docker cannot store the log to an arbitrary location (yet), so we create an
|
||||||
|
// symlink at LogPath, linking to the actual path of the log.
|
||||||
// TODO: check if the default values returned by the runtime API are ok.
|
// TODO: check if the default values returned by the runtime API are ok.
|
||||||
func (ds *dockerService) CreateContainer(podSandboxID string, config *runtimeApi.ContainerConfig, sandboxConfig *runtimeApi.PodSandboxConfig) (string, error) {
|
func (ds *dockerService) CreateContainer(podSandboxID string, config *runtimeApi.ContainerConfig, sandboxConfig *runtimeApi.PodSandboxConfig) (string, error) {
|
||||||
if config == nil {
|
if config == nil {
|
||||||
|
@ -140,7 +141,7 @@ func (ds *dockerService) CreateContainer(podSandboxID string, config *runtimeApi
|
||||||
if rOpts != nil {
|
if rOpts != nil {
|
||||||
hc.Resources = dockercontainer.Resources{
|
hc.Resources = dockercontainer.Resources{
|
||||||
Memory: rOpts.GetMemoryLimitInBytes(),
|
Memory: rOpts.GetMemoryLimitInBytes(),
|
||||||
MemorySwap: -1, // Always disable memory swap.
|
MemorySwap: -1,
|
||||||
CPUShares: rOpts.GetCpuShares(),
|
CPUShares: rOpts.GetCpuShares(),
|
||||||
CPUQuota: rOpts.GetCpuQuota(),
|
CPUQuota: rOpts.GetCpuQuota(),
|
||||||
CPUPeriod: rOpts.GetCpuPeriod(),
|
CPUPeriod: rOpts.GetCpuPeriod(),
|
||||||
|
@ -229,10 +230,10 @@ func (ds *dockerService) StartContainer(containerID string) error {
|
||||||
}
|
}
|
||||||
// Create container log symlink.
|
// Create container log symlink.
|
||||||
if err := ds.createContainerLogSymlink(containerID); err != nil {
|
if err := ds.createContainerLogSymlink(containerID); err != nil {
|
||||||
// Do not stop the container if fail to create symlink, because:
|
// Do not stop the container if we failed to create symlink because:
|
||||||
// 1. This is not a critical failure.
|
// 1. This is not a critical failure.
|
||||||
// 2. We don't have enough information to properly stop container here.
|
// 2. We don't have enough information to properly stop container here.
|
||||||
// Kubelet will surface this error to user with event.
|
// Kubelet will surface this error to user via an event.
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -248,7 +249,7 @@ func (ds *dockerService) StopContainer(containerID string, timeout int64) error
|
||||||
func (ds *dockerService) RemoveContainer(containerID string) error {
|
func (ds *dockerService) RemoveContainer(containerID string) error {
|
||||||
// Ideally, log lifecycle should be independent of container lifecycle.
|
// Ideally, log lifecycle should be independent of container lifecycle.
|
||||||
// However, docker will remove container log after container is removed,
|
// However, docker will remove container log after container is removed,
|
||||||
// we can't prevent that now, so we also cleanup the symlink here.
|
// we can't prevent that now, so we also clean up the symlink here.
|
||||||
err := ds.removeContainerLogSymlink(containerID)
|
err := ds.removeContainerLogSymlink(containerID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -279,7 +280,7 @@ func getContainerTimestamps(r *dockertypes.ContainerJSON) (time.Time, time.Time,
|
||||||
return createdAt, startedAt, finishedAt, nil
|
return createdAt, startedAt, finishedAt, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContainerStatus returns the container status.
|
// ContainerStatus inspects the docker container and returns the status.
|
||||||
func (ds *dockerService) ContainerStatus(containerID string) (*runtimeApi.ContainerStatus, error) {
|
func (ds *dockerService) ContainerStatus(containerID string) (*runtimeApi.ContainerStatus, error) {
|
||||||
r, err := ds.client.InspectContainer(containerID)
|
r, err := ds.client.InspectContainer(containerID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -292,7 +293,7 @@ func (ds *dockerService) ContainerStatus(containerID string) (*runtimeApi.Contai
|
||||||
return nil, fmt.Errorf("failed to parse timestamp for container %q: %v", containerID, err)
|
return nil, fmt.Errorf("failed to parse timestamp for container %q: %v", containerID, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert the image id to pullable id.
|
// Convert the image id to a pullable id.
|
||||||
ir, err := ds.client.InspectImageByID(r.Image)
|
ir, err := ds.client.InspectImageByID(r.Image)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("unable to inspect docker image %q while inspecting docker container %q: %v", r.Image, containerID, err)
|
return nil, fmt.Errorf("unable to inspect docker image %q while inspecting docker container %q: %v", r.Image, containerID, err)
|
||||||
|
|
|
@ -368,7 +368,7 @@ func sharesHostNetwork(container *dockertypes.ContainerJSON) bool {
|
||||||
|
|
||||||
func setSandboxResources(hc *dockercontainer.HostConfig) {
|
func setSandboxResources(hc *dockercontainer.HostConfig) {
|
||||||
hc.Resources = dockercontainer.Resources{
|
hc.Resources = dockercontainer.Resources{
|
||||||
MemorySwap: -1, // Always disable memory swap.
|
MemorySwap: -1,
|
||||||
CPUShares: defaultSandboxCPUshares,
|
CPUShares: defaultSandboxCPUshares,
|
||||||
// Use docker's default cpu quota/period.
|
// Use docker's default cpu quota/period.
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue