Skip to content
This repository has been archived by the owner on Sep 21, 2023. It is now read-only.

Add V1 controller and spec support to the shipper #59

Merged

Conversation

fearful-symmetry
Copy link
Contributor

@fearful-symmetry fearful-symmetry commented Jun 15, 2022

This adds support for the V1 build system and controller into the shipper. This is a breaking change that will live on its own branch, and it changes the config and startup so the shipper can only run under agent, as I assume there's no standalone use case for this.

There's two parts to this:

  • Integrate the shipper into the existing dev-tools targets so that agent can run mage package. There seems to be a lot of cruft and legacy tooling in the package targets that require a variety of extra files, targets, etc, and we may want to clean those up at a later date.
  • Add the client control code. The agent client code is tested with what little surrounding infrastructure exists now, and it can start, send config to, and stop the shipper.

TODO:

  • Test with the newly-merged console output
  • Make the client test actually test something, and not just log results

@fearful-symmetry fearful-symmetry added Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team v8.4.0 labels Jun 15, 2022
@fearful-symmetry fearful-symmetry requested a review from a team as a code owner June 15, 2022 22:01
@fearful-symmetry fearful-symmetry requested review from kvch and faec and removed request for a team June 15, 2022 22:01
@fearful-symmetry fearful-symmetry self-assigned this Jun 15, 2022
@fearful-symmetry fearful-symmetry changed the base branch from main to v1-support June 15, 2022 22:02
@elasticmachine
Copy link
Collaborator

elasticmachine commented Jun 15, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-06-20T19:35:01.399+0000

  • Duration: 10 min 10 sec

Test stats 🧪

Test Results
Failed 0
Passed 12
Skipped 0
Total 12

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

@cmacknz cmacknz requested a review from rdner June 16, 2022 18:24
@cmacknz
Copy link
Member

cmacknz commented Jun 16, 2022

For clarification on the plan with the shipper integrating with the different control protocol versions:

  • The main branch will support the V2 protocol. The V2 protocol is currently being implemented however, and it doesn't yet give us a way to do end to ends tests of the shipper running under agent.
  • This V1 branch will continue to live until the V2 protocol implementation in the agent is complete. This gives us a way to run the shipper with the agent as needed while we wait for the V2 protocol implementation to complete.

&devtools.BuildVariableSources{
BeatVersion: "./version/version.go",
GoVersion: ".go-version",
DocBranch: "./docs/version.asciidoc",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't think we need a doc version, because there are no docs here.

Do we need this with V2 as well? If so we should just modify the tooling to make this optional.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are all required by the Package target, and it looks like we blindly copied them all into elastic-agent from beats. Currently unsure if it's worth it to make our own mage package target separate from beats and agent in the scope of this, since the build system is kind of a snarl. The good news is that the V2 build system removes most of this cruft, so I'm kind of mentally treating this as a temporary holdover until then.

// OnConfig is called by the agent on a requested config change
func (client *AgentClient) OnConfig(in string) {
client.log.Infof("Got config update, (re)starting the shipper")
_ = client.client.Status(proto.StateObserved_CONFIGURING, "configuring from OnConfig", nil)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming this is an RPC call, I'm curious what state the system is left in if this fails. Do we just get this again? Is the behavior more obvious in V2?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yah, status calls are more organized in V2. None of the beats V1 code checks the error, and I'm kind of operating under the assumption that if the RPC fails, we have bigger problems than updating the status.

@cmacknz
Copy link
Member

cmacknz commented Jun 16, 2022

Thanks for making this work! Unless we decide to promote this to main I am hesitant to review it too thoroughly. I am interested to see what this looks like under V2 as there seems like lots of tricky things that can happen around Start/Stop calls and configuration reloading.

server/client_test.go Outdated Show resolved Hide resolved
server/server.go Outdated Show resolved Hide resolved
server/server.go Outdated
serv.grpcServer.GracefulStop()
serv.queue.Close()
// Don't try to gracefully stop monitoring until we deal with expvar
//s.monHandler.End()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this still pending? It's not obvious to me from the comment what still needs to happen for this line to be activated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yah, I think we might just want to remove the expvar End() for now, since there isn't really an easy workaround for it.

@fearful-symmetry fearful-symmetry merged commit 42b3946 into elastic:v1-support Jun 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team v8.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants