Exemplo n.º 1
0
func (db *ETCDDB) GatherAndPruneLRPs(logger lager.Logger, cellSet models.CellSet) (*models.ConvergenceInput, error) {
	guids := map[string]struct{}{}
	// always fetch actualLRPs before desiredLRPs to ensure correctness
	logger.Debug("gathering-and-pruning-actual-lrps")
	lrpMetricCounter := &LRPMetricCounter{}

	actuals, err := db.gatherAndPruneActualLRPs(logger, guids, lrpMetricCounter) // modifies guids
	if err != nil {
		logger.Error("failed-gathering-and-pruning-actual-lrps", err)

		lrpMetricCounter.unclaimedLRPs = -1
		lrpMetricCounter.claimedLRPs = -1
		lrpMetricCounter.runningLRPs = -1
		lrpMetricCounter.crashedActualLRPs = -1
		lrpMetricCounter.crashingDesiredLRPs = -1
		lrpMetricCounter.desiredLRPs = -1

		lrpMetricCounter.Send(logger)

		return &models.ConvergenceInput{}, err
	}
	logger.Debug("succeeded-gathering-and-pruning-actual-lrps")

	// always fetch desiredLRPs after actualLRPs to ensure correctness
	logger.Debug("gathering-and-pruning-desired-lrps")
	desireds, err := db.GatherAndPruneDesiredLRPs(logger, guids, lrpMetricCounter) // modifies guids
	if err != nil {
		logger.Error("failed-gathering-and-pruning-desired-lrps", err)

		lrpMetricCounter.desiredLRPs = -1
		lrpMetricCounter.Send(logger)

		return &models.ConvergenceInput{}, err
	}
	logger.Debug("succeeded-gathering-and-pruning-desired-lrps")

	lrpMetricCounter.Send(logger)

	logger.Debug("listing-domains")
	domains, err := db.Domains(logger)
	if err != nil {
		return &models.ConvergenceInput{}, err
	}
	logger.Debug("succeeded-listing-domains")
	for _, domain := range domains {
		metric.Metric(domainMetricPrefix + domain).Send(1)
	}

	return &models.ConvergenceInput{
		AllProcessGuids: guids,
		DesiredLRPs:     desireds,
		ActualLRPs:      actuals,
		Domains:         models.NewDomainSet(domains),
		Cells:           cellSet,
	}, nil
}
Exemplo n.º 2
0
	"encoding/json"
	"errors"
	"net"
	"strconv"
	"sync"
	"unicode/utf8"

	"github.com/cloudfoundry-incubator/diego-ssh/helpers"
	"github.com/cloudfoundry-incubator/runtime-schema/metric"
	"github.com/cloudfoundry/dropsonde/logs"
	"github.com/pivotal-golang/lager"
	"golang.org/x/crypto/ssh"
)

const (
	sshConnections = metric.Metric("ssh-connections")
)

type Waiter interface {
	Wait() error
}

type TargetConfig struct {
	Address         string `json:"address"`
	HostFingerprint string `json:"host_fingerprint"`
	User            string `json:"user,omitempty"`
	Password        string `json:"password,omitempty"`
	PrivateKey      string `json:"private_key,omitempty"`
}

type LogMessage struct {
Exemplo n.º 3
0
	"github.com/cloudfoundry-incubator/auctioneer"
	"github.com/cloudfoundry-incubator/bbs/models"
	"github.com/cloudfoundry-incubator/runtime-schema/metric"
	"github.com/cloudfoundry/gunk/workpool"
	"github.com/pivotal-golang/lager"
)

const (
	convergeTaskRunsCounter = metric.Counter("ConvergenceTaskRuns")
	convergeTaskDuration    = metric.Duration("ConvergenceTaskDuration")

	tasksKickedCounter = metric.Counter("ConvergenceTasksKicked")
	tasksPrunedCounter = metric.Counter("ConvergenceTasksPruned")

	pendingTasks   = metric.Metric("TasksPending")
	runningTasks   = metric.Metric("TasksRunning")
	completedTasks = metric.Metric("TasksCompleted")
	resolvingTasks = metric.Metric("TasksResolving")
)

type compareAndSwappableTask struct {
	OldIndex uint64
	NewTask  *models.Task
}

func (db *ETCDDB) ConvergeTasks(
	logger lager.Logger,
	kickTaskDuration, expirePendingTaskDuration, expireCompletedTaskDuration time.Duration,
) {
	logger = logger.Session("converge-tasks")
Exemplo n.º 4
0
	"github.com/pivotal-golang/clock"
	"github.com/pivotal-golang/lager"
)

const (
	convergeLRPRunsCounter = metric.Counter("ConvergenceLRPRuns")
	convergeLRPDuration    = metric.Duration("ConvergenceLRPDuration")

	malformedSchedulingInfosMetric = metric.Counter("ConvergenceLRPPreProcessingMalformedSchedulingInfos")
	malformedRunInfosMetric        = metric.Counter("ConvergenceLRPPreProcessingMalformedRunInfos")
	actualLRPsDeleted              = metric.Counter("ConvergenceLRPPreProcessingActualLRPsDeleted")
	orphanedRunInfosMetric         = metric.Counter("ConvergenceLRPPreProcessingOrphanedRunInfos")

	domainMetricPrefix = "Domain."

	desiredLRPs   = metric.Metric("LRPsDesired")
	claimedLRPs   = metric.Metric("LRPsClaimed")
	unclaimedLRPs = metric.Metric("LRPsUnclaimed")
	runningLRPs   = metric.Metric("LRPsRunning")

	missingLRPs = metric.Metric("LRPsMissing")
	extraLRPs   = metric.Metric("LRPsExtra")

	crashedActualLRPs   = metric.Metric("CrashedActualLRPs")
	crashingDesiredLRPs = metric.Metric("CrashingDesiredLRPs")
)

func (db *ETCDDB) ConvergeLRPs(logger lager.Logger, cellSet models.CellSet) ([]*auctioneer.LRPStartRequest, []*models.ActualLRPKeyWithSchedulingInfo, []*models.ActualLRPKey) {
	convergeStart := db.clock.Now()
	convergeLRPRunsCounter.Increment()
	logger = logger.Session("etcd")
Exemplo n.º 5
0
package metrics

import (
	"os"
	"time"

	"github.com/cloudfoundry-incubator/executor"
	"github.com/cloudfoundry-incubator/runtime-schema/metric"
	"github.com/pivotal-golang/lager"
)

const (
	totalMemory     = metric.Mebibytes("CapacityTotalMemory")
	totalDisk       = metric.Mebibytes("CapacityTotalDisk")
	totalContainers = metric.Metric("CapacityTotalContainers")

	remainingMemory     = metric.Mebibytes("CapacityRemainingMemory")
	remainingDisk       = metric.Mebibytes("CapacityRemainingDisk")
	remainingContainers = metric.Metric("CapacityRemainingContainers")

	containerCount = metric.Metric("ContainerCount")
)

type ExecutorSource interface {
	RemainingResources() (executor.ExecutorResources, error)
	TotalResources() (executor.ExecutorResources, error)
	ListContainers(executor.Tags) ([]executor.Container, error)
}

type Reporter struct {
	Interval       time.Duration
Exemplo n.º 6
0
	"github.com/cloudfoundry-incubator/bbs"
	"github.com/cloudfoundry-incubator/bbs/models"
	"github.com/cloudfoundry-incubator/cf_http"
	"github.com/cloudfoundry-incubator/nsync/helpers"
	"github.com/cloudfoundry-incubator/nsync/recipebuilder"
	"github.com/cloudfoundry-incubator/routing-info/cfroutes"
	"github.com/cloudfoundry-incubator/runtime-schema/cc_messages"
	"github.com/cloudfoundry-incubator/runtime-schema/metric"
	"github.com/cloudfoundry/gunk/workpool"
	"github.com/pivotal-golang/clock"
	"github.com/pivotal-golang/lager"
)

const (
	syncDesiredLRPsDuration = metric.Duration("DesiredLRPSyncDuration")
	invalidLRPsFound        = metric.Metric("NsyncInvalidDesiredLRPsFound")
)

type Processor struct {
	bbsClient             bbs.Client
	pollingInterval       time.Duration
	domainTTL             time.Duration
	bulkBatchSize         uint
	updateLRPWorkPoolSize int
	skipCertVerify        bool
	logger                lager.Logger
	fetcher               Fetcher
	builders              map[string]recipebuilder.RecipeBuilder
	clock                 clock.Clock
}
Exemplo n.º 7
0
	"crypto/tls"
	"encoding/json"
	"errors"
	"net/http"
	"strconv"

	"github.com/cloudfoundry-incubator/cf_http"
	"github.com/cloudfoundry-incubator/runtime-schema/metric"
	"github.com/cloudfoundry/gunk/urljoiner"
	"github.com/pivotal-golang/lager"
)

var errRedirected = errors.New("redirected to leader")

const (
	etcdLeader                = metric.Metric("ETCDLeader")
	etcdReceivedBandwidthRate = metric.BytesPerSecond("ETCDReceivedBandwidthRate")
	etcdSentBandwidthRate     = metric.BytesPerSecond("ETCDSentBandwidthRate")
	etcdReceivedRequestRate   = metric.RequestsPerSecond("ETCDReceivedRequestRate")
	etcdSentRequestRate       = metric.RequestsPerSecond("ETCDSentRequestRate")
	etcdRaftTerm              = metric.Metric("ETCDRaftTerm")
	etcdWatchers              = metric.Metric("ETCDWatchers")
)

type ETCDMetrics struct {
	logger lager.Logger

	etcdCluster []string

	client *http.Client
}
Exemplo n.º 8
0
	"time"

	"github.com/cloudfoundry-incubator/bbs"
	"github.com/cloudfoundry-incubator/bbs/events"
	"github.com/cloudfoundry-incubator/bbs/models"
	"github.com/cloudfoundry-incubator/route-emitter/nats_emitter"
	"github.com/cloudfoundry-incubator/route-emitter/routing_table"
	"github.com/cloudfoundry-incubator/route-emitter/syncer"
	"github.com/cloudfoundry-incubator/routing-info/cfroutes"
	"github.com/cloudfoundry-incubator/runtime-schema/metric"
	"github.com/pivotal-golang/clock"
	"github.com/pivotal-golang/lager"
)

var (
	routesTotal  = metric.Metric("RoutesTotal")
	routesSynced = metric.Counter("RoutesSynced")

	routeSyncDuration = metric.Duration("RouteEmitterSyncDuration")

	routesRegistered   = metric.Counter("RoutesRegistered")
	routesUnregistered = metric.Counter("RoutesUnregistered")
)

type Watcher struct {
	bbsClient  bbs.Client
	clock      clock.Clock
	table      routing_table.RoutingTable
	emitter    nats_emitter.NATSEmitter
	syncEvents syncer.Events
	logger     lager.Logger