Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add profile flag to commands to allow running profiles at the same time #1368

Merged
merged 4 commits into from
Jul 26, 2023

Conversation

mrodm
Copy link
Contributor

@mrodm mrodm commented Jul 25, 2023

Based on #1230

This allows us to use the profile information to be able to start different profiles at the same time. Profile information is used to set a different name for the Docker Compose Project.

This PR also adds profile flag to these commands:

  • benchmark
  • service

How to test

  1. Build elastic-package from this branch
  2. Start different Elastic stacks in different profiles, they should be using different container names (Docker Compose projects)
# New profile parameters available in benchmark and service commands
elastic-package benchmark -h
elastic-package service -h

elastic-package stack up -v --version 8.8.2
# this should show this output for the containers and network
# ✔ Network elastic-package-stack_default                        Created                                                                                                                                       0.1s 
# ✔ Container elastic-package-stack-elasticsearch-1              Healthy                                                                                                                                      18.0s 
# ✔ Container elastic-package-stack-package-registry-1           Healthy                                                                                                                                       6.5s 
# ✔ Container elastic-package-stack-package-registry_is_ready-1  Started                                                                                                                                       6.7s 
# ✔ Container elastic-package-stack-elasticsearch_is_ready-1     Started                                                                                                                                      17.3s 
# ✔ Container elastic-package-stack-kibana-1                     Healthy                                                                                                                                      39.4s 
# ✔ Container elastic-package-stack-kibana_is_ready-1            Started                                                                                                                                      40.1s 
# ✔ Container elastic-package-stack-fleet-server-1               Healthy                                                                                                                                      65.7s 
# ✔ Container elastic-package-stack-elastic-agent-1              Healthy                                                                                                                                      76.4s 
# ✔ Container elastic-package-stack-fleet-server_is_ready-1      Started                                                                                                                                      65.9s 
# ✔ Container elastic-package-stack-elastic-agent_is_ready-1     Started                                                                                                                                      76.6s
elastic-package stack status
elastic-package stack down

# Create a new profile
elastic-package profiles create --from default other
elastic-package profiles use other

# Start a new elastic stack in the new profile
elastic-package stack up -v -d --version 8.8.1
# this should show this output for the containers and network 
# ✔ Network elastic-package-stack-other_default                        Created                                                                                                                                 0.1s 
# ✔ Container elastic-package-stack-other-elasticsearch-1              Healthy                                                                                                                                17.3s 
# ✔ Container elastic-package-stack-other-package-registry-1           Healthy                                                                                                                                 5.9s 
# ✔ Container elastic-package-stack-other-elasticsearch_is_ready-1     Started                                                                                                                                16.7s 
# ✔ Container elastic-package-stack-other-kibana-1                     Healthy                                                                                                                                38.2s 
# ✔ Container elastic-package-stack-other-package-registry_is_ready-1  Started                                                                                                                                 6.5s 
# ✔ Container elastic-package-stack-other-kibana_is_ready-1            Started                                                                                                                                39.3s 
# ✔ Container elastic-package-stack-other-fleet-server-1               Healthy                                                                                                                                65.3s 
# ✔ Container elastic-package-stack-other-fleet-server_is_ready-1      Started                                                                                                                                65.8s 
# ✔ Container elastic-package-stack-other-elastic-agent-1              Healthy                                                                                                                                71.3s 
# ✔ Container elastic-package-stack-other-elastic-agent_is_ready-1     Started                                                                                                                                71.5s 
elastic-package stack status
elastic-package stack down

@mrodm mrodm self-assigned this Jul 25, 2023
Comment on lines +25 to +27
if profile.ProfileName == "default" {
return baseComposeProjectName
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this condition is added, the resulting container names would be the same as previously keeping backwards compatibility.

@mrodm mrodm requested a review from a team July 25, 2023 09:54
@mrodm
Copy link
Contributor Author

mrodm commented Jul 25, 2023

GCP test package is failing, investigating it here #1366

@mrodm mrodm marked this pull request as ready for review July 25, 2023 11:22
@mrodm
Copy link
Contributor Author

mrodm commented Jul 25, 2023

/test

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

cc @mrodm

@mrodm mrodm merged commit d334792 into elastic:main Jul 26, 2023
@mrodm mrodm deleted the add_profile_to_commands branch July 26, 2023 08:29
@@ -248,6 +251,11 @@ func systemCommandAction(cmd *cobra.Command, args []string) error {
return fmt.Errorf("locating package root failed: %w", err)
}

profile, err := cobraext.GetProfileFlag(cmd)
if err != nil {
return nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have seen this now while updating #1230, shouldn't this be return err?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right, it should return the error.
Thanks for the heads up!

Opened a PR for this: #1370

@@ -58,8 +60,14 @@ func upCommandAction(cmd *cobra.Command, args []string) error {

variantFlag, _ := cmd.Flags().GetString(cobraext.VariantFlagName)

profile, err := cobraext.GetProfileFlag(cmd)
if err != nil {
return nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants