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

Resolve out of sync presence map #366

Merged
merged 2 commits into from May 10, 2021
Merged

Conversation

SimonRichardson
Copy link
Member

The following attempts to keep the presence map in sync with the actual
data after normalization. During a normalization "scale" is swapped
out for "num_units". This is fine, except when it comes to overlays you
now don't know if scale or num_units was used for the overlays and
subsequent scale calls are now not used.

This is actually a problem with the library itself. There should be an
internal representation of a bundle that carries all this important
information, which should include schemas etc. At the very end of the
reading/parsing process, we should hand back a clean version of that
charm/bundle. That way we can make the bundle grow organically without
the requirement of so many hacks.

The code is simple, detect and resolve a normalization and just insert
the right value into the presence map before applying an overlay.


Bug: https://bugs.launchpad.net/juju/+bug/1884465

The following attempts to keep the presence map in-sync with the actual
data after a normalisation. During a normalisation "scale" is swapped
out for "num_units". This is fine, except when it comes to overlays you
now don't know if scale or num_units was used for the overlays and
subsequent scale calls are now not used.

This is actually a problem with the library itself. There should be an
internal representation of a bundle that carries all this important
information, which should include schemas etc. At the very end of the
reading/parsing process we should hand back a clean version of that
charm/bundle. That way we can make the bundle grow organically without
the requirement of so many hacks.

The code is simple, detect and resolve a normalisation and just insert
the right value into the presence map before applying an overlay.
Copy link
Contributor

@achilleasa achilleasa left a comment

Choose a reason for hiding this comment

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

LGTM (needs some tweaking with the comment typos). However, I think it would be a good idea to add a check as suggested in the PR comments.

overlay.go Outdated Show resolved Hide resolved
overlay.go Show resolved Hide resolved
When dealing with deletions of applications for overlays, the presence
map will have removed applications. In that case we need to not panic
when attempting to resolve the fields for an out of sync map.

It is much safer to always return a map back and then determine if the
field present is on the empty FieldPresenceMap. We will fail a bit later
on, but it means we don't have to force consumers of the forField check
for existence of a value.
@SimonRichardson SimonRichardson changed the base branch from master to v8 May 10, 2021 11:45
@SimonRichardson
Copy link
Member Author

$$merge$$

@jujubot jujubot merged commit 82380ab into juju:v8 May 10, 2021
@SimonRichardson SimonRichardson deleted the overlay-scales branch May 10, 2021 11:49
@wallyworld wallyworld mentioned this pull request May 12, 2021
jujubot added a commit that referenced this pull request May 12, 2021
#368

Merge v8 branch

#365 Change EnsureSchema signature to accept the default schema as an arg
#366 Resolve out of sync presence map

No conflicts
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.

None yet

3 participants