-
Notifications
You must be signed in to change notification settings - Fork 355
Skip deploy 611 #16123
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
base: release/6.11
Are you sure you want to change the base?
Skip deploy 611 #16123
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -741,6 +741,52 @@ private ApplicationId updateApplicationByArtifact(ApplicationId appId, | |
| allowedArtifactScopes, allowSnapshot, ownerAdmin.getOwner(appId), appSpec); | ||
| } | ||
|
|
||
| /** | ||
| * Checks if the application already exists with the exact same artifact and | ||
| * configuration. | ||
| */ | ||
| public boolean isAppAlreadyDeployed(ApplicationId appId, AppRequest<?> appRequest) throws Exception { | ||
|
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. |
||
| ApplicationMeta appMeta = store.getLatest(appId.getAppReference()); | ||
|
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. The logic currently checks the latest version of the application using |
||
| if (appMeta == null || appMeta.getSpec() == null) { | ||
| return false; | ||
| } | ||
|
|
||
| ArtifactSummary requestedArtifact = appRequest.getArtifact(); | ||
| if (requestedArtifact == null) { | ||
| return false; | ||
| } | ||
|
|
||
| ArtifactId currentArtifactId = appMeta.getSpec().getArtifactId(); | ||
| if (!currentArtifactId.getName().equals(requestedArtifact.getName()) || | ||
| !currentArtifactId.getScope().equals(requestedArtifact.getScope())) { | ||
| return false; | ||
| } | ||
|
|
||
| try { | ||
| io.cdap.cdap.api.artifact.ArtifactVersionRange range = io.cdap.cdap.api.artifact.ArtifactVersionRange | ||
| .parse(requestedArtifact.getVersion()); | ||
| if (!range.versionIsInRange(currentArtifactId.getVersion())) { | ||
| return false; | ||
| } | ||
| } catch (Exception e) { | ||
| return false; | ||
| } | ||
|
Comment on lines
+765
to
+773
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. Using |
||
|
|
||
| Object config = appRequest.getConfig(); | ||
| String requestedConfigStr = config == null ? null | ||
| : config instanceof String ? (String) config : GSON.toJson(config); | ||
| String currentConfigStr = appMeta.getSpec().getConfiguration(); | ||
|
|
||
| String normRequestedConfig = requestedConfigStr == null ? "" : requestedConfigStr.trim(); | ||
| String normCurrentConfig = currentConfigStr == null ? "" : currentConfigStr.trim(); | ||
|
|
||
| if (!normRequestedConfig.equals(normCurrentConfig)) { | ||
| return false; | ||
| } | ||
|
Comment on lines
+780
to
+785
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. Comparing JSON configurations as trimmed strings is fragile and can lead to false negatives if the JSON key ordering or whitespace differs, even when the configurations are semantically identical. A more robust approach is to compare the configurations as |
||
|
|
||
| return true; | ||
| } | ||
|
|
||
| /** | ||
| * Updates an application config by applying given update actions. The app should know how to | ||
| * apply these actions to its config. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ | |
| package io.cdap.cdap.storage.spanner; | ||
|
|
||
| import com.google.cloud.spanner.ErrorCode; | ||
| import com.google.cloud.spanner.Options; | ||
| import com.google.cloud.spanner.SpannerException; | ||
| import io.cdap.cdap.spi.data.transaction.TransactionException; | ||
| import io.cdap.cdap.spi.data.transaction.TransactionRunner; | ||
|
|
@@ -36,7 +37,8 @@ public SpannerTransactionRunner(SpannerStructuredTableAdmin admin) { | |
| @Override | ||
| public void run(TxRunnable runnable) throws TransactionException { | ||
| try { | ||
| admin.getDatabaseClient().readWriteTransaction().allowNestedTransaction().run(context -> { | ||
| // enforce lock | ||
| admin.getDatabaseClient().readWriteTransaction(Options.optimisticLock()).allowNestedTransaction().run(context -> { | ||
|
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. Enabling |
||
| runnable.run(new SpannerStructuredTableContext(context, admin)); | ||
| return null; | ||
| }); | ||
|
|
||
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.
The use of
LOG.warnis inappropriate here as skipping a deployment because it is already up-to-date is a normal, expected condition.LOG.infoorLOG.debugwould be more suitable. Additionally, there is a missing space after the comma in the log arguments.