Exemplo n.º 1
0
// Package mockengine implements a MockEngine that doesn't really do anything,
// but allows us to test plugins without having to run a real engine.
package mockengine

import "github.com/taskcluster/taskcluster-worker/runtime/util"

var debug = util.Debug("mockengine")
Exemplo n.º 2
0
// Package network contains scripts and abstractions for setting up TAP-device
// based networks for a set of QEMU virtual machines.
//
// Each virtual machine will get a TAP device, represented as a network, the
// TAP device will automatically get an IP address and DNS server using DHCP.
// The DNS server will resolve the "taskcluster" domains to the meta-data IP
// address. Request to the meta-data IP will be forwarded to the handler
// registered for the network instance.
//
// This package uses iptables to lock down network and ensure that the virtual
// machine attached to a TAP device can't contact the meta-data handler of
// another virtual machine.
package network

import "github.com/taskcluster/taskcluster-worker/runtime/util"

var debug = util.Debug("network")
Exemplo n.º 3
0
	"encoding/json"
	"fmt"
	"io"
	"io/ioutil"
	"os"
	rt "runtime"
	"strings"
	"sync"

	"github.com/taskcluster/taskcluster-worker/engines"
	"github.com/taskcluster/taskcluster-worker/runtime"
	"github.com/taskcluster/taskcluster-worker/runtime/gc"
	"github.com/taskcluster/taskcluster-worker/runtime/util"
)

var debug = util.Debug("enginetest")

func fmtPanic(a ...interface{}) {
	panic(fmt.Sprintln(a...))
}

func nilOrPanic(err error, a ...interface{}) {
	if err != nil {
		fmtPanic(append(a, err)...)
	}
}

func evalNilOrPanic(f func() error, a ...interface{}) {
	nilOrPanic(f(), a...)
}
Exemplo n.º 4
0
	graceful "gopkg.in/tylerb/graceful.v1"

	"github.com/cespare/cp"
	"github.com/taskcluster/slugid-go/slugid"
	"github.com/taskcluster/taskcluster-worker/engines/qemu/image"
	"github.com/taskcluster/taskcluster-worker/engines/qemu/metaservice"
	"github.com/taskcluster/taskcluster-worker/engines/qemu/network"
	"github.com/taskcluster/taskcluster-worker/engines/qemu/vm"
	"github.com/taskcluster/taskcluster-worker/plugins/interactive"
	"github.com/taskcluster/taskcluster-worker/runtime"
	"github.com/taskcluster/taskcluster-worker/runtime/gc"
	"github.com/taskcluster/taskcluster-worker/runtime/util"
)

var debug = util.Debug("qemurun")

type cmd struct{}

func (cmd) Summary() string {
	return "Run a QEMU image for debugging"
}

func (cmd) Usage() string {
	return `
taskcluster-worker qemu-run will run a given command inside an image to test it,
and give you an VNC viewer to get you into the virtual machine.

usage: taskcluster-worker qemu-run [options] <image> -- <command>...

options:
Exemplo n.º 5
0
// Package image exposes methods and abstractions for extracting and managing
// virtual machine images. Amongst other things this involves securing that
// the images don't reference external files as backing store.
package image

import "github.com/taskcluster/taskcluster-worker/runtime/util"

var debug = util.Debug("image")
Exemplo n.º 6
0
// 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 169.254.169.254:80.
// 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 metaservice

import "github.com/taskcluster/taskcluster-worker/runtime/util"

var debug = util.Debug("metaservice")
Exemplo n.º 7
0
// Package system implements cross-platform abstractions for user-management
// access-control and sub-process execution geared at executing sub-process with
// best-effort sandboxing.
//
// The system package provides the following platform specific types and
// methods.
//      system.User
//      system.User.Remove()
//      system.Group
//      system.Process
//      system.Process.Wait() bool
//      system.Process.Kill()
//      system.SetSize(columns, rows uint16) error
//     	system.CreateUser(homeFolder string, groups []*Group) (*User, error)
//      system.FindGroup(name string) (*Group, error)
//     	system.StartProcess(options ProcessOptions) (*Process, error)
//     	system.KillByOwner(user *User) error
package system

import "github.com/taskcluster/taskcluster-worker/runtime/util"

// TODO: Implement the following methods to support cache folder.
//      system.Group.Remove()
//      system.CreateGroup() (*Group, error)
//      system.Link(target, source string) error
//      system.Unlink(target string) error
//      system.SetRecursiveReadWriteRecursive(folder string, group *Group) error
//      system.SetRecursiveReadOnlyAccess(folder string, group *Group) error

var debug = util.Debug("system")
Exemplo n.º 8
0
// Package shellclient provides a wrapper for demuxing a shell websocket and
// exposing the stdout/stderr streams as well as offering a way to provide the
// stdin stream.
package shellclient

import "github.com/taskcluster/taskcluster-worker/runtime/util"

var debug = util.Debug("shellclient")
Exemplo n.º 9
0
// The guest tools is pretty much the only way taskcluster-worker can talk to
// the guest virtual machine. As you can't execute processes inside a virtual
// machine without SSH'ing into it or something. That something is these
// guest tools.
package qemuguesttools

import (
	"io"
	"os"

	"github.com/taskcluster/taskcluster-worker/commands"
	"github.com/taskcluster/taskcluster-worker/runtime"
	"github.com/taskcluster/taskcluster-worker/runtime/util"
)

var debug = util.Debug("guesttools")

func init() {
	commands.Register("qemu-guest-tools", cmd{})
}

type cmd struct{}

func (cmd) Summary() string {
	return "Run guest-tools, for use in VMs for the QEMU engine"
}

func (cmd) Usage() string {
	return `taskcluster-worker qemu-guest-tools start the guest tools that should
run inside the virtual machines used with QEMU engine.
Exemplo n.º 10
0
// Package vm provides virtual machine abstractions for QEMU.
package vm

import "github.com/taskcluster/taskcluster-worker/runtime/util"

var debug = util.Debug("vm")
Exemplo n.º 11
0
// Package displayclient provides a golang implementation of websockify,
// transforming a websocket connection to an ioext.ReadWriteCloser object.
//
// The goal of this is to make it easy to interact with a VNC connection from
// a go application. Both for writing tests and command line utilities.
package displayclient

import "github.com/taskcluster/taskcluster-worker/runtime/util"

var debug = util.Debug("displayclient")
Exemplo n.º 12
0
// Package interactive implements the plugin that serves the interactive
// display and shell sessions over websockets.
//
// The package can also be used as library that provides functionality to host
// display and shell sessions over websockets. This is useful for reusing the
// code in small utilities.
package interactive

import (
	"github.com/taskcluster/taskcluster-worker/plugins"
	"github.com/taskcluster/taskcluster-worker/runtime/util"
)

var debug = util.Debug("interactive")

func init() {
	plugins.Register("interactive", provider{})
}
Exemplo n.º 13
0
// Package shell provides a CommandProvider that implements a CLI tool for
// opening to a interactive shell to an interactive taskcluster-worker task
// in your terminal.
package shell

import "github.com/taskcluster/taskcluster-worker/runtime/util"

var debug = util.Debug("shell")
Exemplo n.º 14
0
// Package mocknet implements a net.Listener interface that can reached with
// mocknet.Dial() and establishes connections using net.Pipe()
//
// This is useful for testing things that needs net.Listener and net.Conn
// instances without creating a TCP listener on localhost.
package mocknet

import (
	"sync"

	"github.com/taskcluster/taskcluster-worker/runtime/util"
)

var debug = util.Debug("mocknet")

// mNetworks guards access to networks, which is global list of mock networks.
var (
	mNetworks = sync.Mutex{}
	networks  = make(map[string]*MockListener)
)
Exemplo n.º 15
0
// Package scriptengine provides an engine that can be configured with a script
// and a JSON schema, such that the worker executes declarative tasks.
package scriptengine

import "github.com/taskcluster/taskcluster-worker/runtime/util"

var debug = util.Debug("scriptengine")
Exemplo n.º 16
0
// Package nativeengine provides an engine with minimal sandboxing relying on
// per-task user accounts, temporary folders and process isolation.
//
// Platform specific methods such as run sub-process under a difference user,
// add/remove users and management of user permissions are all implemented in
// the system/ sub-package.
package nativeengine

import "github.com/taskcluster/taskcluster-worker/runtime/util"

var debug = util.Debug("native")