in agent/framework/coremanager/coremanager.go [88:209]
func initializeBookkeepingLocations(log logger.T, shortInstanceID string) bool {
//TODO: initializations for all state tracking folders of core modules should be moved inside the corresponding core modules.
//Create folders pending, current, completed, corrupt under the location DefaultLogDirPath/<instanceId>
log.Info("Initializing bookkeeping folders")
initStatus := true
folders := []string{
appconfig.DefaultLocationOfPending,
appconfig.DefaultLocationOfCurrent,
appconfig.DefaultLocationOfCompleted,
appconfig.DefaultLocationOfCorrupt}
for _, folder := range folders {
directoryName := filepath.Join(appconfig.DefaultDataStorePath,
shortInstanceID,
appconfig.DefaultDocumentRootDirName,
appconfig.DefaultLocationOfState,
folder)
//legacy dir, unused
if folder == appconfig.DefaultLocationOfCompleted {
log.Info("removing the completed state files")
fileutil.DeleteDirectory(directoryName)
}
err := fileutil.MakeDirs(directoryName)
if err != nil {
log.Errorf("Encountered error while creating folders for internal state management. %v", err)
initStatus = false
break
}
}
//Create folders for long running plugins
log.Infof("Initializing bookkeeping folders for long running plugins")
longRunningPluginsFolderName := filepath.Join(appconfig.DefaultDataStorePath,
shortInstanceID,
appconfig.LongRunningPluginsLocation,
appconfig.LongRunningPluginDataStoreLocation)
if err := fileutil.MakeDirs(longRunningPluginsFolderName); err != nil {
log.Error("encountered error while creating folders for internal state management for long running plugins", err)
initStatus = false
}
log.Infof("Initializing replies folder for MDS reply requests that couldn't reach the service")
replies := filepath.Join(appconfig.DefaultDataStorePath,
shortInstanceID,
appconfig.RepliesRootDirName)
if err := fileutil.MakeDirs(replies); err != nil {
log.Error("encountered error while creating folders for MDS replies", err)
initStatus = false
}
log.Infof("Initializing replies folder for MGS reply requests that couldn't reach the service")
mgsReplies := filepath.Join(appconfig.DefaultDataStorePath,
shortInstanceID,
appconfig.RepliesMGSRootDirName)
if err := fileutil.MakeDirs(mgsReplies); err != nil {
log.Error("encountered error while creating folders for MGS replies", err)
initStatus = false
}
log.Infof("Initializing healthcheck folders for long running plugins")
f := filepath.Join(appconfig.DefaultDataStorePath,
shortInstanceID,
appconfig.LongRunningPluginsLocation,
appconfig.LongRunningPluginsHealthCheck)
if err := fileutil.MakeDirs(f); err != nil {
log.Error("encountered error while creating folders for health check for long running plugins", err)
initStatus = false
}
//Create folders for inventory plugin
log.Infof("Initializing locations for inventory plugin")
inventoryLocation := filepath.Join(appconfig.DefaultDataStorePath,
shortInstanceID,
appconfig.InventoryRootDirName)
if err := fileutil.MakeDirs(inventoryLocation); err != nil {
log.Error("encountered error while creating folders for inventory plugin", err)
initStatus = false
}
log.Infof("Initializing default location for custom inventory")
customInventoryLocation := filepath.Join(appconfig.DefaultDataStorePath,
shortInstanceID,
appconfig.InventoryRootDirName,
appconfig.CustomInventoryRootDirName)
if err := fileutil.MakeDirs(customInventoryLocation); err != nil {
log.Error("encountered error while creating folders for custom inventory", err)
initStatus = false
}
log.Infof("Initializing default location for file inventory")
fileInventoryLocation := filepath.Join(appconfig.DefaultDataStorePath,
shortInstanceID,
appconfig.InventoryRootDirName,
appconfig.FileInventoryRootDirName)
if err := fileutil.MakeDirs(fileInventoryLocation); err != nil {
log.Error("encountered error while creating folders for file inventory", err)
initStatus = false
}
log.Infof("Initializing default location for role inventory")
roleInventoryLocation := filepath.Join(appconfig.DefaultDataStorePath,
shortInstanceID,
appconfig.InventoryRootDirName,
appconfig.RoleInventoryRootDirName)
if err := fileutil.MakeDirs(roleInventoryLocation); err != nil {
log.Error("encountered error while creating folders for role inventory", err)
initStatus = false
}
return initStatus
}