@@ -79,7 +79,8 @@ func (ds *dockerService) ListContainers(filter *runtimeApi.ContainerFilter) ([]*
79
79
}
80
80
81
81
// CreateContainer creates a new container in the given PodSandbox
82
- // Note: docker doesn't use LogPath yet.
82
+ // Docker cannot store the log to an arbitrary location (yet), so we create an
83
+ // symlink at LogPath, linking to the actual path of the log.
83
84
// TODO: check if the default values returned by the runtime API are ok.
84
85
func (ds * dockerService ) CreateContainer (podSandboxID string , config * runtimeApi.ContainerConfig , sandboxConfig * runtimeApi.PodSandboxConfig ) (string , error ) {
85
86
if config == nil {
@@ -140,7 +141,7 @@ func (ds *dockerService) CreateContainer(podSandboxID string, config *runtimeApi
140
141
if rOpts != nil {
141
142
hc .Resources = dockercontainer.Resources {
142
143
Memory : rOpts .GetMemoryLimitInBytes (),
143
- MemorySwap : - 1 , // Always disable memory swap.
144
+ MemorySwap : - 1 ,
144
145
CPUShares : rOpts .GetCpuShares (),
145
146
CPUQuota : rOpts .GetCpuQuota (),
146
147
CPUPeriod : rOpts .GetCpuPeriod (),
@@ -229,10 +230,10 @@ func (ds *dockerService) StartContainer(containerID string) error {
229
230
}
230
231
// Create container log symlink.
231
232
if err := ds .createContainerLogSymlink (containerID ); err != nil {
232
- // Do not stop the container if fail to create symlink, because:
233
- // 1. This is not a critical failure.
234
- // 2. We don't have enough information to properly stop container here.
235
- // Kubelet will surface this error to user with event.
233
+ // Do not stop the container if we failed to create symlink because:
234
+ // 1. This is not a critical failure.
235
+ // 2. We don't have enough information to properly stop container here.
236
+ // Kubelet will surface this error to user via an event.
236
237
return err
237
238
}
238
239
return nil
@@ -248,7 +249,7 @@ func (ds *dockerService) StopContainer(containerID string, timeout int64) error
248
249
func (ds * dockerService ) RemoveContainer (containerID string ) error {
249
250
// Ideally, log lifecycle should be independent of container lifecycle.
250
251
// However, docker will remove container log after container is removed,
251
- // we can't prevent that now, so we also cleanup the symlink here.
252
+ // we can't prevent that now, so we also clean up the symlink here.
252
253
err := ds .removeContainerLogSymlink (containerID )
253
254
if err != nil {
254
255
return err
@@ -279,7 +280,7 @@ func getContainerTimestamps(r *dockertypes.ContainerJSON) (time.Time, time.Time,
279
280
return createdAt , startedAt , finishedAt , nil
280
281
}
281
282
282
- // ContainerStatus returns the container status.
283
+ // ContainerStatus inspects the docker container and returns the status.
283
284
func (ds * dockerService ) ContainerStatus (containerID string ) (* runtimeApi.ContainerStatus , error ) {
284
285
r , err := ds .client .InspectContainer (containerID )
285
286
if err != nil {
@@ -292,7 +293,7 @@ func (ds *dockerService) ContainerStatus(containerID string) (*runtimeApi.Contai
292
293
return nil , fmt .Errorf ("failed to parse timestamp for container %q: %v" , containerID , err )
293
294
}
294
295
295
- // Convert the image id to pullable id.
296
+ // Convert the image id to a pullable id.
296
297
ir , err := ds .client .InspectImageByID (r .Image )
297
298
if err != nil {
298
299
return nil , fmt .Errorf ("unable to inspect docker image %q while inspecting docker container %q: %v" , r .Image , containerID , err )
0 commit comments