Exemplo n.º 1
0
	DeployGroup           = "HAPROXY_DEPLOYMENT_GROUP"
	DeployGroupAltPort    = "HAPROXY_DEPLOYMENT_ALT_PORT"
	DeployGroupColour     = "HAPROXY_DEPLOYMENT_COLOUR"
	DeployProxyPort       = "HAPROXY_0_PORT"
	DeployTargetInstances = "HAPROXY_DEPLOYMENT_TARGET_INSTANCES"
	DeployStartedAt       = "HAPROXY_DEPLOYMENT_STARTED_AT"
	ProxyAppId            = "HAPROXY_APP_ID"
	ColourBlue            = "blue"
	ColourGreen           = "green"
)

var (
	ErrorNoLabels         = errors.New("No labels found. Please define the HAPROXY_DEPLOYMENT_GROUP and HAPROXY_DEPLOYMENT_ALT_PORT label")
	ErrorNoServicePortSet = errors.New("No service port set")
	LabelFormatErr        = "Please define the %s label"
	log                   = logger.GetLogger("depcon.marathon.bg")
)

func (c *BGClient) DeployBlueGreenFromFile(filename string) (*marathon.Application, error) {

	log.Debug("Enter DeployBlueGreenFromFile")

	parseOpts := &marathon.CreateOptions{
		ErrorOnMissingParams: c.opts.ErrorOnMissingParams,
		EnvParams:            c.opts.EnvParams,
	}
	app, err := c.marathon.ParseApplicationFromFile(filename, parseOpts)
	if err != nil {
		return nil, err
	}
	return c.DeployBlueGreen(app)
Exemplo n.º 2
0
import (
	"fmt"
	"github.com/ContainX/depcon/pkg/cli"
	"github.com/ContainX/depcon/pkg/encoding"
	"github.com/ContainX/depcon/pkg/logger"
	"os"
)

const (
	FLAG_FORMAT string = "output"
	TypeJSON    string = "json"
	TypeYAML    string = "yaml"
	TypeColumn  string = "column"
)

var log = logger.GetLogger("depcon")

func init() {
	cli.Register(&cli.CLIWriter{FormatWriter: PrintFormat, ErrorWriter: PrintError})
	rootCmd.PersistentFlags().StringP(FLAG_FORMAT, "o", "column", "Specifies the output format [column | json | yaml]")
}

func getFormatType() string {
	if rootCmd.PersistentFlags().Changed(FLAG_FORMAT) {
		format, err := rootCmd.PersistentFlags().GetString(FLAG_FORMAT)
		if err == nil {
			return format
		}
	}
	if configFile != nil && configFile.Format != "" {
		return configFile.Format
Exemplo n.º 3
0
package marathon

import (
	"github.com/ContainX/depcon/pkg/logger"
	"github.com/ContainX/depcon/utils"
	"time"
)

var logWait = logger.GetLogger("depcon.deploy.wait")

func (c *MarathonClient) WaitForApplication(id string, timeout time.Duration) error {
	t_now := time.Now()
	t_stop := t_now.Add(timeout)

	logWaitApplication(id)
	for {
		if time.Now().After(t_stop) {
			return ErrorTimeout
		}

		app, err := c.GetApplication(id)
		if err == nil {
			if app.DeploymentID == nil || len(app.DeploymentID) <= 0 {
				logWait.Info("Application deployment has completed for %s, elapsed time %s", id, utils.ElapsedStr(time.Since(t_now)))
				if app.HealthChecks != nil && len(app.HealthChecks) > 0 {
					err := c.WaitForApplicationHealthy(id, timeout)
					if err != nil {
						logWait.Error("Error waiting for application '%s' to become healthy: %s", id, err.Error())
					}
				} else {
					logWait.Warning("No health checks defined for '%s', skipping waiting for healthy state", id)
Exemplo n.º 4
0
package httpclient

import (
	"crypto/tls"
	"errors"
	"github.com/ContainX/depcon/pkg/encoding"
	"github.com/ContainX/depcon/pkg/logger"
	"io"
	"io/ioutil"
	"net/http"
	"strings"
	"sync"
	"time"
)

var log = logger.GetLogger("client")

type Response struct {
	Status  int
	Content string
	Elapsed time.Duration
	Error   error
}

type Request struct {
	// Http Method type
	method Method
	// Complete URL including params
	url string
	// Post data
	data string
Exemplo n.º 5
0
	API_APPS         = API_VERSION + "/apps"
	API_TASKS        = API_VERSION + "/tasks"
	API_TASKS_DELETE = API_VERSION + "/tasks/delete"
	API_DEPLOYMENTS  = API_VERSION + "/deployments"
	API_GROUPS       = API_VERSION + "/groups"
	API_QUEUE        = API_VERSION + "/queue"
	API_INFO         = API_VERSION + "/info"
	API_LEADER       = API_VERSION + "/leader"
	API_EVENTS       = API_VERSION + "/events"
	API_PING         = "ping"

	DefaultTimeout = time.Duration(90) * time.Second
)

// Common package logger
var log = logger.GetLogger("depcon.marathon")

type CreateOptions struct {
	// if true will attempt to wait until the new application or group is running
	Wait bool
	// if true and an application/group already exists an update will be performed.
	// if false and an application/group exists an error will be returned
	Force bool
	// If true an error will be returned on params defined in the configuration file that
	// could not resolve to user input and environment variables
	ErrorOnMissingParams bool
	// Additional environment params - looks at this map for token substitution which takes
	// priority over matching environment variables
	EnvParams map[string]string

	// If an existing deployment for this group/app is in progress then remove it and let this revision
Exemplo n.º 6
0
package compose

import (
	depconLog "github.com/ContainX/depcon/pkg/logger"
	"github.com/docker/libcompose/logger"
	"io"
	"os"
)

var log = depconLog.GetLogger("depcon.compose")

type ComposeLogger struct {
}

func (n *ComposeLogger) Out(b []byte) {
	log.Info("%v", b)
}

func (n *ComposeLogger) Err(b []byte) {
	log.Error("%v", b)
}

func (n *ComposeLogger) ErrWriter() io.Writer {
	return os.Stderr
}

func (n *ComposeLogger) OutWriter() io.Writer {
	return os.Stdout
}

func (n *ComposeLogger) Create(name string) logger.Logger {