(bug) reset profile Status.DependenciesHash#1101
Merged
gianlucam76 merged 1 commit intoprojectsveltos:mainfrom Mar 17, 2025
Merged
(bug) reset profile Status.DependenciesHash#1101gianlucam76 merged 1 commit intoprojectsveltos:mainfrom
gianlucam76 merged 1 commit intoprojectsveltos:mainfrom
Conversation
In Sveltos v0.50.0, when a ClusterProfile utilizes the `dependsOn` field
to establish dependencies between profiles, Sveltos incorrectly modifies
the `Spec.ClusterRefs` field. This field is intended for user configuration
and should not be altered by Sveltos.
**Root Cause:**
When Sveltos determines that a ClusterProfile needs to be deployed to a new
cluster due to dependency requirements, it mistakenly updates the `Spec.ClusterRefs`
field. This unintended modification leads to potential conflicts with user-defined
configurations.
**Solution:**
Instead of modifying `Spec.ClusterRefs`, Sveltos should reset the `Status.DependenciesHash`
field of the ClusterProfile. This action will trigger a new reconciliation loop, ensuring
that Sveltos correctly evaluates and deploys the ClusterProfile to the necessary clusters
based on its dependencies.
**Detailed Explanation:**
1. **Dependencies and Deployment:**
* ClusterProfiles can define dependencies using the `dependsOn` field.
* Sveltos tracks these dependencies to ensure that prerequisite profiles are deployed before dependent profiles.
* This dependency tracking should function independently of the `ClusterSelectors` specified in the ClusterProfile.
* If a ClusterProfile is required on a cluster due to its dependencies, even if its `ClusterSelectors` do not initially match, Sveltos should deploy it.
2. **The Bug:**
* In v0.50.0, Sveltos incorrectly modifies `Spec.ClusterRefs` when a dependent ClusterProfile needs to be deployed to a new cluster.
* `Spec.ClusterRefs` is a user-configurable field that should only be modified by the user.
* Modifying this field breaks the principle of least surprise and can lead to unexpected behavior.
3. **The Correct Approach:**
* When Sveltos detects a dependency that requires deployment to a new cluster, it should reset the `Status.DependenciesHash` field of the ClusterProfile.
* Resetting `Status.DependenciesHash` forces a reconciliation of the ClusterProfile.
* During reconciliation, Sveltos will re-evaluate the dependencies and the cluster selection logic.
* This ensures that the ClusterProfile is deployed to the necessary clusters without modifying the user-defined `Spec.ClusterRefs`.
4. **Benefits of the Solution:**
* Preserves the integrity of the user-defined `Spec.ClusterRefs` field.
* Maintains the expected behavior of ClusterProfile dependencies.
* Ensures that ClusterProfiles are deployed correctly based on dependencies, regardless of their `ClusterSelectors`.
* Avoids unintended side effects.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In Sveltos v0.50.0, when a ClusterProfile utilizes the
dependsOnfield to establish dependencies between profiles, Sveltos incorrectly modifies theSpec.ClusterRefsfield. This field is intended for user configuration and should not be altered by Sveltos.Root Cause:
When Sveltos determines that a ClusterProfile needs to be deployed to a new cluster due to dependency requirements, it mistakenly updates the
Spec.ClusterRefsfield. This unintended modification leads to potential conflicts with user-defined configurations.Solution:
Instead of modifying
Spec.ClusterRefs, Sveltos should reset theStatus.DependenciesHashfield of the ClusterProfile. This action will trigger a new reconciliation loop, ensuring that Sveltos correctly evaluates and deploys the ClusterProfile to the necessary clusters based on its dependencies.Detailed Explanation:
Dependencies and Deployment:
dependsOnfield.ClusterSelectorsspecified in the ClusterProfile.ClusterSelectorsdo not initially match, Sveltos should deploy it.The Bug:
Spec.ClusterRefswhen a dependent ClusterProfile needs to be deployed to a new cluster.Spec.ClusterRefsis a user-configurable field that should only be modified by the user.The Correct Approach:
Status.DependenciesHashfield of the ClusterProfile.Status.DependenciesHashforces a reconciliation of the ClusterProfile.Spec.ClusterRefs.Benefits of the Solution:
Spec.ClusterRefsfield.ClusterSelectors.Fixes #1100