consul/agent/hcp
Nick Cellino 5fb6ab6a3a
Move HCP Manager lifecycle management out of Link controller (#20401)
* Add function to get update channel for watching HCP Link

* Add MonitorHCPLink function

This function can be called in a goroutine to manage the lifecycle
of the HCP manager.

* Update HCP Manager config in link monitor before starting

This updates HCPMonitorLink so it updates the HCP manager
with an HCP client and management token when a Link is upserted.

* Let MonitorHCPManager handle lifecycle instead of link controller

* Remove cleanup from Link controller and move it to MonitorHCPLink

Previously, the Link Controller was responsible for cleaning up the
HCP-related files on the file system. This change makes it so
MonitorHCPLink handles this cleanup. As a result, we are able to remove
the PlacementEachServer placement strategy for the Link controller
because it no longer needs to do this per-node cleanup.

* Remove HCP Manager dependency from Link Controller

The Link controller does not need to have HCP Manager
as a dependency anymore, so this removes that dependency
in order to simplify the design.

* Add Linked prefix to Linked status variables

This is in preparation for adding a new status type to the
Link resource.

* Add new "validated" status type to link resource

The link resource controller will now set a "validated" status
in addition to the "linked" status. This is needed so that other
components (eg the HCP manager) know when the Link is ready to link
with HCP.

* Fix tests

* Handle new 'EndOfSnapshot' WatchList event

* Fix watch test

* Remove unnecessary config from TestAgent_scadaProvider

Since the Scada provider is now started on agent startup
regardless of whether a cloud config is provided, this removes
the cloud config override from the relevant test.

This change is not exactly related to the changes from this PR,
but rather is something small and sort of related that was noticed
while working on this PR.

* Simplify link watch test and remove sleep from link watch

This updates the link watch test so that it uses more mocks
and does not require setting up the infrastructure for the HCP Link
controller.

This also removes the time.Sleep delay in the link watcher loop in favor
of an error counter. When we receive 10 consecutive errors, we shut down
the link watcher loop.

* Add better logging for link validation. Remove EndOfSnapshot test.

* Refactor link monitor test into a table test

* Add some clarifying comments to link monitor

* Simplify link watch test

* Test a bunch more errors cases in link monitor test

* Use exponential backoff instead of errorCounter in LinkWatch

* Move link watch and link monitor into a single goroutine called from server.go

* Refactor HCP link watcher to use single go-routine.

Previously, if the WatchClient errored, we would've never recovered
because we never retry to create the stream. With this change,
we have a single goroutine that runs for the life of the server agent
and if the WatchClient stream ever errors, we retry the creation
of the stream with an exponential backoff.
2024-02-12 10:48:23 -05:00
..
bootstrap Move HCP Manager lifecycle management out of Link controller (#20401) 2024-02-12 10:48:23 -05:00
client Fix: avoid redundant logs on failures to export metrics (#20519) 2024-02-08 11:00:20 -05:00
config [CC-7044] Start HCP manager as part of link creation (#20312) 2024-01-29 16:31:44 -06:00
discover [COMPLIANCE] License changes (#18443) 2023-08-11 09:12:13 -04:00
scada [CC-7041] Update and start the SCADA provider in HCP manager (#19976) 2024-01-08 09:49:29 -06:00
telemetry [CC-7044] Start HCP manager as part of link creation (#20312) 2024-01-29 16:31:44 -06:00
testserver [COMPLIANCE] License changes (#18443) 2023-08-11 09:12:13 -04:00
deps.go Fix logging when we fail to export metrics to hcp (#20514) 2024-02-08 11:00:47 -05:00
deps_test.go Fix logging when we fail to export metrics to hcp (#20514) 2024-02-08 11:00:47 -05:00
link_watch.go Move HCP Manager lifecycle management out of Link controller (#20401) 2024-02-12 10:48:23 -05:00
link_watch_test.go Move HCP Manager lifecycle management out of Link controller (#20401) 2024-02-12 10:48:23 -05:00
manager.go Move HCP Manager lifecycle management out of Link controller (#20401) 2024-02-12 10:48:23 -05:00
manager_lifecycle.go Move HCP Manager lifecycle management out of Link controller (#20401) 2024-02-12 10:48:23 -05:00
manager_lifecycle_test.go Move HCP Manager lifecycle management out of Link controller (#20401) 2024-02-12 10:48:23 -05:00
manager_test.go Move HCP Manager lifecycle management out of Link controller (#20401) 2024-02-12 10:48:23 -05:00
mock_Manager.go [CC-7049] Stop the HCP manager when link is deleted (#20351) 2024-01-30 09:40:36 -06:00
mock_TelemetryProvider.go [CC-7049] Stop the HCP manager when link is deleted (#20351) 2024-01-30 09:40:36 -06:00
telemetry_provider.go Fix: avoid redundant logs on failures to export metrics (#20519) 2024-02-08 11:00:20 -05:00
telemetry_provider_test.go [CC-7049] Stop the HCP manager when link is deleted (#20351) 2024-01-30 09:40:36 -06:00
testing.go [Cloud][CC-6925] Updates to pushing server state (#19682) 2023-12-04 10:25:18 -05:00