@@ -32,18 +32,22 @@ var _ manager.LeaderElectionRunnable = &Daemon{}
3232// Daemon subscribes to fleet-specific RC products (installer configs and tasks)
3333// and runs after leader election as a controller-runtime Runnable.
3434type Daemon struct {
35- rcClient remoteconfig.RCClient
36- client client.Client
37- mu sync.RWMutex
38- configs map [string ]installerConfig // keyed by config ID; replaced on each RC update
35+ rcClient remoteconfig.RCClient
36+ client client.Client
37+ revisionsEnabled bool
38+ mu sync.RWMutex
39+ configs map [string ]installerConfig // keyed by config ID; replaced on each RC update
3940}
4041
41- // NewDaemon creates a new Fleet Daemon.
42- func NewDaemon (rcClient remoteconfig.RCClient , k8sClient client.Client ) * Daemon {
42+ // NewDaemon creates a new Fleet Daemon. When revisionsEnabled is false, experiment
43+ // signals are rejected because the reconciler cannot process them without the
44+ // ControllerRevision machinery.
45+ func NewDaemon (rcClient remoteconfig.RCClient , k8sClient client.Client , revisionsEnabled bool ) * Daemon {
4346 return & Daemon {
44- rcClient : rcClient ,
45- client : k8sClient ,
46- configs : make (map [string ]installerConfig ),
47+ rcClient : rcClient ,
48+ client : k8sClient ,
49+ revisionsEnabled : revisionsEnabled ,
50+ configs : make (map [string ]installerConfig ),
4751 }
4852}
4953
@@ -101,6 +105,11 @@ func (d *Daemon) getConfig(id string) (installerConfig, error) {
101105// handleRemoteAPIRequest dispatches the incoming task to the appropriate handler.
102106func (d * Daemon ) handleRemoteAPIRequest (ctx context.Context , req remoteAPIRequest ) error {
103107 ctrl .LoggerFrom (ctx ).Info ("Received remote API request" , "id" , req .ID , "package" , req .Package , "method" , req .Method )
108+
109+ if ! d .revisionsEnabled {
110+ return fmt .Errorf ("experiment signals require the CreateControllerRevisions and DatadogAgentInternal feature gates" )
111+ }
112+
104113 switch req .Method {
105114 case methodStartDatadogAgentExperiment :
106115 return d .startDatadogAgentExperiment (ctx , req )
0 commit comments