Andrey Smirnov 0081ac5fac refactor: extract Talos cluster provisioner as common code
This extracts Docker Talos cluster provisioner as common code
which might be shared between `osctl cluster` and integration-test.

There should be almost no functional changes.

As proof of concept, abstract cluster readiness checks were implemented
based on provisioned cluster state. It implements same checks as
`basic-integration.sh` in pure Go via Talos/K8s clients.

`conditions` package was promoted from machined-internal to
`internal/pkg` as it is used to run the checks.

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2019-12-27 12:14:19 -08:00

55 lines
1.9 KiB
Go

// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package system
import (
"context"
"github.com/talos-systems/talos/internal/app/machined/pkg/system/health"
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner"
"github.com/talos-systems/talos/internal/pkg/conditions"
"github.com/talos-systems/talos/internal/pkg/runtime"
)
// Service is an interface describing a system service.
type Service interface {
// ID is the service id.
ID(runtime.Configurator) string
// PreFunc is invoked before a runner is created
PreFunc(context.Context, runtime.Configurator) error
// Runner creates runner for the service
Runner(runtime.Configurator) (runner.Runner, error)
// PostFunc is invoked after a runner is closed.
PostFunc(runtime.Configurator) error
// Condition describes the conditions under which a service should
// start.
Condition(runtime.Configurator) conditions.Condition
// DependsOn returns list of service IDs this service depends on.
DependsOn(runtime.Configurator) []string
}
// HealthcheckedService is a service which provides health check
type HealthcheckedService interface {
// HealtFunc provides function that checks health of the service
HealthFunc(runtime.Configurator) health.Check
// HealthSettings returns settings for the health check
HealthSettings(runtime.Configurator) *health.Settings
}
// APIStartableService is a service which allows to be started via API
type APIStartableService interface {
APIStartAllowed(runtime.Configurator) bool
}
// APIStoppableService is a service which allows to be stopped via API
type APIStoppableService interface {
APIStopAllowed(runtime.Configurator) bool
}
// APIRestartableService is a service which allows to be restarted via API
type APIRestartableService interface {
APIRestartAllowed(runtime.Configurator) bool
}