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

Allow running the shipper in standalone mode independently of the agent #83

Closed
Tracked by #60 ...
cmacknz opened this issue Jul 21, 2022 · 2 comments · Fixed by #103
Closed
Tracked by #60 ...

Allow running the shipper in standalone mode independently of the agent #83

cmacknz opened this issue Jul 21, 2022 · 2 comments · Fixed by #103
Assignees
Labels
Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team v8.5.0

Comments

@cmacknz
Copy link
Member

cmacknz commented Jul 21, 2022

The shipper's default mode of operation is to expect to be started by the agent, expecting to be passed the address of the agent control protocol server to connect to. The control protocol is then responsible for sending the shipper it's runtime configuration.

To make local development and testing easier, allow the shipper to run in a standalone mode independent of the agent. Add a new command line flag that causes the shipper to read its configuration file from disk and start without waiting to connect to the agent control protocol server.

@cmacknz cmacknz added Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team v8.5.0 labels Jul 21, 2022
@cmacknz cmacknz changed the title Allow running the shipper independently of the agent Allow running the shipper in standalone mode independently of the agent Jul 21, 2022
@rdner
Copy link
Member

rdner commented Aug 16, 2022

It's currently possible to run the shipper server using the controller mock like so:

srv := mock.StubServerV2{
CheckinV2Impl: func(observed *proto.CheckinObserved) *proto.CheckinExpected {
mut.Lock()
defer mut.Unlock()
if observed.Token == token {
if len(observed.Units) > 0 {
t.Logf("Current unit state is: %v", observed.Units[0].State)
}
// initial checkin
if len(observed.Units) == 0 || observed.Units[0].State == proto.State_STARTING {
gotConfig = true
return &proto.CheckinExpected{
Units: []*proto.UnitExpected{
{
Id: unitOneID,
Type: proto.UnitType_OUTPUT,
ConfigStateIdx: 1,
Config: &proto.UnitExpectedConfig{
Source: MustNewStruct(t, map[string]interface{}{
"logging": map[string]interface{}{"level": "debug"},
}),
},
State: proto.State_HEALTHY,
},
},
}
} else if observed.Units[0].State == proto.State_HEALTHY {
gotHealthy = true
//shutdown
return &proto.CheckinExpected{
Units: []*proto.UnitExpected{
{
Id: unitOneID,
Type: proto.UnitType_OUTPUT,
ConfigStateIdx: 1,
State: proto.State_STOPPED,
},
},
}
} else if observed.Units[0].State == proto.State_STOPPED {
gotStopped = true
// remove the unit? I think?
return &proto.CheckinExpected{
Units: nil,
}
}
}
//gotInvalid = true
return nil
},
ActionImpl: func(response *proto.ActionResponse) error {
return nil
},
ActionsChan: make(chan *mock.PerformAction, 100),
} // end of srv declaration

We're planning to automate this but for the time being it can be coded quickly for debugging.

@rdner
Copy link
Member

rdner commented Aug 31, 2022

For now it's going to be implemented as a flag that uses a configuration file bypassing the control protocol altogether. This will enable us to run integration tests without running the actual agent.

However, there is this agent mock tool being developed that will allow us to include the control protocol implementation in our integration tests as well. The flag is rather a temporary solution.

@rdner rdner mentioned this issue Sep 1, 2022
3 tasks
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.5.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants