Files
virtual-kubelet/vendor/github.com/vmware/vic/doc/design/container_logging.md
Loc Nguyen 513cebe7b7 VMware vSphere Integrated Containers provider (#206)
* Add Virtual Kubelet provider for VIC

Initial virtual kubelet provider for VMware VIC.  This provider currently
handles creating and starting of a pod VM via the VIC portlayer and persona
server.  Image store handling via the VIC persona server.  This provider
currently requires the feature/wolfpack branch of VIC.

* Added pod stop and delete.  Also added node capacity.

Added the ability to stop and delete pod VMs via VIC.  Also retrieve
node capacity information from the VCH.

* Cleanup and readme file

Some file clean up and added a Readme.md markdown file for the VIC
provider.

* Cleaned up errors, added function comments, moved operation code

1. Cleaned up error handling.  Set standard for creating errors.
2. Added method prototype comments for all interface functions.
3. Moved PodCreator, PodStarter, PodStopper, and PodDeleter to a new folder.

* Add mocking code and unit tests for podcache, podcreator, and podstarter

Used the unit test framework used in VIC to handle assertions in the provider's
unit test.  Mocking code generated using OSS project mockery, which is compatible
with the testify assertion framework.

* Vendored packages for the VIC provider

Requires feature/wolfpack branch of VIC and a few specific commit sha of
projects used within VIC.

* Implementation of POD Stopper and Deleter unit tests (#4)

* Updated files for initial PR
2018-06-04 15:41:32 -07:00

2.3 KiB

Container VM output logging in VIC

When a container VM process produces output, that output is sent down through a serial connection into the vSphere backend where it is written to a logfile. When a user wants to see this output, they use the docker logs command, which reads from this logfile and displays the log entries on the command line in order from oldest to newest.

However, in order for users to be able to use the --since option with docker logs, we must also couple timestamps to these log entries so that the user can selectively filter log messages to be displayed based on when those entries occurred.

Requirements

The container VM logging mechanism must:

  1. Create a header for each log entry containing both the size of that entry, the time at which that entry occurred, and the stream from which that entry originated (stdout, stderr).
  2. Allow these entries to be read and at a later time, starting with the first entry occurring at or beyond the timestamp supplied by the user with the --since option to docker logs, or starting with the first entry in the logfile if --since was not used.

Implementation

A package for containerVM logging in VIC is added as github.com/vmware/vic/lib/iolog. In this package are two files, log_writer.go and log_reader.go. These files contain an implementation of Go's io.Writer and io.ReadCloser interfaces, respectively.

The responsibilities of the LogWriter are:

  1. To create a header for the entry, containing the timestamp at which the entry occurred, the size of the entry, and the stream that produced the entry.
  2. To write these bytes to the serial port associated with the containerVM logfile on the backend.
  3. To flush the remaining bytes in the supplied buffer upon Close()

The responsibilities of the LogReader are:

  1. To read in a header and decode it into the timestamp, size and stream of the entry.
  2. To then read the following size bytes that contain the actual message.
  3. To copy the message bytes into the underlying Read stream's []byte slice.
  4. To preserve unwritten bytes in a call to Read in memory so that they may be written during the next call, in the case where the supplied []byte slice was smaller than the log message we are trying to write.