Beispiel #1
0
		gardenClient    *gardenFakes.FakeClient
		healthcheckSpec garden.ProcessSpec
		logger          *lagertest.TestLogger
	)

	BeforeEach(func() {
		healthcheckSpec = garden.ProcessSpec{
			Path: "/bin/sh",
			Args: []string{"-c", "echo", "hello"},
			User: "******",
		}
		logger = lagertest.NewTestLogger("test")
		gardenClient = &gardenFakes.FakeClient{}
		guidGenerator := &fakeguidgen.FakeGenerator{}
		guidGenerator.GuidReturns("abc-123")
		gardenChecker = gardenhealth.NewChecker(rootfsPath, containerOwnerName, 0, healthcheckSpec, gardenClient, guidGenerator)
	})

	Describe("Healthcheck", func() {
		var fakeContainer *gardenFakes.FakeContainer
		var oldContainer *gardenFakes.FakeContainer
		var fakeProcess *gardenFakes.FakeProcess

		BeforeEach(func() {
			fakeContainer = &gardenFakes.FakeContainer{}
			oldContainer = &gardenFakes.FakeContainer{}
			oldContainer.HandleReturns("old-guid")
			fakeProcess = &gardenFakes.FakeProcess{}
		})

		Context("When garden is healthy", func() {
Beispiel #2
0
func Initialize(logger lager.Logger, config Configuration, clock clock.Clock) (executor.Client, grouper.Members, error) {
	gardenClient := GardenClient.New(GardenConnection.New(config.GardenNetwork, config.GardenAddr))
	err := waitForGarden(logger, gardenClient, clock)
	if err != nil {
		return nil, nil, err
	}

	containersFetcher := &executorContainers{
		gardenClient: gardenClient,
		owner:        config.ContainerOwnerName,
	}

	destroyContainers(gardenClient, containersFetcher, logger)

	workDir := setupWorkDir(logger, config.TempDir)

	transformer := initializeTransformer(
		logger,
		config.CachePath,
		workDir,
		config.MaxCacheSizeInBytes,
		uint(config.MaxConcurrentDownloads),
		maxConcurrentUploads,
		config.SkipCertVerify,
		config.ExportNetworkEnvVars,
		clock,
	)

	hub := event.NewHub()

	gardenStore, err := gardenstore.NewGardenStore(
		gardenClient,
		config.ContainerOwnerName,
		config.ContainerMaxCpuShares,
		config.ContainerInodeLimit,
		config.HealthyMonitoringInterval,
		config.UnhealthyMonitoringInterval,
		transformer,
		clock,
		hub,
		config.HealthCheckWorkPoolSize,
	)
	if err != nil {
		return nil, grouper.Members{}, err
	}

	allocationStore := allocationstore.NewAllocationStore(clock, hub)

	workPoolSettings := executor.WorkPoolSettings{
		CreateWorkPoolSize:  config.CreateWorkPoolSize,
		DeleteWorkPoolSize:  config.DeleteWorkPoolSize,
		ReadWorkPoolSize:    config.ReadWorkPoolSize,
		MetricsWorkPoolSize: config.MetricsWorkPoolSize,
	}

	depotClientProvider, err := depot.NewClientProvider(
		fetchCapacity(logger, gardenClient, config),
		allocationStore,
		gardenStore,
		hub,
		keyed_lock.NewLockManager(),
		workPoolSettings,
	)
	if err != nil {
		return nil, grouper.Members{}, err
	}

	healthcheckSpec := garden.ProcessSpec{
		Path: config.GardenHealthcheckProcessPath,
		Args: config.GardenHealthcheckProcessArgs,
		User: config.GardenHealthcheckProcessUser,
		Env:  config.GardenHealthcheckProcessEnv,
		Dir:  config.GardenHealthcheckProcessDir,
	}

	gardenHealthcheck := gardenhealth.NewChecker(
		config.GardenHealthcheckRootFS,
		config.ContainerOwnerName,
		config.GardenHealthcheckCommandRetryPause,
		healthcheckSpec,
		gardenClient,
		guidgen.DefaultGenerator,
	)

	metricsLogger := logger.Session("metrics-reporter")
	containerMetricsLogger := logger.Session("container-metrics-reporter")

	return depotClientProvider.WithLogger(logger),
		grouper.Members{
			{"metrics-reporter", &metrics.Reporter{
				ExecutorSource: depotClientProvider.WithLogger(metricsLogger),
				Interval:       metricsReportInterval,
				Logger:         metricsLogger,
			}},
			{"hub-closer", closeHub(hub)},
			{"registry-pruner", allocationStore.RegistryPruner(logger, config.RegistryPruningInterval)},
			{"container-metrics-reporter", containermetrics.NewStatsReporter(
				containerMetricsLogger,
				containerMetricsReportInterval,
				clock,
				depotClientProvider.WithLogger(containerMetricsLogger),
			)},
			{"garden_health_checker", gardenhealth.NewRunner(
				config.GardenHealthcheckInterval,
				config.GardenHealthcheckTimeout,
				logger,
				gardenHealthcheck,
				depotClientProvider.WithLogger(logger),
				clock,
			)},
		},
		nil
}