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

Allow idempotent change to artifact state #3637

Merged
merged 1 commit into from
Sep 29, 2023

Conversation

renjingxiao
Copy link
Contributor

Hi @EricWittmann and @carlesarnal ,

In this PR, I have added checks to ensure that the state can be changed to the same value multiple times. It works for both /groups/{groupId}/artifacts/{artifactId}/state and /groups/{groupId}/artifacts/{artifactId}/versions/{versionId}/state endpoints. It may close #3475 .

Thank you for reviewing it.

@renjingxiao renjingxiao force-pushed the state-idempotent branch 2 times, most recently from 2b51d95 to 0280d6c Compare September 11, 2023 08:02
@@ -44,6 +44,7 @@
import io.apicurio.registry.utils.ArtifactIdValidator;
import io.apicurio.registry.utils.IoUtil;
import io.apicurio.registry.utils.JAXRSClientUtil;
import io.apicurio.tenantmanager.api.datamodel.SortBy;
Copy link
Member

Choose a reason for hiding this comment

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

You have imported the wrong bean here. This bean must be coming from Registry, not from the tenant-manager.

@@ -61,14 +61,17 @@

import io.apicurio.registry.AbstractResourceTestBase;
import io.apicurio.registry.rest.client.exception.RuleViolationException;
import io.apicurio.registry.rest.v1.beans.UpdateState;
Copy link
Member

Choose a reason for hiding this comment

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

The UpdateState from v1 is likely not needed.

Copy link
Member

@carlesarnal carlesarnal left a comment

Choose a reason for hiding this comment

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

I have made a couple comments.

@@ -659,8 +664,12 @@ public void updateArtifactVersionState(String groupId, String artifactId, String
requireParameter("groupId", groupId);
requireParameter("artifactId", artifactId);
requireParameter("version", version);

ArtifactMetaDataDto metaData = storage.getArtifactMetaData(defaultGroupIdToNull(groupId), artifactId);
Copy link
Member

Choose a reason for hiding this comment

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

This is not correct. If we are going to take the approach of looking up the current state from the storage, in this instance we need to get the artifact version state, not the artifact state. The reason is that this particular update is for a specific artifact version (notice that the method signature includes a version param).

So this needs to change to look up the metaData of a single version of the artifact from the storage.

@EricWittmann EricWittmann merged commit 25fa051 into Apicurio:main Sep 29, 2023
@carlesarnal carlesarnal added the backport-2.x Backport fix to Registry v2 label Nov 3, 2023
@carlesarnal carlesarnal self-assigned this Nov 7, 2023
carlesarnal pushed a commit to carlesarnal/apicurio-registry that referenced this pull request Nov 13, 2023
carlesarnal added a commit that referenced this pull request Nov 13, 2023
* Add null checks on  role mapping (#3800)

* Add null checks on  role mapping

* Add check for Role and Unit Test

* Fixed a regression in the Settings page search box (#3798)

* modified state change checks in ArtifactStateExt and AbstractSqlRegistryStorage (#3637)

* Incorrect default value avro serialization (#3633)

* Fix default value converter

* Add test for default byte type value in converter test

* Correct comment

* added unit tests (#3593)

* Bugfix: prase decimal's default

---------

Co-authored-by: Amoncy <138134862+Amoncy@users.noreply.github.com>
Co-authored-by: Eric Wittmann <eric.wittmann@gmail.com>
Co-authored-by: Jean Xiao <118199750+renjingxiao@users.noreply.github.com>
Co-authored-by: Anshu Anna Moncy <amoncy@redhat.com>
Co-authored-by: j2gg0s <j2gg0s@gmail.com>
carlesarnal added a commit to carlesarnal/apicurio-registry that referenced this pull request Nov 13, 2023
* Add null checks on  role mapping (Apicurio#3800)

* Add null checks on  role mapping

* Add check for Role and Unit Test

* Fixed a regression in the Settings page search box (Apicurio#3798)

* modified state change checks in ArtifactStateExt and AbstractSqlRegistryStorage (Apicurio#3637)

* Incorrect default value avro serialization (Apicurio#3633)

* Fix default value converter

* Add test for default byte type value in converter test

* Correct comment

* added unit tests (Apicurio#3593)

* Bugfix: prase decimal's default

---------

Co-authored-by: Amoncy <138134862+Amoncy@users.noreply.github.com>
Co-authored-by: Eric Wittmann <eric.wittmann@gmail.com>
Co-authored-by: Jean Xiao <118199750+renjingxiao@users.noreply.github.com>
Co-authored-by: Anshu Anna Moncy <amoncy@redhat.com>
Co-authored-by: j2gg0s <j2gg0s@gmail.com>
carlesarnal added a commit that referenced this pull request Nov 13, 2023
* Add null checks on  role mapping (#3800)

* Add null checks on  role mapping

* Add check for Role and Unit Test

* Fixed a regression in the Settings page search box (#3798)

* modified state change checks in ArtifactStateExt and AbstractSqlRegistryStorage (#3637)

* Incorrect default value avro serialization (#3633)

* Fix default value converter

* Add test for default byte type value in converter test

* Correct comment

* added unit tests (#3593)

* Bugfix: prase decimal's default

---------

Co-authored-by: Amoncy <138134862+Amoncy@users.noreply.github.com>
Co-authored-by: Eric Wittmann <eric.wittmann@gmail.com>
Co-authored-by: Jean Xiao <118199750+renjingxiao@users.noreply.github.com>
Co-authored-by: Anshu Anna Moncy <amoncy@redhat.com>
Co-authored-by: j2gg0s <j2gg0s@gmail.com>
@renjingxiao renjingxiao deleted the state-idempotent branch December 4, 2023 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/rest-api backport-2.x Backport fix to Registry v2
Projects
No open projects
Status: Released
Development

Successfully merging this pull request may close these issues.

POST /groups/{groupId}/artifacts/{artifactId}/state is not idempotent
3 participants