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

Automatically add and remove dedicated masters. #814

Merged
merged 19 commits into from
May 21, 2024

Conversation

gigerdo
Copy link
Member

@gigerdo gigerdo commented Apr 24, 2024

Description

If the terraform config defines no master, the provider will add/remove it as needed:

  • Added if the number of nodes is >= the dedicated master threshold
  • Removed if the number of nodes is < the dedicated master threshold
  • The master tier can still be explicitly set (For example to change the size of the dedicated master tier)

Regarding the implementation:

  • Uses a ModifyPlan modifier to first calculate the number of nodes, then adds or removes the master tier
    • The main advantage of this is that the plan before applying already shows that a master is added/removed
  • It is necessary to load the template to have some info about default sizes etc.

Related Issues

#635
(Most of the problems described in that issue have already been solved, this PR just adds automatically adding/removing master tier)

Motivation and Context

How Has This Been Tested?

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (improves code quality but has no user-facing effect)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation

Readiness Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

@gigerdo gigerdo force-pushed the automatic-dedicated-masters branch 2 times, most recently from 93b0677 to f8f7fb2 Compare April 26, 2024 12:11
If no master tier is configured, it is automatically added/removed:
- Added if the number of nodes is >= the dedicated master threshold
- Removed if the number of nodes is < the dedicated master threshold

If the TF config already contains a master tier, the plan-modifier is skipped.
@gigerdo gigerdo force-pushed the automatic-dedicated-masters branch from ed50d36 to 10861ec Compare April 29, 2024 15:55
@gigerdo gigerdo force-pushed the automatic-dedicated-masters branch from d4ad4cc to bb68f78 Compare April 30, 2024 10:14
@gigerdo gigerdo marked this pull request as ready for review April 30, 2024 15:00
@gigerdo gigerdo requested a review from a team as a code owner April 30, 2024 15:00
gigerdo added 2 commits May 2, 2024 16:16
This happens if a tier requests more memory than the largest size available. In this case multiple nodes are provisioned.
@gigerdo
Copy link
Member Author

gigerdo commented May 2, 2024

@tobio thank you for the feedback. I implemented your feedback in the last two commits.

@gigerdo gigerdo requested a review from tobio May 2, 2024 15:40
gigerdo added 6 commits May 3, 2024 17:18
It is important to use UseTopologyStateForUnknown here, as UseStateForUnknown will also set a state for all children of the topology. However the children should stay unknown and their plan modifiers don't run.

This leads to problems when migrating templates, as the master tier should then not use the state and instead get the new values from the new template.
- The IC should only be updated if 'migrate_to_latest_hardware' is set
  - When this is set -> Take the latest values from deployment-template
- The master tier should only be updated in the plan if it actually is being enabled or disabled
- When the master tier has a ic-id and ic-version, those should be used to decide the default size and zone-count
  - However the deployment-template will always contain the latest version, which may not be the one used in the tier currently
  - So now the plan-modifier will load the correct IC via API and then use that
@gigerdo gigerdo requested a review from dimuon May 13, 2024 10:49
gigerdo added 2 commits May 17, 2024 13:03
- Use template if migrateToLatestHw==true
- Try using IC from private state
- Fall back to template if no IC in private state (for example during create)
Copy link
Contributor

@dimuon dimuon left a comment

Choose a reason for hiding this comment

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

Great work 👍

@gigerdo
Copy link
Member Author

gigerdo commented May 17, 2024

@dimuon thank you very much for taking the time to review this 🥇

@gigerdo gigerdo merged commit 4293f6b into elastic:master May 21, 2024
3 checks passed
@gigerdo gigerdo deleted the automatic-dedicated-masters branch May 21, 2024 10:51
@hnajib-sym
Copy link

Hello @gigerdo , any timeline to when this will be released ?

@gigerdo
Copy link
Member Author

gigerdo commented Aug 12, 2024

@hnajib-sym we do have plans to release a version 0.11 soon, though we don't have an exact timeline.

@nathan-maves
Copy link

We also have run into this same issue and would love to see a release soon!

@gigerdo gigerdo mentioned this pull request Aug 27, 2024
@gigerdo
Copy link
Member Author

gigerdo commented Aug 29, 2024

We have now release 0.11.0 which contains this feature:
https://github.com/elastic/terraform-provider-ec/releases/tag/v0.11.0

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.

5 participants