-
Notifications
You must be signed in to change notification settings - Fork 486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: Flow services #4253
Labels
enhancement
New feature or request
flow
Related to Grafana Agent Flow
frozen-due-to-age
Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed.
proposal
Proposal or RFC
proposal-accepted
Proposal has been accepted.
Milestone
Comments
rfratto
added
enhancement
New feature or request
proposal
Proposal or RFC
flow/feature-parity
flow
Related to Grafana Agent Flow
labels
Jun 23, 2023
This was referenced Jun 23, 2023
3 tasks
rfratto
added a commit
to rfratto/agent
that referenced
this issue
Jun 30, 2023
The `service/` package is used to define Flow services, low-level constructs which run for the lifetime of the Flow controller. This commit introduces just the API for services, without using it anywhere. Related to grafana#4253.
This proposal has been reviewed by all maintainers with consensus for implementing it. Given there are no objections on the issue or on the doc, I'm marking this proposal as accepted. |
rfratto
added a commit
to rfratto/agent
that referenced
this issue
Jun 30, 2023
The `service/` package is used to define Flow services, low-level constructs which run for the lifetime of the Flow controller. This commit introduces just the API for services, without using it anywhere. Related to grafana#4253.
rfratto
added a commit
that referenced
this issue
Jul 5, 2023
* service: introduce new service package The `service/` package is used to define Flow services, low-level constructs which run for the lifetime of the Flow controller. This commit introduces just the API for services, without using it anywhere. Related to #4253. * pkg/flow: implement service.Host in Flow controller This commit updates the Flow controller to implement the new service.Host interface. Note that because it is not currently possible for a service or component to define a dependency on a service, the GetServiceConsumers method always returns nil. GetServiceConsumers will be updated in the future to return a non-nil list once it is possible for consumers of a service to exist. * service/http: port HTTP service to a service implementation This ports the HTTP service to implement the service.Service interface. The old HTTP service code has been removed in favor of the service. This required some hacks to wire everything in correctly; this will be cleaned up in the future once services are fully implemented.
This was referenced Jul 6, 2023
rfratto
added a commit
to rfratto/agent
that referenced
this issue
Jul 31, 2023
This change adds a new field to flow.Options, Services, which causes the lifecycle management of services to be handled by the Flow controller. Services are added to the DAG as nodes, and are run with the Flow controller when the Flow controller starts. Services that declare a dependency on another service are only evaluated after the services they depend on have been evaluated. GetServiceConsumers will now currently return instances of component.Component and service.Service which depend on a service. The set of component.Component dependants is currently empty since it is not yet possible for a component to define a dependency on a service. The follow items are left as follow-up work: * Allow components to define a dependency on a service. * Allow service data to be exposed to components which depend on that service. * Allow services to propagate to loaded modules. * Migrate existing services to be managed by the Flow controller. Related to grafana#4253.
rfratto
added a commit
that referenced
this issue
Aug 1, 2023
* flow/internal/controller: rename files holding DAG node implementations Rename all files holding DAG node implementations to start with node_ so they're easier to locate. * flow/internal/controller: add ServiceNode ServiceNode is the representation of a Flow service in the DAG. Note that it is not currently wired up anywhere. * flow/internal/controller: make NewLoader more flexible Create a new type, LoaderOptions, which passes options to a Loader, to make extending Loader with new options more flexible. LoaderOptions currently encapsulates ComponentGlobals, but will be expanded in the future to contain other relevant options (such as services to load in the DAG). * flow/internal/controller: add service nodes to graph Add service nodes to the graph when the graph is being constructed. If a service declares a dependency on another service, it forms a DAG edge. * flow/internal/controller: expose ServiceNodes to caller This change stores and exposes ServiceNodes after calls to Apply. * flow: enable the management of services This change adds a new field to flow.Options, Services, which causes the lifecycle management of services to be handled by the Flow controller. Services are added to the DAG as nodes, and are run with the Flow controller when the Flow controller starts. Services that declare a dependency on another service are only evaluated after the services they depend on have been evaluated. GetServiceConsumers will now currently return instances of component.Component and service.Service which depend on a service. The set of component.Component dependants is currently empty since it is not yet possible for a component to define a dependency on a service. The follow items are left as follow-up work: * Allow components to define a dependency on a service. * Allow service data to be exposed to components which depend on that service. * Allow services to propagate to loaded modules. * Migrate existing services to be managed by the Flow controller. Related to #4253.
rfratto
added a commit
to rfratto/agent
that referenced
this issue
Aug 1, 2023
This commit allows a component to define a dependency on a service. When wiring dependencies in the graph, the registration of a component is used to create the dependency. This also means that Flow.GetServiceConsumers will now implicitly return instances of [component.Component] which declare a dependency on the service. Related to grafana#4253.
rfratto
added a commit
to rfratto/agent
that referenced
this issue
Aug 1, 2023
This commit updates the Flow controller to expose service data to components. Components are only allowed to access service data for services they have listed as an explicit dependency. This ensures that services cannot access data for a service they depend on until that service has been evaluated. Related to grafana#4253.
rfratto
added a commit
that referenced
this issue
Aug 2, 2023
* component: allow components to depend on a service This commit allows a component to define a dependency on a service. When wiring dependencies in the graph, the registration of a component is used to create the dependency. This also means that Flow.GetServiceConsumers will now implicitly return instances of [component.Component] which declare a dependency on the service. Related to #4253. * component: expose service data to components This commit updates the Flow controller to expose service data to components. Components are only allowed to access service data for services they have listed as an explicit dependency. This ensures that services cannot access data for a service they depend on until that service has been evaluated. Related to #4253. * flow: add tests for components using services --------- Co-authored-by: Paschalis Tsilias <tpaschalis@users.noreply.github.com>
rfratto
added a commit
to rfratto/agent
that referenced
this issue
Aug 2, 2023
This change allows components to propagate services to module controllers. To avoid cyclic dependencies, only services which module loader depends on can be propagated. This effectively means that module loaders must always depend on all services. Related to grafana#4253.
rfratto
added a commit
to rfratto/agent
that referenced
this issue
Aug 2, 2023
This change allows components to propagate services to module controllers. To avoid cyclic dependencies, only services which module loader depends on can be propagated. This effectively means that module loaders must always depend on all services. Related to grafana#4253.
rfratto
added a commit
to rfratto/agent
that referenced
this issue
Aug 2, 2023
This change allows components to propagate services to module controllers. To avoid cyclic dependencies, only services which module loader depends on can be propagated. This effectively means that module loaders must always depend on all services. Related to grafana#4253.
rfratto
added a commit
that referenced
this issue
Aug 2, 2023
* pkg/flow: create internal options type for creating controllers Create an internal options type, `controllerOptions`, which extends the public `Options` type. This will be used for internal settings which should not be settable via users. For the initial commit, the module registry has been moved to this type. * flow/internal/controller: add ServiceMap type Add a new ServiceMap type to make set operations around services easier. * flow: propagate services to modules This change allows components to propagate services to module controllers. To avoid cyclic dependencies, only services which module loader depends on can be propagated. This effectively means that module loaders must always depend on all services. Related to #4253. * flow/internal/controller: allow passing custom component registries The component registry is used when constructing the graph. A custom component registry allows unit tests to make fake components without having to globally register them. * flow: use custom component registry for service tests * flow: write tests for propagating services to modules
clayton-cornell
pushed a commit
that referenced
this issue
Aug 14, 2023
* service: introduce new service package The `service/` package is used to define Flow services, low-level constructs which run for the lifetime of the Flow controller. This commit introduces just the API for services, without using it anywhere. Related to #4253. * pkg/flow: implement service.Host in Flow controller This commit updates the Flow controller to implement the new service.Host interface. Note that because it is not currently possible for a service or component to define a dependency on a service, the GetServiceConsumers method always returns nil. GetServiceConsumers will be updated in the future to return a non-nil list once it is possible for consumers of a service to exist. * service/http: port HTTP service to a service implementation This ports the HTTP service to implement the service.Service interface. The old HTTP service code has been removed in favor of the service. This required some hacks to wire everything in correctly; this will be cleaned up in the future once services are fully implemented.
clayton-cornell
pushed a commit
that referenced
this issue
Aug 14, 2023
* flow/internal/controller: rename files holding DAG node implementations Rename all files holding DAG node implementations to start with node_ so they're easier to locate. * flow/internal/controller: add ServiceNode ServiceNode is the representation of a Flow service in the DAG. Note that it is not currently wired up anywhere. * flow/internal/controller: make NewLoader more flexible Create a new type, LoaderOptions, which passes options to a Loader, to make extending Loader with new options more flexible. LoaderOptions currently encapsulates ComponentGlobals, but will be expanded in the future to contain other relevant options (such as services to load in the DAG). * flow/internal/controller: add service nodes to graph Add service nodes to the graph when the graph is being constructed. If a service declares a dependency on another service, it forms a DAG edge. * flow/internal/controller: expose ServiceNodes to caller This change stores and exposes ServiceNodes after calls to Apply. * flow: enable the management of services This change adds a new field to flow.Options, Services, which causes the lifecycle management of services to be handled by the Flow controller. Services are added to the DAG as nodes, and are run with the Flow controller when the Flow controller starts. Services that declare a dependency on another service are only evaluated after the services they depend on have been evaluated. GetServiceConsumers will now currently return instances of component.Component and service.Service which depend on a service. The set of component.Component dependants is currently empty since it is not yet possible for a component to define a dependency on a service. The follow items are left as follow-up work: * Allow components to define a dependency on a service. * Allow service data to be exposed to components which depend on that service. * Allow services to propagate to loaded modules. * Migrate existing services to be managed by the Flow controller. Related to #4253.
clayton-cornell
pushed a commit
that referenced
this issue
Aug 14, 2023
* component: allow components to depend on a service This commit allows a component to define a dependency on a service. When wiring dependencies in the graph, the registration of a component is used to create the dependency. This also means that Flow.GetServiceConsumers will now implicitly return instances of [component.Component] which declare a dependency on the service. Related to #4253. * component: expose service data to components This commit updates the Flow controller to expose service data to components. Components are only allowed to access service data for services they have listed as an explicit dependency. This ensures that services cannot access data for a service they depend on until that service has been evaluated. Related to #4253. * flow: add tests for components using services --------- Co-authored-by: Paschalis Tsilias <tpaschalis@users.noreply.github.com>
clayton-cornell
pushed a commit
that referenced
this issue
Aug 14, 2023
* pkg/flow: create internal options type for creating controllers Create an internal options type, `controllerOptions`, which extends the public `Options` type. This will be used for internal settings which should not be settable via users. For the initial commit, the module registry has been moved to this type. * flow/internal/controller: add ServiceMap type Add a new ServiceMap type to make set operations around services easier. * flow: propagate services to modules This change allows components to propagate services to module controllers. To avoid cyclic dependencies, only services which module loader depends on can be propagated. This effectively means that module loaders must always depend on all services. Related to #4253. * flow/internal/controller: allow passing custom component registries The component registry is used when constructing the graph. A custom component registry allows unit tests to make fake components without having to globally register them. * flow: use custom component registry for service tests * flow: write tests for propagating services to modules
clayton-cornell
pushed a commit
that referenced
this issue
Aug 14, 2023
* service: introduce new service package The `service/` package is used to define Flow services, low-level constructs which run for the lifetime of the Flow controller. This commit introduces just the API for services, without using it anywhere. Related to #4253. * pkg/flow: implement service.Host in Flow controller This commit updates the Flow controller to implement the new service.Host interface. Note that because it is not currently possible for a service or component to define a dependency on a service, the GetServiceConsumers method always returns nil. GetServiceConsumers will be updated in the future to return a non-nil list once it is possible for consumers of a service to exist. * service/http: port HTTP service to a service implementation This ports the HTTP service to implement the service.Service interface. The old HTTP service code has been removed in favor of the service. This required some hacks to wire everything in correctly; this will be cleaned up in the future once services are fully implemented.
clayton-cornell
pushed a commit
that referenced
this issue
Aug 14, 2023
* flow/internal/controller: rename files holding DAG node implementations Rename all files holding DAG node implementations to start with node_ so they're easier to locate. * flow/internal/controller: add ServiceNode ServiceNode is the representation of a Flow service in the DAG. Note that it is not currently wired up anywhere. * flow/internal/controller: make NewLoader more flexible Create a new type, LoaderOptions, which passes options to a Loader, to make extending Loader with new options more flexible. LoaderOptions currently encapsulates ComponentGlobals, but will be expanded in the future to contain other relevant options (such as services to load in the DAG). * flow/internal/controller: add service nodes to graph Add service nodes to the graph when the graph is being constructed. If a service declares a dependency on another service, it forms a DAG edge. * flow/internal/controller: expose ServiceNodes to caller This change stores and exposes ServiceNodes after calls to Apply. * flow: enable the management of services This change adds a new field to flow.Options, Services, which causes the lifecycle management of services to be handled by the Flow controller. Services are added to the DAG as nodes, and are run with the Flow controller when the Flow controller starts. Services that declare a dependency on another service are only evaluated after the services they depend on have been evaluated. GetServiceConsumers will now currently return instances of component.Component and service.Service which depend on a service. The set of component.Component dependants is currently empty since it is not yet possible for a component to define a dependency on a service. The follow items are left as follow-up work: * Allow components to define a dependency on a service. * Allow service data to be exposed to components which depend on that service. * Allow services to propagate to loaded modules. * Migrate existing services to be managed by the Flow controller. Related to #4253.
clayton-cornell
pushed a commit
that referenced
this issue
Aug 14, 2023
* component: allow components to depend on a service This commit allows a component to define a dependency on a service. When wiring dependencies in the graph, the registration of a component is used to create the dependency. This also means that Flow.GetServiceConsumers will now implicitly return instances of [component.Component] which declare a dependency on the service. Related to #4253. * component: expose service data to components This commit updates the Flow controller to expose service data to components. Components are only allowed to access service data for services they have listed as an explicit dependency. This ensures that services cannot access data for a service they depend on until that service has been evaluated. Related to #4253. * flow: add tests for components using services --------- Co-authored-by: Paschalis Tsilias <tpaschalis@users.noreply.github.com>
clayton-cornell
pushed a commit
that referenced
this issue
Aug 14, 2023
* pkg/flow: create internal options type for creating controllers Create an internal options type, `controllerOptions`, which extends the public `Options` type. This will be used for internal settings which should not be settable via users. For the initial commit, the module registry has been moved to this type. * flow/internal/controller: add ServiceMap type Add a new ServiceMap type to make set operations around services easier. * flow: propagate services to modules This change allows components to propagate services to module controllers. To avoid cyclic dependencies, only services which module loader depends on can be propagated. This effectively means that module loaders must always depend on all services. Related to #4253. * flow/internal/controller: allow passing custom component registries The component registry is used when constructing the graph. A custom component registry allows unit tests to make fake components without having to globally register them. * flow: use custom component registry for service tests * flow: write tests for propagating services to modules
9 tasks
github-actions
bot
added
the
frozen-due-to-age
Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed.
label
Feb 21, 2024
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
enhancement
New feature or request
flow
Related to Grafana Agent Flow
frozen-due-to-age
Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed.
proposal
Proposal or RFC
proposal-accepted
Proposal has been accepted.
The most recent copy of this proposal can be found on Google docs. The below may be out of date, but is left in for posterity.
Background
In the context of Flow, a "service" is a low-level primitive which exposes additional behavior on top of the Flow controller. Today, there are three services that exist in
pkg/flow
:All of the services today are started prior to the Flow controller.
One of the remaining items for Flow feature parity is adding support for configuring TLS settings for the HTTP service at runtime. This would be added as a new config block into the Flow configuration file. This leads to a minimum set of functional requirements:
remote.vault
), those components must be evaluated first to be able to evaluate the TLS settings properly.prometheus.exporter.unix
depends on the HTTP service to create its targets.These functional requirements extend to the clustering service, which must only start after the HTTP service is ready.
To allow services to be configured at runtime, those services (any any service which depends on them) must now exist in the DAG to ensure proper evaluation order; today, only the telemetry service exists in the DAG.
Additionally, there has been ongoing work to prepare Grafana Agent for a 1.0 release. This included some preliminary offline discussions about moving Flow and River to a separate repository so they may have their own versions separate from Grafana Agent.
This proposal aims to solve both problems at once:
pkg/flow
in preparation for Flow and River to be moved to a dedicated Git repository.Goals
pkg/flow
.Non-goals
Design
A new
service
package will be introduced which defines the API that services will have at their disposal:The
component
package will be updated to be aware of services:The
flow
package will also be updated to be aware of services:Notes
service.Host
interface will be implemented by the Flow controller.service.Host.GetServiceConsumers
is required for the HTTP interface to install HTTP handlers for the clustering service, and for an optimization, look up components which depend on a service.any
to avoid circular dependencies. The component, flow, and service packages should be merged in the future to avoid this, but this change is out of scope for this proposal.service.Service.Data
can return anything which might be useful to components, such as information about the service in a struct (such as the HTTP listen address), or an interface so components can invoke methods (such as looking up the clustering owner for at token).component.Component.Update
.Details
The Flow controller will create DAG nodes for each service assigned to it. Edges from service nodes will be based on:
service.Definition
.component.Registration
.Having services in the DAG will ensure that there are no cyclic dependencies.
Services will only run once the Flow controller is run; Flow.LoadFile must be called before Flow.Run to make sure that the HTTP service does not run before TLS is configured.
Refer to the design above for other aspects of how the services API behaves.
Thanks
Thanks to @erikbaranowski for his help on this proposal.
The text was updated successfully, but these errors were encountered: