taskcluster-worker: github.com/taskcluster/taskcluster-worker/engines/qemu/metaservice Index | Files

package metaservice

import "github.com/taskcluster/taskcluster-worker/engines/qemu/metaservice"

Package metaservice implements the meta-data service that the guests use to talk to the host.

The meta-data service is exposed to the guest on This is how the command and environment variables enter the virtual machine. It is also the services that the guest uses to report logs and final result.


Package Files

doc.go metaservice.go payload.go


const (
    ErrorCodeMethodNotAllowed = "MethodNotAllowed"
    ErrorCodeNoSuchEndPoint   = "NoSuchEndPoint"
    ErrorCodeInternalError    = "InternalError"
    ErrorCodeResourceConflict = "ResourceConflict"
    ErrorCodeUnknownActionID  = "UnknownActionId"
    ErrorCodeInvalidPayload   = "InvalidPayload"

List of API error codes for using the Error struct.

const PollTimeout = 30 * time.Second

PollTimeout is the maximum amount of time a poll request will be left hanging before getting a response (even if the response is none).

type Action Uses

type Action struct {
    ID      string   `json:"id"`      // id, to be used when replying
    Type    string   `json:"type"`    // none, get-artifact, list-folder, exec-shell, kill-process
    Path    string   `json:"path"`    // file path, if get-artifact/list-folder
    Command []string `json:"command"` // Command for exec-shell
    TTY     bool     `json:"tty"`     // TTY or not for exec-shell

Action is the response payload for the /engine/v1/poll end-point.

type Error Uses

type Error struct {
    Code    string `json:"code"`
    Message string `json:"message"`

Error is the response payload for any error senario.

type Execute Uses

type Execute struct {
    Env     map[string]string `json:"env"`
    Command []string          `json:"command"`

Execute is the response payload for the /engine/v1/execute end-point.

type Files Uses

type Files struct {
    Files    []string `json:"files"`    // List of absolute file paths
    NotFound bool     `json:"notFound"` // true, if path doesn't exist

Files is the request payload for the /engine/v1/list-folder end-point.

type MetaService Uses

type MetaService struct {
    // contains filtered or unexported fields

MetaService implements the meta-data service that communicates worker process running inside the virtual machine. This is how the command to run gets into the virtual machine, and how logs and artifacts are copied out.

func New Uses

func New(
    command []string, env map[string]string, logDrain io.Writer,
    resultCallback func(bool), environment *runtime.Environment,
) *MetaService

New returns a new MetaService that will tell the virtual machine to run command, with environment variables env. It will write the logs to logDrain.

The callback resultCallback will be called when the guest reports that the command is done.

func (*MetaService) ExecShell Uses

func (s *MetaService) ExecShell(command []string, tty bool) (engines.Shell, error)

ExecShell will send an action to guest-tools to execute a shell, then wait for guest-tools to callback establish a websocket and connect to an implementation of engines.Shell

func (*MetaService) GetArtifact Uses

func (s *MetaService) GetArtifact(path string) (ioext.ReadSeekCloser, error)

GetArtifact will tell polling guest-tools to send a given artifact.

func (*MetaService) KillProcess Uses

func (s *MetaService) KillProcess() error

KillProcess will send an action to guest-tools to kill the process executing the main command.

Note: For robustness this shouldn't be relied upon.

func (*MetaService) ListFolder Uses

func (s *MetaService) ListFolder(path string) ([]string, error)

ListFolder the contents of a folder (recursively)

func (*MetaService) ServeHTTP Uses

func (s *MetaService) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP handles request to the meta-data service.

func (*MetaService) StopPollers Uses

func (s *MetaService) StopPollers()

StopPollers will stop all polling requests. This is only used for testing, where it is important that clients stop polling or we can't Close the server.

Package metaservice imports 15 packages (graph) and is imported by 3 packages. Updated 2017-04-19. Refresh now. Tools for package owners.