Skip to content

Commit

Permalink
chore(super-agent): New uncaught error for no installations
Browse files Browse the repository at this point in the history
  • Loading branch information
NSSPKrishna committed May 9, 2024
1 parent a595677 commit f2328ff
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions internal/install/recipe_installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,13 @@ func (i *RecipeInstall) isTargetInstallRecipe(recipeName string) bool {
// If the host has super agent installed infra agent and logs agent would be UNSUPPORTED
// 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
var (
additionalBundle *recipes.Bundle
bun *recipes.Bundler
ok bool
)
if i.hostHasSuperAgentProcess() {
if bun, ok := bundler.(*recipes.Bundler); ok {
if bun, ok = bundler.(*recipes.Bundler); ok {
bun.HasSuperInstalled = true
log.Debugf("Super agent process found. Proceeding with additional bundle.")
}
Expand All @@ -426,7 +430,7 @@ func (i *RecipeInstall) installAdditionalBundle(bundler RecipeBundler, bundleIns
log.Debugf("bundling addtional bundle")

Check failure on line 430 in internal/install/recipe_installer.go

View workflow job for this annotation

GitHub Actions / lint

"addtional" is a misspelling of "additional"

Check failure on line 430 in internal/install/recipe_installer.go

View workflow job for this annotation

GitHub Actions / lint

`addtional` is a misspelling of `additional` (misspell)

Check failure on line 430 in internal/install/recipe_installer.go

View workflow job for this annotation

GitHub Actions / lint

"addtional" is a misspelling of "additional"

Check failure on line 430 in internal/install/recipe_installer.go

View workflow job for this annotation

GitHub Actions / lint

`addtional` is a misspelling of `additional` (misspell)
log.Debugf("recipes in list %d", len(i.RecipeNames))
additionalBundle = bundler.CreateAdditionalTargetedBundle(i.RecipeNames)
if bundler.(*recipes.Bundler).HasSuperInstalled {
if bun.HasSuperInstalled {
for _, coreRecipe := range bundler.(*recipes.Bundler).GetCoreRecipeNames() {
if i, ok := additionalBundle.ContainsName(coreRecipe); ok {
additionalBundle.BundleRecipes[i].AddDetectionStatus(execution.RecipeStatusTypes.UNSUPPORTED, 0)
Expand All @@ -445,6 +449,11 @@ func (i *RecipeInstall) installAdditionalBundle(bundler RecipeBundler, bundleIns
bundleInstaller.InstallContinueOnError(additionalBundle, i.AssumeYes)

if bundleInstaller.InstalledRecipesCount() == 0 {
if bun.HasSuperInstalled {
return &types.UncaughtError{
Err: fmt.Errorf("super Agent is installed, preventing the installation of this recipe"),
}
}
return &types.UncaughtError{
Err: fmt.Errorf("no recipes were installed"),
}
Expand Down
2 changes: 1 addition & 1 deletion internal/install/recipe_installer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ func TestInstallTargetedInstallShouldInstallCoreIfCoreWasSkippedWhileSuperAgentI

err := recipeInstall.Install()

assert.Equal(t, "no recipes were installed", err.Error())
assert.Equal(t, "super Agent is installed, preventing the installation of this recipe", err.Error())
assert.Equal(t, 1, statusReporter.RecipeDetectedCallCount, "Detection Count")
assert.Equal(t, 1, statusReporter.RecipeAvailableCallCount, "Available Count")
assert.Equal(t, 0, statusReporter.RecipeInstallingCallCount, "Installing Count")
Expand Down

0 comments on commit f2328ff

Please sign in to comment.