@@ -18,6 +18,7 @@ import (
18
18
19
19
"github.com/newrelic/infrastructure-agent/pkg/sysinfo/hostid"
20
20
21
+ "github.com/newrelic/infrastructure-agent/internal/agent/cmdchannel/fflag"
21
22
"github.com/newrelic/infrastructure-agent/internal/agent/instrumentation"
22
23
"github.com/newrelic/infrastructure-agent/internal/agent/inventory"
23
24
"github.com/newrelic/infrastructure-agent/internal/agent/types"
@@ -95,6 +96,7 @@ type Agent struct {
95
96
agentID * entity.ID // pointer as it's referred from several points
96
97
mtx sync.Mutex // Protect plugins
97
98
notificationHandler * ctl.NotificationHandlerWithCancellation // Handle ipc messaging.
99
+ ffRetriever feature_flags.Retriever
98
100
}
99
101
100
102
type inventoryState struct {
@@ -393,6 +395,7 @@ func NewAgent(
393
395
cloudHarvester ,
394
396
fpHarvester ,
395
397
notificationHandler ,
398
+ ffRetriever ,
396
399
)
397
400
}
398
401
@@ -410,6 +413,7 @@ func New(
410
413
cloudHarvester cloud.Harvester ,
411
414
fpHarvester fingerprint.Harvester ,
412
415
notificationHandler * ctl.NotificationHandlerWithCancellation ,
416
+ ffRetriever feature_flags.Retriever ,
413
417
) (* Agent , error ) {
414
418
a := & Agent {
415
419
Context : ctx ,
@@ -422,6 +426,7 @@ func New(
422
426
connectSrv : connectSrv ,
423
427
provideIDs : provideIDs ,
424
428
notificationHandler : notificationHandler ,
429
+ ffRetriever : ffRetriever ,
425
430
}
426
431
427
432
a .plugins = make ([]Plugin , 0 )
@@ -820,6 +825,19 @@ func (a *Agent) Run() (err error) {
820
825
close (exit )
821
826
}()
822
827
828
+ // We check FF to delete the whole inventory and trigger the whoel inventory send
829
+ // This will bypass the deltas cache and force the inventory to be sent after restarting the Agent
830
+ if a .ffRetriever != nil {
831
+ alog .Debug ("readding FlagFullInventoryDeletion feature flag" )
832
+ ffFullInventoryDeletionEnabled , ffExists := a .ffRetriever .GetFeatureFlag (fflag .FlagFullInventoryDeletion )
833
+ if ffExists && ffFullInventoryDeletionEnabled {
834
+ alog .Info ("Cleaning inventory cache and forcing full inventory report" )
835
+ a .store .ResetAllDeltas (a .Context .EntityKey ())
836
+ }
837
+ } else {
838
+ alog .Warn ("Feature flags retriever is not available" )
839
+ }
840
+
823
841
if a .inventoryHandler != nil {
824
842
if a .shouldSendInventory () {
825
843
a .inventoryHandler .Start ()
0 commit comments