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

fix: #2802 - let SnapshotSource reuse self-generated snapshot #2803

Merged
merged 13 commits into from
Sep 10, 2024

Conversation

cknaap
Copy link
Member

@cknaap cknaap commented Jun 25, 2024

Description

If SnapshotSource detects a snapshot generated by our own SnapshotGenerator, it does not re-generate it.

Related issues

Fixes #2802.

Testing

See 2 new unit tests in the PR.

FirelyTeam Checklist

  • Update the title of the PR to be succinct and less than 50 characters
  • Mark the PR with the label breaking change when this PR introduces breaking changes

@ewoutkramer
Copy link
Member

I do not understand why #2802 is considered a bug. When you set the setting "ForceRegenerateSnapshots" to true, it will re-generate the snapshots, no matter what. This is the documented behaviour of this option:

Force expansion of all external profiles, disregarding any existing snapshot components.
If enabled, the snapshot generator will re-generate the snapshot components of all the core resource and datatype profiles
as well as of all other referenced external profiles.
Re-generated snapshots are annotated to prevent duplicate re-generation (assuming the provided resource resolver uses caching).
If disabled (default), then the snapshot generator relies on existing snapshot components, if they exist.

This PR does not look like a fix, but a behavioural change. The "ForceRegenerateSnapshot" used to always regenerate the snapshot, now it will only renegerate it if it was not created by us. That's a breaking change that we should not make in a non-major version.

Why don't you just set ForceRegenerateSnapshot to false instead? This will create a new snapshot if there is none, or if the snapshot is not ours.

@ewoutkramer
Copy link
Member

Design discussion will be continued on issue #2802.

Kasdejong
Kasdejong previously approved these changes Aug 15, 2024
Copy link
Contributor

@Kasdejong Kasdejong left a comment

Choose a reason for hiding this comment

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

I think this PR is overall an improvement now. From what I've read this is what we're going with, so I'll pull it

@Kasdejong
Copy link
Contributor

I will also deprecate the setting for good measure, because it seems as though right now it does not do anything. In fact, setting it to false while there is no snapshot will just produce no snapshot now :)

@@ -96,7 +98,9 @@ private async Tasks.Task<Resource> ensureSnapshot(Resource res)
{
if (res is StructureDefinition sd)
{
if (!sd.HasSnapshot || Generator.Settings.ForceRegenerateSnapshots || !sd.Snapshot.IsCreatedBySnapshotGenerator())
#pragma warning disable CS0618 // Type or member is obsolete
if (!sd.HasSnapshot || (Generator.Settings.ForceRegenerateSnapshots && !sd.Snapshot.IsCreatedBySnapshotGenerator()))
Copy link
Member

Choose a reason for hiding this comment

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

As Ewout says in #2802 this will surely result in regressions. We shouldn't change this.

@Kasdejong Kasdejong marked this pull request as draft August 20, 2024 07:53
@mmsmits mmsmits added the breaking change This issue/commit causes a breaking change, and requires a major version upgrade label Sep 4, 2024
@mmsmits
Copy link
Member

mmsmits commented Sep 4, 2024

This still needs to be done:

We should obsolete it and introduce a more explicit setting. Basically there are only two cases:
- Add a snapshot if there is none or use whatever is there (new behaviour)
- Regenerate snapshot once to ensure it is "ours" (and/or at least updated to the lastest version) (current default behaviour)

@Kasdejong Kasdejong removed the breaking change This issue/commit causes a breaking change, and requires a major version upgrade label Sep 4, 2024
@mmsmits mmsmits marked this pull request as ready for review September 10, 2024 11:11
@mmsmits mmsmits requested review from mmsmits and removed request for ewoutkramer September 10, 2024 11:12
@mmsmits mmsmits merged commit 846cdf5 into develop Sep 10, 2024
16 checks passed
@mmsmits mmsmits deleted the fix/snapshotsource-reuse-snapshot branch September 10, 2024 13:11
mmsmits added a commit that referenced this pull request Nov 20, 2024
…euse-snapshot"

This reverts commit 846cdf5, reversing
changes made to f8ef048.
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.

SnapshotSource does not reuse self-generated snapshot
4 participants