Skip to content

Commit

Permalink
chore(agent-control): rename Super Agent to Agent Control
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenruizdegauna committed Dec 16, 2024
1 parent 63ba336 commit c02a833
Show file tree
Hide file tree
Showing 13 changed files with 109 additions and 109 deletions.
4 changes: 2 additions & 2 deletions internal/install/bundle_installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (bi *BundleInstaller) InstallContinueOnError(bundle *recipes.Bundle, assume

func (bi *BundleInstaller) reportBundleStatus(bundle *recipes.Bundle) {
for _, recipe := range bundle.BundleRecipes {
if types.SuperAgentRecipeName == recipe.Recipe.Name && recipe.LastStatus(execution.RecipeStatusTypes.INSTALLED) {
if types.AgentControlRecipeName == recipe.Recipe.Name && recipe.LastStatus(execution.RecipeStatusTypes.INSTALLED) {
continue
}
if bi.installedRecipes[recipe.Recipe.Name] {
Expand Down Expand Up @@ -130,7 +130,7 @@ func (bi *BundleInstaller) InstallBundleRecipe(bundleRecipe *recipes.BundleRecip
}

recipeName := bundleRecipe.Recipe.Name
if strings.EqualFold(recipeName, types.SuperAgentRecipeName) && bundleRecipe.HasStatus(execution.RecipeStatusTypes.INSTALLED) {
if strings.EqualFold(recipeName, types.AgentControlRecipeName) && bundleRecipe.HasStatus(execution.RecipeStatusTypes.INSTALLED) {
return nil
}
if bi.installedRecipes[bundleRecipe.Recipe.Name] {
Expand Down
10 changes: 5 additions & 5 deletions internal/install/bundle_installer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ func TestInstallContinueOnErrorReturnsImmediatelyWhenNoIsEntered(t *testing.T) {
test.mockStatusReporter.AssertNumberOfCalls(t, "ReportStatus", 1)
}

func TestInstallContinueOnErrorReturnsImmediatelyWhenSuperAgentIsInstalled(t *testing.T) {
func TestInstallContinueOnErrorReturnsImmediatelyWhenAgentControlIsInstalled(t *testing.T) {
test := createBundleInstallerTest().withPrompterYesNoVal(false).withRecipeInstallerError()
test.addRecipeToBundle("super-agent", execution.RecipeStatusTypes.INSTALLED)
test.addRecipeToBundle("agent-control", execution.RecipeStatusTypes.INSTALLED)

test.BundleInstaller.InstallContinueOnError(test.bundle, false)

test.mockRecipeInstaller.AssertNumberOfCalls(t, "executeAndValidateWithProgress", 0)
test.mockStatusReporter.AssertNumberOfCalls(t, "ReportStatus", 0)
}

func TestInstallContinueOnErrorWhenSuperAgentIsAvailable(t *testing.T) {
func TestInstallContinueOnErrorWhenAgentControlIsAvailable(t *testing.T) {
test := createBundleInstallerTest().withPrompterYesNoVal(false).withRecipeInstallerError()
test.addRecipeToBundle("super-agent", execution.RecipeStatusTypes.AVAILABLE)
test.addRecipeToBundle("agent-control", execution.RecipeStatusTypes.AVAILABLE)

test.BundleInstaller.InstallContinueOnError(test.bundle, false)

Expand All @@ -82,7 +82,7 @@ func TestInstallContinueOnErrorIgnoresUxPromptIfBundleIsAdditionalTargeted(t *te

func TestInstallContinueOnErrorIgnoresUxPromptIfBundleIsAdditionalTargetedSuperIsInstalled(t *testing.T) {
test := createBundleInstallerTest().withRecipeInstallerSuccess()
test.addRecipeToBundle(types.SuperAgentRecipeName, execution.RecipeStatusTypes.INSTALLED)
test.addRecipeToBundle(types.AgentControlRecipeName, execution.RecipeStatusTypes.INSTALLED)
test.BundleInstaller.InstallContinueOnError(test.bundle, true)

test.mockRecipeInstaller.AssertNumberOfCalls(t, "executeAndValidateWithProgress", 0)
Expand Down
8 changes: 4 additions & 4 deletions internal/install/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ var Command = &cobra.Command{

i := NewRecipeInstaller(ic)

//// Do not install both infra and super agents simultaneously: install only the 'super-agent' if targeted.
//if i.IsRecipeTargeted(types.SuperAgentRecipeName) && i.shouldInstallCore() {
// log.Debugf("'%s' is targeted, disabling infra/logs core bundle install\n", types.SuperAgentRecipeName)
//// Do not install both infra and agent controls simultaneously: install only the 'agent-control' if targeted.
//if i.IsRecipeTargeted(types.AgentControlRecipeName) && i.shouldInstallCore() {
// log.Debugf("'%s' is targeted, disabling infra/logs core bundle install\n", types.AgentControlRecipeName)
// i.shouldInstallCore = func() bool { return false }
//}

Expand All @@ -76,7 +76,7 @@ var Command = &cobra.Command{
return e
}

if errors.Is(err, types.ErrSuperAgent) {
if errors.Is(err, types.ErrAgentControl) {
return err
}

Expand Down
4 changes: 2 additions & 2 deletions internal/install/execution/terminal_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ func (r TerminalStatusReporter) printFleetLink(status *InstallStatus) {
statuses := r.getRecipesStatusesForInstallationSummary(status)

for _, s := range statuses {
isSuperAgentRecipe := s.Name == types.SuperAgentRecipeName || s.Name == types.LoggingSuperAgentRecipeName
isAgentControlRecipe := s.Name == types.AgentControlRecipeName || s.Name == types.LoggingAgentControlRecipeName

if s.Status == RecipeStatusTypes.INSTALLED && isSuperAgentRecipe {
if s.Status == RecipeStatusTypes.INSTALLED && isAgentControlRecipe {
linkToFleetRaw := "https://one.newrelic.com/nr1-core?filters=(domain = 'NR1' AND type = 'FLEET')"

linkToFleet := url.PathEscape(linkToFleetRaw)
Expand Down
6 changes: 3 additions & 3 deletions internal/install/execution/terminal_reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ func Test_ShouldGenerateLoggingLink(t *testing.T) {
Name: types.LoggingRecipeName,
Status: RecipeStatusTypes.INSTALLED,
}
loggingSuperAgentRecipeStatus := &RecipeStatus{
loggingAgentControlRecipeStatus := &RecipeStatus{
DisplayName: "Logs integration",
Name: types.LoggingSuperAgentRecipeName,
Name: types.LoggingAgentControlRecipeName,
Status: RecipeStatusTypes.INSTALLED,
}

status.Statuses = append(status.Statuses, loggingRecipeStatus)
status.Statuses = append(status.Statuses, loggingSuperAgentRecipeStatus)
status.Statuses = append(status.Statuses, loggingAgentControlRecipeStatus)

err := r.InstallComplete(status)
require.NoError(t, err)
Expand Down
24 changes: 12 additions & 12 deletions internal/install/recipe_installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,9 @@ func (i *RecipeInstall) install(ctx context.Context) error {
return err
}

if _, ok := availableRecipes.GetRecipeDetection(types.SuperAgentRecipeName); i.hostHasSuperAgentProcess() && !ok {
if _, ok := availableRecipes.GetRecipeDetection(types.AgentControlRecipeName); i.hostHasAgentControlProcess() && !ok {
availableRecipes = append(availableRecipes, &recipes.RecipeDetectionResult{
Recipe: &types.OpenInstallationRecipe{Name: types.SuperAgentRecipeName},
Recipe: &types.OpenInstallationRecipe{Name: types.AgentControlRecipeName},
Status: execution.RecipeStatusTypes.AVAILABLE,
DurationMs: 0,
})
Expand Down Expand Up @@ -392,13 +392,13 @@ func (i *RecipeInstall) reportRecipeRecommendations(availableRecipes recipes.Rec
}
}

// Skip reporting for the infra agent if super agent has been targeted.
// Skip reporting for the infra agent if agent control has been targeted.
// The logs-integration also reports a status for the infra agent
// and should be skipped as well.
func (i *RecipeInstall) shouldSkipReporting(name string) bool {
if name == "infrastructure-agent-installer" || name == "logs-integration" {
for _, v := range i.RecipeNames {
if v == "super-agent" || v == "logs-integration-super-agent" {
if v == "agent-control" || v == "logs-integration-agent-control" {
return true
}
}
Expand Down Expand Up @@ -441,11 +441,11 @@ func (i *RecipeInstall) isTargetInstallRecipe(recipeName string) bool {

func (i *RecipeInstall) checkSuper(bundler RecipeBundler) *recipes.Bundler {
bun, ok := bundler.(*recipes.Bundler)
if i.hostHasSuperAgentProcess() && ok {
if i.hostHasAgentControlProcess() && ok {
bun.HasSuperInstalled = true
log.Debugf("Super agent process found.")
log.Debugf("Agent Control process found.")
} else {
log.Debugf("Super agent process not found.")
log.Debugf("Agent Control process not found.")
}
log.Debugf("Preparing bundle")
return bun
Expand All @@ -463,9 +463,9 @@ func bundleRecipeProcessing(bundle *recipes.Bundle, bun *recipes.Bundler) {
}

// installAdditionalBundle installs additional bundles for the given recipes.
// It checks if the host has a super agent process running, and proceeds with the additional bundle.
// It checks if the host has a agent control process running, and proceeds with the additional bundle.
// If the list of recipes is provided, it creates a targeted bundle; otherwise, it creates a guided bundle.
// If the host has super agent installed infra agent and logs agent would be NULL
// If the host has agent control installed infra agent and logs agent would be NULL
// It then installs the additional bundle and reports any unsupported recipes.
func (i *RecipeInstall) installAdditionalBundle(bundler RecipeBundler, bundleInstaller RecipeBundleInstaller, repo *recipes.RecipeRepository) error {
var additionalBundle *recipes.Bundle
Expand All @@ -491,7 +491,7 @@ func (i *RecipeInstall) installAdditionalBundle(bundler RecipeBundler, bundleIns
if bundleInstaller.InstalledRecipesCount() == 0 {
for _, recipe := range i.RecipeNames {
if bun.HasSuperInstalled && bun.IsCore(recipe) {
return types.NewDetailError(types.EventTypes.OtherError, types.ErrSuperAgent.Error())
return types.NewDetailError(types.EventTypes.OtherError, types.ErrAgentControl.Error())
}
}

Expand Down Expand Up @@ -853,6 +853,6 @@ func (i *RecipeInstall) finishHandlingFailure(recipeName string) {
}
}

func (i *RecipeInstall) hostHasSuperAgentProcess() bool {
return i.processEvaluator.FindProcess(types.SuperAgentProcessName)
func (i *RecipeInstall) hostHasAgentControlProcess() bool {
return i.processEvaluator.FindProcess(types.AgentControlProcessName)
}
Loading

0 comments on commit c02a833

Please sign in to comment.