@@ -16,10 +16,12 @@ import (
16
16
"github.com/elastic/elastic-agent-libs/logp"
17
17
18
18
"github.com/elastic/elastic-agent/internal/pkg/agent/application/coordinator"
19
+ "github.com/elastic/elastic-agent/internal/pkg/agent/application/dispatcher"
19
20
"github.com/elastic/elastic-agent/internal/pkg/agent/application/info"
20
21
"github.com/elastic/elastic-agent/internal/pkg/agent/application/monitoring"
21
22
"github.com/elastic/elastic-agent/internal/pkg/agent/application/paths"
22
23
"github.com/elastic/elastic-agent/internal/pkg/agent/application/upgrade"
24
+ "github.com/elastic/elastic-agent/internal/pkg/agent/application/upgrade/details"
23
25
"github.com/elastic/elastic-agent/internal/pkg/agent/configuration"
24
26
"github.com/elastic/elastic-agent/internal/pkg/agent/errors"
25
27
"github.com/elastic/elastic-agent/internal/pkg/agent/storage"
@@ -34,6 +36,7 @@ import (
34
36
"github.com/elastic/elastic-agent/internal/pkg/fleetapi/acker/retrier"
35
37
fleetclient "github.com/elastic/elastic-agent/internal/pkg/fleetapi/client"
36
38
otelmanager "github.com/elastic/elastic-agent/internal/pkg/otel/manager"
39
+ "github.com/elastic/elastic-agent/internal/pkg/queue"
37
40
"github.com/elastic/elastic-agent/internal/pkg/release"
38
41
"github.com/elastic/elastic-agent/pkg/component"
39
42
"github.com/elastic/elastic-agent/pkg/component/runtime"
@@ -59,6 +62,7 @@ func New(
59
62
fleetInitTimeout time.Duration ,
60
63
disableMonitoring bool ,
61
64
override CfgOverrider ,
65
+ initialUpgradeDetails * details.Details ,
62
66
modifiers ... component.PlatformModifier ,
63
67
) (* coordinator.Coordinator , coordinator.ConfigManager , composable.Controller , error ) {
64
68
@@ -143,7 +147,6 @@ func New(
143
147
var compModifiers = []coordinator.ComponentsModifier {InjectAPMConfig }
144
148
var composableManaged bool
145
149
var isManaged bool
146
-
147
150
var actionAcker acker.Acker
148
151
if testingMode {
149
152
log .Info ("Elastic Agent has been started in testing mode and is managed through the control protocol" )
@@ -212,8 +215,19 @@ func New(
212
215
batchedAcker := lazy .NewAcker (fleetAcker , log , lazy .WithRetrier (retrier ))
213
216
actionAcker = stateStore .NewStateStoreActionAcker (batchedAcker , stateStorage )
214
217
218
+ actionQueue , err := queue .NewActionQueue (stateStorage .Queue (), stateStorage )
219
+ if err != nil {
220
+ return nil , nil , nil , fmt .Errorf ("unable to initialize action queue: %w" , err )
221
+ }
222
+
223
+ if initialUpgradeDetails == nil {
224
+ // initial upgrade details are nil (normally the caller supplies the ones from the marker file at this point),
225
+ // hence, extract any scheduled upgrade details from the action queue.
226
+ initialUpgradeDetails = dispatcher .GetScheduledUpgradeDetails (log , actionQueue .Actions (), time .Now ())
227
+ }
228
+
215
229
// TODO: stop using global state
216
- managed , err = newManagedConfigManager (ctx , log , agentInfo , cfg , store , runtime , fleetInitTimeout , paths .Top (), client , fleetAcker , actionAcker , retrier , stateStorage , upgrader )
230
+ managed , err = newManagedConfigManager (ctx , log , agentInfo , cfg , store , runtime , fleetInitTimeout , paths .Top (), client , fleetAcker , actionAcker , retrier , stateStorage , actionQueue , upgrader )
217
231
if err != nil {
218
232
return nil , nil , nil , err
219
233
}
@@ -226,8 +240,16 @@ func New(
226
240
return nil , nil , nil , errors .New (err , "failed to initialize composable controller" )
227
241
}
228
242
243
+ << << << < HEAD
229
244
otelManager := otelmanager .NewOTelManager (log .Named ("otel_manager" ))
230
245
coord := coordinator .New (log , cfg , logLevel , agentInfo , specs , reexec , upgrader , runtime , configMgr , varsManager , caps , monitor , isManaged , otelManager , actionAcker , compModifiers ... )
246
+ == == == =
247
+ otelManager , err := otelmanager .NewOTelManager (log .Named ("otel_manager" ), logLevel , baseLogger , otelmanager .EmbeddedExecutionMode , agentInfo , monitor .ComponentMonitoringConfig )
248
+ if err != nil {
249
+ return nil , nil , nil , fmt .Errorf ("failed to create otel manager: %w" , err )
250
+ }
251
+ coord := coordinator .New (log , cfg , logLevel , agentInfo , specs , reexec , upgrader , runtime , configMgr , varsManager , caps , monitor , isManaged , otelManager , actionAcker , initialUpgradeDetails , compModifiers ... )
252
+ >> >> >> > ff8047180 (fix : scheduled upgrade details state (#9562 ))
231
253
if managed != nil {
232
254
// the coordinator requires the config manager as well as in managed-mode the config manager requires the
233
255
// coordinator, so it must be set here once the coordinator is created
0 commit comments