-
Notifications
You must be signed in to change notification settings - Fork 27
Fix: IPM Update Resource Conflict #1129
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
Open
isc-jlechtne
wants to merge
4
commits into
main
Choose a base branch
from
fix-1128
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,6 +54,14 @@ Property Children As array Of %String(MAXLEN = 1, XMLPROJECTION = "NONE"); | |
|
|
||
| Index Children On Children(KEYS); | ||
|
|
||
| /// Tells us if this resource belongs to a module that will be processed as a part of the "Update" command | ||
| /// If set to true, %OnBeforeSave() will not error if another resource of the same name tries to be saved | ||
| /// and will instead save that resource with the other module as new | ||
| /// This is useful for an "Update" command where a resource was moved from one module to another. | ||
| /// If the resource's new module gets updated first, we don't want to error on a resource listed in two modules | ||
| /// when it will only be in one in the final environment once the resource's previous home gets updated | ||
| Property MarkedForUpdate As %Boolean [ InitialExpression = 0 ]; | ||
|
|
||
| Method ProcessorGet() As %IPM.ResourceProcessor.Abstract | ||
| { | ||
| // Similar to LifecycleGet in Module. | ||
|
|
@@ -344,6 +352,21 @@ ClassMethod NonNullResourceNameOpen( | |
| quit tResult | ||
| } | ||
|
|
||
| /// When given a name for a resource, set its MarkedForUpdate flag | ||
| /// See property description for more details on the usage of MarkedForUpdate | ||
| ClassMethod MarkResourceForUpdate( | ||
| resourceName As %String, | ||
| marking As %Boolean = 1) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there a use case for this method when marking would be set to 0? |
||
| { | ||
| set resource = ..NonNullResourceNameOpen(resourceName,,.sc) | ||
| if (resource = $$$NULLOREF) { | ||
| // If unable to find a resource with this name, do nothing | ||
| quit | ||
| } | ||
| set resource.MarkedForUpdate = marking | ||
| $$$ThrowOnError(resource.%Save()) | ||
| } | ||
|
|
||
| ClassMethod GetStatus( | ||
| InternalName As %String, | ||
| Output pReferenced As %Boolean, | ||
|
|
@@ -432,6 +455,11 @@ Method %OnBeforeSave(insert As %Boolean) As %Status [ Private, ServerOnly = 1 ] | |
| if $$$ISERR(tSC) { | ||
| quit | ||
| } | ||
| if (tOtherInstance.MarkedForUpdate) { | ||
| // If other instance marked for update, then we should overwrite it with this instead of throwing an error | ||
| $$$ThrowOnError(..%DeleteId(tExistingID)) | ||
| quit | ||
| } | ||
| if (tOtherInstance.Module.Name = ..Module.Name) { | ||
| set tMsg = $$$FormatText("Resource '%1' is listed more than once in module '%2'",..Name,..Module.Name) | ||
| } else { | ||
|
|
@@ -542,6 +570,9 @@ Storage Default | |
| <Value name="10"> | ||
| <Value>IsAPI</Value> | ||
| </Value> | ||
| <Value name="11"> | ||
| <Value>MarkedForUpdate</Value> | ||
| </Value> | ||
| </Data> | ||
| <DataLocation>{%%PARENT}("Resources")</DataLocation> | ||
| <DefaultData>ResourceReferenceDefaultData</DefaultData> | ||
|
|
||
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
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
9 changes: 9 additions & 0 deletions
9
.../_data/update-test/dependency-versions-updated/post-update/module-a/cls/Shared/Class2.cls
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| Class Shared.Class2 | ||
| { | ||
|
|
||
| ClassMethod MethodA() | ||
| { | ||
| write !, "This is ##class(Shared.Class2).MethodA() in module-a" | ||
| } | ||
|
|
||
| } |
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
9 changes: 9 additions & 0 deletions
9
.../_data/update-test/dependency-versions-updated/post-update/module-c/cls/Shared/Class1.cls
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| Class Shared.Class1 | ||
| { | ||
|
|
||
| ClassMethod MethodA() | ||
| { | ||
| write !, "This is ##class(Shared.Class1).MethodA() in module-c" | ||
| } | ||
|
|
||
| } |
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
9 changes: 9 additions & 0 deletions
9
...n/_data/update-test/dependency-versions-updated/pre-update/module-b/cls/Shared/Class1.cls
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| Class Shared.Class1 | ||
| { | ||
|
|
||
| ClassMethod MethodA() | ||
| { | ||
| write !, "This is ##class(Shared.Class1).MethodA() in module-b" | ||
| } | ||
|
|
||
| } |
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
9 changes: 9 additions & 0 deletions
9
...n/_data/update-test/dependency-versions-updated/pre-update/module-c/cls/Shared/Class2.cls
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| Class Shared.Class2 | ||
| { | ||
|
|
||
| ClassMethod MethodA() | ||
| { | ||
| write !, "This is ##class(Shared.Class2).MethodA() in module-c" | ||
| } | ||
|
|
||
| } |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: why did this get moved to only when pLockedDependencies is set?