From c02a8336a4b4f2920bfe52cff2809e7c5ce6c928 Mon Sep 17 00:00:00 2001 From: Ruben Ruiz de Gauna Date: Mon, 16 Dec 2024 18:08:23 +0100 Subject: [PATCH] chore(agent-control): rename Super Agent to Agent Control --- internal/install/bundle_installer.go | 4 +- internal/install/bundle_installer_test.go | 10 +-- internal/install/command.go | 8 +- .../install/execution/terminal_reporter.go | 4 +- .../execution/terminal_reporter_test.go | 6 +- internal/install/recipe_installer.go | 24 +++--- internal/install/recipe_installer_test.go | 78 +++++++++---------- internal/install/recipes/bundler.go | 18 ++--- internal/install/recipes/bundler_test.go | 42 +++++----- internal/install/recipes/recipe_repository.go | 2 +- .../install/recipes/recipe_repository_test.go | 6 +- internal/install/types/errors.go | 2 +- internal/install/types/recipe.go | 14 ++-- 13 files changed, 109 insertions(+), 109 deletions(-) diff --git a/internal/install/bundle_installer.go b/internal/install/bundle_installer.go index 5a46113ae..4f2897fe0 100644 --- a/internal/install/bundle_installer.go +++ b/internal/install/bundle_installer.go @@ -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] { @@ -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] { diff --git a/internal/install/bundle_installer_test.go b/internal/install/bundle_installer_test.go index ef77e7ade..3a58f348c 100644 --- a/internal/install/bundle_installer_test.go +++ b/internal/install/bundle_installer_test.go @@ -51,9 +51,9 @@ 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) @@ -61,9 +61,9 @@ func TestInstallContinueOnErrorReturnsImmediatelyWhenSuperAgentIsInstalled(t *te 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) @@ -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) diff --git a/internal/install/command.go b/internal/install/command.go index a09e7855c..52d73c6b4 100644 --- a/internal/install/command.go +++ b/internal/install/command.go @@ -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 } //} @@ -76,7 +76,7 @@ var Command = &cobra.Command{ return e } - if errors.Is(err, types.ErrSuperAgent) { + if errors.Is(err, types.ErrAgentControl) { return err } diff --git a/internal/install/execution/terminal_reporter.go b/internal/install/execution/terminal_reporter.go index 11f263dda..6f8e889ce 100644 --- a/internal/install/execution/terminal_reporter.go +++ b/internal/install/execution/terminal_reporter.go @@ -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) diff --git a/internal/install/execution/terminal_reporter_test.go b/internal/install/execution/terminal_reporter_test.go index 96deea9e0..7359e7b9b 100644 --- a/internal/install/execution/terminal_reporter_test.go +++ b/internal/install/execution/terminal_reporter_test.go @@ -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) diff --git a/internal/install/recipe_installer.go b/internal/install/recipe_installer.go index dd351b4ec..150fc6e6b 100644 --- a/internal/install/recipe_installer.go +++ b/internal/install/recipe_installer.go @@ -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, }) @@ -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 } } @@ -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 @@ -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 @@ -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()) } } @@ -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) } diff --git a/internal/install/recipe_installer_test.go b/internal/install/recipe_installer_test.go index e8c227f5f..5560d0a12 100644 --- a/internal/install/recipe_installer_test.go +++ b/internal/install/recipe_installer_test.go @@ -93,23 +93,23 @@ func TestInstallWithInvalidDiscoveryResultReturnsError(t *testing.T) { assert.True(t, strings.Contains(actual.Error(), expected.Error())) } -// FIX: add a test for super agent installed on host -// super agent is present and OHI is trying to be installed -func TestInstallGuidedShouldSkipCoreInstallWhileSuperAgentIsInstalled(t *testing.T) { +// FIX: add a test for agent control installed on host +// agent control is present and OHI is trying to be installed +func TestInstallGuidedShouldSkipCoreInstallWhileAgentControlIsInstalled(t *testing.T) { r := &recipes.RecipeDetectionResult{ Recipe: recipes.NewRecipeBuilder().Name(types.InfraAgentRecipeName).Build(), Status: execution.RecipeStatusTypes.AVAILABLE, } - // super agent should be made available + // agent control should be made available r2 := &recipes.RecipeDetectionResult{ - Recipe: recipes.NewRecipeBuilder().Name(types.SuperAgentRecipeName).Build(), + Recipe: recipes.NewRecipeBuilder().Name(types.AgentControlRecipeName).Build(), Status: execution.RecipeStatusTypes.AVAILABLE, } statusReporter := execution.NewMockStatusReporter() recipeInstall := NewRecipeInstallBuilder(). WithRecipeDetectionResult(r).WithRecipeDetectionResult(r2). WithStatusReporter(statusReporter). - WithRunningProcess("super-agent-process", types.SuperAgentProcessName). + WithRunningProcess("agent-control-process", types.AgentControlProcessName). Build() err := recipeInstall.install(context.TODO()) @@ -247,7 +247,7 @@ func TestInstallGuidedShouldSkipSuper(t *testing.T) { Status: execution.RecipeStatusTypes.AVAILABLE, } r2 := &recipes.RecipeDetectionResult{ - Recipe: recipes.NewRecipeBuilder().Name(types.SuperAgentRecipeName).WithDiscoveryMode([]types.OpenInstallationDiscoveryMode{ + Recipe: recipes.NewRecipeBuilder().Name(types.AgentControlRecipeName).WithDiscoveryMode([]types.OpenInstallationDiscoveryMode{ types.OpenInstallationDiscoveryModeTypes.TARGETED, }).Build(), Status: execution.RecipeStatusTypes.NULL, @@ -359,11 +359,11 @@ func TestInstallTargetedShouldNotSkipOTEL(t *testing.T) { func TestInstallTargetedShouldNotSkipSuper(t *testing.T) { r := &recipes.RecipeDetectionResult{ - Recipe: recipes.NewRecipeBuilder().Name(types.SuperAgentRecipeName).Build(), + Recipe: recipes.NewRecipeBuilder().Name(types.AgentControlRecipeName).Build(), Status: execution.RecipeStatusTypes.AVAILABLE, } statusReporter := execution.NewMockStatusReporter() - recipeInstall := NewRecipeInstallBuilder().WithRecipeDetectionResult(r).WithTargetRecipeName(types.SuperAgentRecipeName).WithStatusReporter(statusReporter).Build() + recipeInstall := NewRecipeInstallBuilder().WithRecipeDetectionResult(r).WithTargetRecipeName(types.AgentControlRecipeName).WithStatusReporter(statusReporter).Build() recipeInstall.AssumeYes = true err := recipeInstall.Install() @@ -378,17 +378,17 @@ func TestInstallTargetedShouldNotSkipSuper(t *testing.T) { assert.Equal(t, 0, statusReporter.RecipeRecommendedCallCount, "Recommendation Count") assert.Equal(t, 0, statusReporter.RecipeSkippedCallCount, "Skipped Count") assert.Equal(t, 0, statusReporter.RecipeCanceledCallCount, "Cancelled Count") - assert.Equal(t, 1, statusReporter.ReportInstalled[r.Recipe.Name], "Super Agent Installed") + assert.Equal(t, 1, statusReporter.ReportInstalled[r.Recipe.Name], "Agent Control Installed") } func TestInstallTargetedShouldNotSkipSuperOnSuperInstalledHost(t *testing.T) { r := &recipes.RecipeDetectionResult{ - Recipe: recipes.NewRecipeBuilder().Name(types.SuperAgentRecipeName).Build(), + Recipe: recipes.NewRecipeBuilder().Name(types.AgentControlRecipeName).Build(), Status: execution.RecipeStatusTypes.AVAILABLE, } statusReporter := execution.NewMockStatusReporter() - recipeInstall := NewRecipeInstallBuilder().WithRecipeDetectionResult(r).WithTargetRecipeName(types.SuperAgentRecipeName).WithStatusReporter(statusReporter). - WithRunningProcess(types.SuperAgentProcessName, types.SuperAgentProcessName).Build() + recipeInstall := NewRecipeInstallBuilder().WithRecipeDetectionResult(r).WithTargetRecipeName(types.AgentControlRecipeName).WithStatusReporter(statusReporter). + WithRunningProcess(types.AgentControlProcessName, types.AgentControlProcessName).Build() recipeInstall.AssumeYes = true err := recipeInstall.Install() @@ -403,12 +403,12 @@ func TestInstallTargetedShouldNotSkipSuperOnSuperInstalledHost(t *testing.T) { assert.Equal(t, 0, statusReporter.RecipeRecommendedCallCount, "Recommendation Count") assert.Equal(t, 0, statusReporter.RecipeSkippedCallCount, "Skipped Count") assert.Equal(t, 0, statusReporter.RecipeCanceledCallCount, "Cancelled Count") - assert.Equal(t, 1, statusReporter.ReportInstalled[r.Recipe.Name], "Super Agent Installed") + assert.Equal(t, 1, statusReporter.ReportInstalled[r.Recipe.Name], "Agent Control Installed") } func TestInstallTargetedShouldNotSkipInfraOnSuperInstalledHost(t *testing.T) { r := &recipes.RecipeDetectionResult{ - Recipe: recipes.NewRecipeBuilder().Name(types.SuperAgentRecipeName).Build(), + Recipe: recipes.NewRecipeBuilder().Name(types.AgentControlRecipeName).Build(), Status: execution.RecipeStatusTypes.AVAILABLE, } r1 := &recipes.RecipeDetectionResult{ @@ -417,12 +417,12 @@ func TestInstallTargetedShouldNotSkipInfraOnSuperInstalledHost(t *testing.T) { } statusReporter := execution.NewMockStatusReporter() recipeInstall := NewRecipeInstallBuilder().WithRecipeDetectionResult(r).WithTargetRecipeName(types.InfraAgentRecipeName).WithStatusReporter(statusReporter). - WithRunningProcess(types.SuperAgentProcessName, types.SuperAgentProcessName).WithRecipeDetectionResult(r1).Build() + WithRunningProcess(types.AgentControlProcessName, types.AgentControlProcessName).WithRecipeDetectionResult(r1).Build() recipeInstall.AssumeYes = true err := recipeInstall.Install() - assert.Equal(t, "super Agent is installed, preventing the installation of this recipe", err.Error()) + assert.Equal(t, "agent control is installed, preventing the installation of this recipe", err.Error()) assert.Equal(t, 2, statusReporter.RecipeDetectedCallCount, "Detection Count") assert.Equal(t, 2, statusReporter.RecipeAvailableCallCount, "Available Count") assert.Equal(t, 0, statusReporter.RecipeInstallingCallCount, "Installing Count") @@ -433,7 +433,7 @@ func TestInstallTargetedShouldNotSkipInfraOnSuperInstalledHost(t *testing.T) { assert.Equal(t, 0, statusReporter.RecipeRecommendedCallCount, "Recommendation Count") assert.Equal(t, 0, statusReporter.RecipeSkippedCallCount, "Skipped Count") assert.Equal(t, 0, statusReporter.RecipeCanceledCallCount, "Cancelled Count") - assert.Equal(t, 0, statusReporter.ReportInstalled[r.Recipe.Name], "Super Agent Installed") + assert.Equal(t, 0, statusReporter.ReportInstalled[r.Recipe.Name], "Agent Control Installed") assert.Equal(t, 0, statusReporter.ReportInstalled[r1.Recipe.Name], "infra Agent Installed") } @@ -462,13 +462,13 @@ func TestInstallTargetedInstallShouldInstallCoreIfCoreWasSkipped(t *testing.T) { assert.Equal(t, 1, statusReporter.ReportInstalled[r.Recipe.Name], "Recipe1 Installed") } -func TestInstallTargetedInstallShouldNotInstallCoreIfCoreWasSkippedWhileSuperAgentIsInstalled(t *testing.T) { +func TestInstallTargetedInstallShouldNotInstallCoreIfCoreWasSkippedWhileAgentControlIsInstalled(t *testing.T) { r := &recipes.RecipeDetectionResult{ Recipe: recipes.NewRecipeBuilder().Name(types.InfraAgentRecipeName).Build(), Status: execution.RecipeStatusTypes.AVAILABLE, } r2 := &recipes.RecipeDetectionResult{ - Recipe: recipes.NewRecipeBuilder().Name(types.SuperAgentRecipeName).Build(), + Recipe: recipes.NewRecipeBuilder().Name(types.AgentControlRecipeName).Build(), Status: execution.RecipeStatusTypes.AVAILABLE, } statusReporter := execution.NewMockStatusReporter() @@ -476,12 +476,12 @@ func TestInstallTargetedInstallShouldNotInstallCoreIfCoreWasSkippedWhileSuperAge WithRecipeDetectionResult(r).WithRecipeDetectionResult(r2). withShouldInstallCore(func() bool { return false }). WithTargetRecipeName(types.InfraAgentRecipeName).WithStatusReporter(statusReporter). - WithRunningProcess("super-agent-process", types.SuperAgentProcessName).Build() + WithRunningProcess("agent-control-process", types.AgentControlProcessName).Build() recipeInstall.AssumeYes = true err := recipeInstall.Install() - assert.Equal(t, "super Agent is installed, preventing the installation of this recipe", err.Error()) + assert.Equal(t, "agent control is installed, preventing the installation of this recipe", err.Error()) assert.Equal(t, 2, statusReporter.RecipeDetectedCallCount, "Detection Count") assert.Equal(t, 1, statusReporter.RecipeAvailableCallCount, "Available Count") assert.Equal(t, 0, statusReporter.RecipeInstallingCallCount, "Installing Count") @@ -564,15 +564,15 @@ func TestInstallGuidededInstallAdditionalShouldInstall(t *testing.T) { assert.Equal(t, 1, statusReporter.ReportInstalled[r.Recipe.Name], "Recipe Installed") } -func TestInstallSuperInstallAdditionalShouldInstallOnSuperAgentInstalled(t *testing.T) { +func TestInstallSuperInstallAdditionalShouldInstallOnAgentControlInstalled(t *testing.T) { r := &recipes.RecipeDetectionResult{ - Recipe: recipes.NewRecipeBuilder().Name(types.SuperAgentRecipeName).Build(), + Recipe: recipes.NewRecipeBuilder().Name(types.AgentControlRecipeName).Build(), Status: execution.RecipeStatusTypes.AVAILABLE, } statusReporter := execution.NewMockStatusReporter() recipeInstall := NewRecipeInstallBuilder().WithStatusReporter(statusReporter). - WithTargetRecipeName(types.SuperAgentRecipeName). - WithRunningProcess("super-agent-process", types.SuperAgentProcessName).Build() + WithTargetRecipeName(types.AgentControlRecipeName). + WithRunningProcess("agent-control-process", types.AgentControlProcessName).Build() recipeInstall.AssumeYes = true err := recipeInstall.install(context.TODO()) @@ -590,7 +590,7 @@ func TestInstallSuperInstallAdditionalShouldInstallOnSuperAgentInstalled(t *test assert.Equal(t, 1, statusReporter.ReportInstalled[r.Recipe.Name], "Recipe Installed") } -func TestInstallOHIAdditionalShouldInstallOnSuperAgentInstalled(t *testing.T) { +func TestInstallOHIAdditionalShouldInstallOnAgentControlInstalled(t *testing.T) { r2 := &recipes.RecipeDetectionResult{ Recipe: recipes.NewRecipeBuilder().Name("recipe1").Build(), Status: execution.RecipeStatusTypes.AVAILABLE, @@ -598,7 +598,7 @@ func TestInstallOHIAdditionalShouldInstallOnSuperAgentInstalled(t *testing.T) { statusReporter := execution.NewMockStatusReporter() recipeInstall := NewRecipeInstallBuilder().WithStatusReporter(statusReporter). WithTargetRecipeName("recipe1").WithRecipeDetectionResult(r2). - WithRunningProcess("super-agent-process", types.SuperAgentProcessName).Build() + WithRunningProcess("agent-control-process", types.AgentControlProcessName).Build() recipeInstall.AssumeYes = true err := recipeInstall.install(context.TODO()) @@ -618,32 +618,32 @@ func TestInstallOHIAdditionalShouldInstallOnSuperAgentInstalled(t *testing.T) { func TestShouldSkipReporting(t *testing.T) { // Target a recipe - recipeInstall := NewRecipeInstallBuilder().WithTargetRecipeName("super-agent").Build() + recipeInstall := NewRecipeInstallBuilder().WithTargetRecipeName("agent-control").Build() // Should this recipe be skipped as a result? b := recipeInstall.shouldSkipReporting("infrastructure-agent-installer") - assert.Equal(t, true, b, "Super Agent with Infrastructure Agent targeted") + assert.Equal(t, true, b, "Agent Control with Infrastructure Agent targeted") - recipeInstall = NewRecipeInstallBuilder().WithTargetRecipeName("super-agent").Build() + recipeInstall = NewRecipeInstallBuilder().WithTargetRecipeName("agent-control").Build() b = recipeInstall.shouldSkipReporting("logs-integration") - assert.Equal(t, true, b, "Super Agent Provided") + assert.Equal(t, true, b, "Agent Control Provided") - recipeInstall = NewRecipeInstallBuilder().WithTargetRecipeName("logs-integration-super-agent").Build() + recipeInstall = NewRecipeInstallBuilder().WithTargetRecipeName("logs-integration-agent-control").Build() b = recipeInstall.shouldSkipReporting("infrastructure-agent-installer") - assert.Equal(t, true, b, "Super Agent Provided") + assert.Equal(t, true, b, "Agent Control Provided") - recipeInstall = NewRecipeInstallBuilder().WithTargetRecipeName("logs-integration-super-agent").Build() + recipeInstall = NewRecipeInstallBuilder().WithTargetRecipeName("logs-integration-agent-control").Build() b = recipeInstall.shouldSkipReporting("logs-integration") - assert.Equal(t, true, b, "Super Agent Provided") + assert.Equal(t, true, b, "Agent Control Provided") - // Super Agent / Logs not included -> should return false + // Agent Control / Logs not included -> should return false recipeInstall = NewRecipeInstallBuilder().Build() b = recipeInstall.shouldSkipReporting("infrastructure-agent-installer") - assert.Equal(t, false, b, "Super Agent Provided") + assert.Equal(t, false, b, "Agent Control Provided") recipeInstall = NewRecipeInstallBuilder().Build() b = recipeInstall.shouldSkipReporting("logs-integration") - assert.Equal(t, false, b, "Super Agent Provided") + assert.Equal(t, false, b, "Agent Control Provided") } func TestPromptIfNotLatestCliVersionDoesNotLogMessagesOrErrorWhenVersionsMatch(t *testing.T) { diff --git a/internal/install/recipes/bundler.go b/internal/install/recipes/bundler.go index d9fdcefda..f223b1fc4 100644 --- a/internal/install/recipes/bundler.go +++ b/internal/install/recipes/bundler.go @@ -42,7 +42,7 @@ func (b *Bundler) CreateAdditionalGuidedBundle() *Bundle { for _, d := range b.AvailableRecipes { if !coreRecipeMap[d.Recipe.Name] { - if !strings.EqualFold(d.Recipe.Name, types.SuperAgentRecipeName) { + if !strings.EqualFold(d.Recipe.Name, types.AgentControlRecipeName) { recipes = append(recipes, d.Recipe.Name) } } @@ -85,16 +85,16 @@ func (b *Bundler) createBundle(recipes []string, bType BundleType) *Bundle { bundleRecipe = b.getBundleRecipeWithDependencies(d.Recipe) if bundleRecipe != nil { - isSuperAgentTargetedInput := utils.StringInSlice(types.SuperAgentRecipeName, recipes) - if dep, found := findRecipeDependency(bundleRecipe, types.SuperAgentRecipeName); !isSuperAgentTargetedInput && found { + isAgentControlTargetedInput := utils.StringInSlice(types.AgentControlRecipeName, recipes) + if dep, found := findRecipeDependency(bundleRecipe, types.AgentControlRecipeName); !isAgentControlTargetedInput && found { log.Debugf("updating the dependency status for %s", dep) dep.AddDetectionStatus(execution.RecipeStatusTypes.INSTALLED, 0) } - if !isSuperAgentTargetedInput && b.HasSuperInstalled { - log.Debugf("Super agent found, skipping") + if !isAgentControlTargetedInput && b.HasSuperInstalled { + log.Debugf("Agent Control found, skipping") superRecipe := &BundleRecipe{ Recipe: &types.OpenInstallationRecipe{ - Name: types.SuperAgentRecipeName, + Name: types.AgentControlRecipeName, }, } superRecipe.AddDetectionStatus(execution.RecipeStatusTypes.INSTALLED, 0) @@ -174,7 +174,7 @@ func detectDependencies(deps []string) (string, bool) { return "", false } - const dualRecipeDependencyRegex = `^.+\|\|.+$` // e.g.: infrastructure-agent-installer || super-agent + const dualRecipeDependencyRegex = `^.+\|\|.+$` // e.g.: infrastructure-agent-installer || agent-control r, _ := regexp.Compile(dualRecipeDependencyRegex) // Not yet considering the unlikely case of dealing with more than one recipe dependency line coming in the 'recipe-a || recipe-b' form @@ -205,13 +205,13 @@ func (b *Bundler) updateDependency(dualDep string, recipes []string) []string { } for _, dep := range splitDeps { dep = strings.TrimSpace(dep) - if dep == types.SuperAgentRecipeName { + if dep == types.AgentControlRecipeName { hasSuperDep = true break } } if hasSuperDep && b.HasSuperInstalled { - return []string{types.SuperAgentRecipeName} + return []string{types.AgentControlRecipeName} } for _, dep := range splitDeps { diff --git a/internal/install/recipes/bundler_test.go b/internal/install/recipes/bundler_test.go index d3e1f6e54..10a03861f 100644 --- a/internal/install/recipes/bundler_test.go +++ b/internal/install/recipes/bundler_test.go @@ -47,17 +47,17 @@ func TestCreateAdditionalTargetedBundleShouldNotSkipCoreRecipes(t *testing.T) { require.NotNil(t, findRecipeByName(addBundle, "mysql")) } -// Super agent is installed but not a dependency +// Agent Control is installed but not a dependency func TestCreateAdditionalTargetedBundleShouldNotSkipCoreRecipesWithSuper(t *testing.T) { infraRecipe := NewRecipeBuilder().Name(types.InfraAgentRecipeName).Build() loggingRecipe := NewRecipeBuilder().Name(types.LoggingRecipeName).Build() goldenRecipe := NewRecipeBuilder().Name(types.GoldenRecipeName).Build() mysqlRecipe := NewRecipeBuilder().Name("mysql").Build() bundler := createTestBundler() - // Super agent is installed but not a dependency - superRecipe := NewRecipeBuilder().Name(types.SuperAgentRecipeName).Build() + // Agent Control is installed but not a dependency + superRecipe := NewRecipeBuilder().Name(types.AgentControlRecipeName).Build() bundler.HasSuperInstalled = true - withAvailableRecipe(bundler, types.SuperAgentRecipeName, execution.RecipeStatusTypes.AVAILABLE, superRecipe) + withAvailableRecipe(bundler, types.AgentControlRecipeName, execution.RecipeStatusTypes.AVAILABLE, superRecipe) withAvailableRecipe(bundler, types.InfraAgentRecipeName, execution.RecipeStatusTypes.AVAILABLE, infraRecipe) withAvailableRecipe(bundler, types.LoggingRecipeName, execution.RecipeStatusTypes.AVAILABLE, loggingRecipe) @@ -79,23 +79,23 @@ func TestCreateAdditionalTargetedBundleShouldNotSkipCoreRecipesWithSuper(t *test require.NotNil(t, findRecipeByName(addBundle, "mysql")) } -// Super agent is installed but is a dependency +// Agent Control is installed but is a dependency func TestCreateAdditionalTargetedBundleShouldNotSkipCoreRecipesOnHasSuperDependency(t *testing.T) { infraRecipe := NewRecipeBuilder().Name(types.InfraAgentRecipeName).Build() loggingRecipe := NewRecipeBuilder().Name(types.LoggingRecipeName).Build() goldenRecipe := NewRecipeBuilder().Name(types.GoldenRecipeName).Build() - superRecipe := NewRecipeBuilder().Name(types.SuperAgentRecipeName).Build() + superRecipe := NewRecipeBuilder().Name(types.AgentControlRecipeName).Build() mysqlRecipe := NewRecipeBuilder().Name("mysql").Build() bundler := createTestBundler() bundler.HasSuperInstalled = true - mysqlRecipe.Dependencies = []string{types.SuperAgentRecipeName} + mysqlRecipe.Dependencies = []string{types.AgentControlRecipeName} withAvailableRecipe(bundler, types.InfraAgentRecipeName, execution.RecipeStatusTypes.AVAILABLE, infraRecipe) withAvailableRecipe(bundler, types.LoggingRecipeName, execution.RecipeStatusTypes.AVAILABLE, loggingRecipe) withAvailableRecipe(bundler, types.GoldenRecipeName, execution.RecipeStatusTypes.AVAILABLE, goldenRecipe) withAvailableRecipe(bundler, "mysql", execution.RecipeStatusTypes.AVAILABLE, mysqlRecipe) - // super agent should be made available - withAvailableRecipe(bundler, types.SuperAgentRecipeName, execution.RecipeStatusTypes.AVAILABLE, superRecipe) + // agent control should be made available + withAvailableRecipe(bundler, types.AgentControlRecipeName, execution.RecipeStatusTypes.AVAILABLE, superRecipe) recipeNames := []string{ "mysql", @@ -104,16 +104,16 @@ func TestCreateAdditionalTargetedBundleShouldNotSkipCoreRecipesOnHasSuperDepende types.GoldenRecipeName, } addBundle := bundler.CreateAdditionalTargetedBundle(recipeNames) - r := findDependencyByName(addBundle.GetBundleRecipe("mysql"), types.SuperAgentRecipeName) + r := findDependencyByName(addBundle.GetBundleRecipe("mysql"), types.AgentControlRecipeName) require.Equal(t, 5, len(addBundle.BundleRecipes)) require.NotNil(t, findRecipeByName(addBundle, types.InfraAgentRecipeName)) require.NotNil(t, findRecipeByName(addBundle, types.LoggingRecipeName)) require.NotNil(t, findRecipeByName(addBundle, types.GoldenRecipeName)) require.NotNil(t, findRecipeByName(addBundle, "mysql")) - require.NotNil(t, findRecipeByName(addBundle, types.SuperAgentRecipeName)) - require.Equal(t, r.Name, types.SuperAgentRecipeName) - // super agent should be installed + require.NotNil(t, findRecipeByName(addBundle, types.AgentControlRecipeName)) + require.Equal(t, r.Name, types.AgentControlRecipeName) + // agent control should be installed mysqlBundle := findRecipeByName(addBundle, "mysql") require.Equal(t, 1, len(mysqlBundle.Dependencies)) require.True(t, mysqlBundle.Dependencies[0].LastStatus(execution.RecipeStatusTypes.INSTALLED)) @@ -392,7 +392,7 @@ func TestUpdateDependencyReturnsFirstDualDependencyThatIsInTargetedRecipes(t *te } } -func TestUpdateDependencyReturnsSuperAgentDualDependencyThatIsInTargetedRecipes(t *testing.T) { +func TestUpdateDependencyReturnsAgentControlDualDependencyThatIsInTargetedRecipes(t *testing.T) { type test struct { dualDep string recipes []string @@ -401,13 +401,13 @@ func TestUpdateDependencyReturnsSuperAgentDualDependencyThatIsInTargetedRecipes( } tests := []test{ - {dualDep: "infra || super-agent", recipes: []string{"super-agent", "mysql", "logging"}, want: []string{"super-agent"}, b: Bundler{HasSuperInstalled: false}}, - {dualDep: "super-agent || infra", recipes: []string{"super-agent", "mysql", "logging"}, want: []string{"super-agent"}, b: Bundler{HasSuperInstalled: false}}, - {dualDep: "super-agent || infra", recipes: []string{"mysql", "infra", "logging"}, want: []string{"super-agent"}, b: Bundler{HasSuperInstalled: true}}, - {dualDep: "super-agent || infra", recipes: []string{"mysql", "infra", "super-agent"}, want: []string{"super-agent"}, b: Bundler{HasSuperInstalled: true}}, - {dualDep: "infra || super-agent", recipes: []string{"mysql", "infra", "super-agent"}, want: []string{"super-agent"}, b: Bundler{HasSuperInstalled: true}}, - {dualDep: "infra || super-agent", recipes: []string{"infra", "mysql", "logging"}, want: []string{"super-agent"}, b: Bundler{HasSuperInstalled: true}}, - {dualDep: "infra || super-agent", recipes: []string{"infra", "mysql", "logging"}, want: []string{"infra"}, b: Bundler{HasSuperInstalled: false}}, + {dualDep: "infra || agent-control", recipes: []string{"agent-control", "mysql", "logging"}, want: []string{"agent-control"}, b: Bundler{HasSuperInstalled: false}}, + {dualDep: "agent-control || infra", recipes: []string{"agent-control", "mysql", "logging"}, want: []string{"agent-control"}, b: Bundler{HasSuperInstalled: false}}, + {dualDep: "agent-control || infra", recipes: []string{"mysql", "infra", "logging"}, want: []string{"agent-control"}, b: Bundler{HasSuperInstalled: true}}, + {dualDep: "agent-control || infra", recipes: []string{"mysql", "infra", "agent-control"}, want: []string{"agent-control"}, b: Bundler{HasSuperInstalled: true}}, + {dualDep: "infra || agent-control", recipes: []string{"mysql", "infra", "agent-control"}, want: []string{"agent-control"}, b: Bundler{HasSuperInstalled: true}}, + {dualDep: "infra || agent-control", recipes: []string{"infra", "mysql", "logging"}, want: []string{"agent-control"}, b: Bundler{HasSuperInstalled: true}}, + {dualDep: "infra || agent-control", recipes: []string{"infra", "mysql", "logging"}, want: []string{"infra"}, b: Bundler{HasSuperInstalled: false}}, } for _, tc := range tests { diff --git a/internal/install/recipes/recipe_repository.go b/internal/install/recipes/recipe_repository.go index a6b7e8c8c..acde56f94 100644 --- a/internal/install/recipes/recipe_repository.go +++ b/internal/install/recipes/recipe_repository.go @@ -100,7 +100,7 @@ func (rf *RecipeRepository) FindRecipes(excludingRecipes []*types.OpenInstallati // Enriching recipe func (rf *RecipeRepository) enrichLogRecipe() { for _, recipe := range rf.filteredRecipes { - if recipe.Name == types.LoggingRecipeName || recipe.Name == types.LoggingSuperAgentRecipeName { + if recipe.Name == types.LoggingRecipeName || recipe.Name == types.LoggingAgentControlRecipeName { logMatches := rf.logMatchFinder.GetPaths(utils.SignalCtx, rf.filteredRecipes) var discoveredLogFilesString string diff --git a/internal/install/recipes/recipe_repository_test.go b/internal/install/recipes/recipe_repository_test.go index b6ddce2f4..07db5a411 100644 --- a/internal/install/recipes/recipe_repository_test.go +++ b/internal/install/recipes/recipe_repository_test.go @@ -186,12 +186,12 @@ func TestRecipeRepository_ShouldEnrichLogRecipe(t *testing.T) { require.Equal(t, exist, true) } -func TestRecipeRepository_ShouldEnrichSuperAgentLogRecipe(t *testing.T) { +func TestRecipeRepository_ShouldEnrichAgentControlLogRecipe(t *testing.T) { Setup() - givenCachedRecipeOs("log1", types.LoggingSuperAgentRecipeName, types.OpenInstallationOperatingSystemTypes.LINUX) + givenCachedRecipeOs("log1", types.LoggingAgentControlRecipeName, types.OpenInstallationOperatingSystemTypes.LINUX) discoveryManifest.OS = "linux" - repository.FindRecipeByName(types.LoggingSuperAgentRecipeName) + repository.FindRecipeByName(types.LoggingAgentControlRecipeName) _, exist := types.RecipeVariables["NR_DISCOVERED_LOG_FILES"] require.Equal(t, exist, true) diff --git a/internal/install/types/errors.go b/internal/install/types/errors.go index 69170b2d4..44944a10f 100644 --- a/internal/install/types/errors.go +++ b/internal/install/types/errors.go @@ -16,7 +16,7 @@ var ( ErrDiscovery = errors.New("failed to detect your system's hostname. Please contact New Relic support") ErrPostEvent = errors.New("there was a failure posting data to New Relic. Please try again later or contact New Relic support. For real-time platform status info visit https://status.newrelic.com/") ErrLicenseKey = errors.New("the configured license key is invalid for the configured account. Please set a valid license key with the `newrelic profile` command. For more details visit https://docs.newrelic.com/docs/apis/intro-apis/new-relic-api-keys/#ingest-license-key") - ErrSuperAgent = errors.New("super Agent is installed, preventing the installation of this recipe") + ErrAgentControl = errors.New("agent control is installed, preventing the installation of this recipe") ) type EventType string diff --git a/internal/install/types/recipe.go b/internal/install/types/recipe.go index 7d5c3f639..abb01ecb2 100644 --- a/internal/install/types/recipe.go +++ b/internal/install/types/recipe.go @@ -9,13 +9,13 @@ import ( ) const ( - InfraAgentRecipeName = "infrastructure-agent-installer" - LoggingRecipeName = "logs-integration" - LoggingSuperAgentRecipeName = "logs-integration-super-agent" - GoldenRecipeName = "alerts-golden-signal" - SuperAgentRecipeName = "super-agent" - SuperAgentProcessName = "newrelic-super-agent" - InfraAgentProcessName = "newrelic-infra" + InfraAgentRecipeName = "infrastructure-agent-installer" + LoggingRecipeName = "logs-integration" + LoggingAgentControlRecipeName = "logs-integration-agent-control" + GoldenRecipeName = "alerts-golden-signal" + AgentControlRecipeName = "agent-control" + AgentControlProcessName = "newrelic-agent-control" + InfraAgentProcessName = "newrelic-infra" ) var RecipeVariables = map[string]string{}