From c7d56f260057d9bfb234067dbb18c1b4ef45d1ed Mon Sep 17 00:00:00 2001 From: Yonggang Liu Date: Fri, 27 Sep 2024 12:37:08 -0400 Subject: [PATCH 1/4] HARMONY-1878: Make WKT conversion precision configurable. --- .../harmony/app/frontends/ogc-edr/get-data-for-point.ts | 6 ++---- .../app/frontends/ogc-edr/get-data-for-trajectory.ts | 6 ++---- services/harmony/app/util/env.ts | 2 ++ services/harmony/env-defaults | 3 +++ 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/services/harmony/app/frontends/ogc-edr/get-data-for-point.ts b/services/harmony/app/frontends/ogc-edr/get-data-for-point.ts index 283436f2b..c3b162df4 100644 --- a/services/harmony/app/frontends/ogc-edr/get-data-for-point.ts +++ b/services/harmony/app/frontends/ogc-edr/get-data-for-point.ts @@ -2,12 +2,10 @@ import { keysToLowerCase } from '../../util/object'; import { ParameterParseError, mergeParameters, parseWkt, validateWkt } from '../../util/parameter-parsing-helpers'; import { Response, NextFunction } from 'express'; import HarmonyRequest from '../../models/harmony-request'; +import env from '../../util/env'; import { RequestValidationError } from '../../util/errors'; import { getDataCommon } from './get-data-common'; -// POINT to POLYGON conversion side length, 0.0001 is about 11 meters in precision -const POINT_PRECISION = 0.0001; - /** * Converts a WKT POINT string to a WKT POLYGON string. * The polygon is a square centered around the point. @@ -82,7 +80,7 @@ function wktMultipointToMultipolygon(wktMultipoint: string, sideLength: number): * @returns The converted WKT POLYGON or WKT MULTIPOLYGON string. * @throws RequestValidationError if the WKT string format is invalid. */ -export function convertWktToPolygon(wkt: string, sideLength: number = POINT_PRECISION): string { +export function convertWktToPolygon(wkt: string, sideLength: number = env.wktPrecision): string { if (wkt.startsWith('POINT')) { return wktPointToPolygon(wkt, sideLength); } else if (wkt.startsWith('MULTIPOINT')) { diff --git a/services/harmony/app/frontends/ogc-edr/get-data-for-trajectory.ts b/services/harmony/app/frontends/ogc-edr/get-data-for-trajectory.ts index 8062a755b..ad141b3a0 100644 --- a/services/harmony/app/frontends/ogc-edr/get-data-for-trajectory.ts +++ b/services/harmony/app/frontends/ogc-edr/get-data-for-trajectory.ts @@ -2,12 +2,10 @@ import { keysToLowerCase } from '../../util/object'; import { ParameterParseError, mergeParameters, parseWkt, validateWkt } from '../../util/parameter-parsing-helpers'; import { Response, NextFunction } from 'express'; import HarmonyRequest from '../../models/harmony-request'; +import env from '../../util/env'; import { RequestValidationError } from '../../util/errors'; import { getDataCommon } from './get-data-common'; -// LINESTRING to POLYGON conversion side length, 0.0001 is about 11 meters in precision -const LINESTRING_PRECISION = 0.0001; - type Point = { x: number, y: number }; /** @@ -162,7 +160,7 @@ function wktMultiLineStringToMultipolygon( */ export function convertWktLineToPolygon( wkt: string, - sideLength: number = LINESTRING_PRECISION): string { + sideLength: number = env.wktPrecision): string { if (wkt.startsWith('LINESTRING')) { return convertLineStringToPolygon(wkt, sideLength); diff --git a/services/harmony/app/util/env.ts b/services/harmony/app/util/env.ts index 82333afca..45a0656d0 100644 --- a/services/harmony/app/util/env.ts +++ b/services/harmony/app/util/env.ts @@ -108,6 +108,8 @@ class HarmonyServerEnv extends HarmonyEnv { @Min(1) maxDataOperationCacheSize: number; + wktPrecision: number; + locallyDeployedServices: string; } diff --git a/services/harmony/env-defaults b/services/harmony/env-defaults index 3085558d3..8c2de12b9 100644 --- a/services/harmony/env-defaults +++ b/services/harmony/env-defaults @@ -132,6 +132,9 @@ MAX_POST_FILE_PARTS=100 # Maximum size (in bytes) of the cache for data operations MAX_DATA_OPERATION_CACHE_SIZE=512000000 +# WKT POINT/LINESTRING to POLYGON conversion side length, 0.0001 is about 11 meters in precision +WKT_PRECISION=0.0001 + ############################################################################# # OAuth 2 (Earthdata Login) # # # From 23ee0f7a7e7ace4bcf17208a13f211ef7cedde39 Mon Sep 17 00:00:00 2001 From: Yonggang Liu Date: Fri, 27 Sep 2024 12:38:18 -0400 Subject: [PATCH 2/4] HARMONY-1873: Update /service-image-tag API docs. --- docs/guides/managing-existing-services.md | 28 +++++++++++------------ 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/guides/managing-existing-services.md b/docs/guides/managing-existing-services.md index e25c0d53c..d8f41c9d0 100644 --- a/docs/guides/managing-existing-services.md +++ b/docs/guides/managing-existing-services.md @@ -36,14 +36,14 @@ The returned JSON response is a map of canonical service names to tags: "subset-band-name": "latest" } ``` -**Example 2** - Harmony `/service-image-tags` response +**Example 2** - Harmony `/service-image-tag` response ## Get backend service tag (version) information for a specific service ``` curl -Ln -bj https://harmony.uat.earthdata.nasa.gov/service-image-tag/#canonical-service-name ``` -**Example 3** - Getting a specific backend service image tag using the `/service-image-tags` API +**Example 3** - Getting a specific backend service image tag using the `/service-image-tag` API The returned JSON response is a map with a single `tag` field: @@ -52,7 +52,7 @@ The returned JSON response is a map with a single `tag` field: "tag": "1.2.3" } ``` -**Example 4** - Harmony `/service-image-tags` response for a single service +**Example 4** - Harmony `/service-image-tag` response for a single service ## Update backend service tag (version) for a specific service @@ -66,17 +66,17 @@ For example: ``` curl -XPUT https://harmony.uat.earthdata.nasa.gov/service-image-tag/#canonical-service-name -H 'Authorization: Bearer ' -d '{"tag": "new-version"}' -H 'Content-type: application/json' ``` -**Example 5** - Updating a specific backend service image tag using the `/service-image-tags` API +**Example 5** - Updating a specific backend service image tag using the `/service-image-tag` API -The body of the `PUT` request should be a JSON object with a `tag` field indicating the tag of the updated service image and an optional `test` field with the value of the tag of the regression test docker image, the value 'latest' will be used when `test` field is omitted. +The body of the `PUT` request should be a JSON object with a `tag` field indicating the tag of the updated service image and an optional `regression_test_version` field with the value of the tag of the regression test docker image, the value 'latest' will be used when `regression_test_version` field is omitted. ```JSON { "tag": "new-version", - "test": "1.0.0" + "regression_test_version": "1.0.0" } ``` -**Example 6** - Harmony `/service-image-tags` request body for updating a tag +**Example 6** - Harmony `/service-image-tag` request body for updating a tag The returned JSON response has a tag field indicating the new tag value and a statusLink field with the url for getting the status of the service image deployment. @@ -86,7 +86,7 @@ The returned JSON response has a tag field indicating the new tag value and a st "statusLink": "https://harmony.uat.earthdata.nasa.gov/service-deployment/" } ``` -**Example 7** - Harmony `/service-image-tags` response for a updating a single service +**Example 7** - Harmony `/service-image-tag` response for a updating a single service >**Note** this is an asynchronous request, so the status code for the response will be `202 Accepted` - it may take several minutes for the entire update to complete. @@ -132,7 +132,7 @@ The returned JSON response has the fields indicating the current status of the s GET https://harmony.uat.earthdata.nasa.gov/service-deployments-state ``` -**Example 10** - Getting the current enable/disable state of the service deployment feature using the `service-image-tag` API +**Example 10** - Getting the current enable/disable state of the service deployment feature using the `service-deployments-state` API The returned JSON response shows if the service deployment is currently enabled (true) or disabled (false) and any optional message: @@ -143,7 +143,7 @@ The returned JSON response shows if the service deployment is currently enabled } ``` --- -**Example 11** - Harmony `service-image-tags` response for enable/disable state +**Example 11** - Harmony `service-deployments-state` response for enable/disable state ## Enable the service deployment feature The user must have admin permission in order to invoke this endpoint. User can provide an optional message in the JSON body to indicate the reason for enabling. This message will be persisted in database and returned when user retrieves the service deployment state later. @@ -154,7 +154,7 @@ For example: curl -XPUT -H 'Authorization: Bearer ' -H 'Content-type: application/json' https://harmony.uat.earthdata.nasa.gov/service-deployments-state -d '{"enabled": true, "message": "Manually enabled by David"}' ``` --- -**Example 12** - Harmony `service-image-tags` request for enabling the service deployment +**Example 12** - Harmony `service-deployments-state` request for enabling the service deployment The returned JSON response is the same as the get current state of the service deployment feature request above, indicating the current state: @@ -164,7 +164,7 @@ The returned JSON response is the same as the get current state of the service d "message": "Manually enabled by David" } ``` -**Example 13** - Harmony `/service-image-tags` response for enabling the service deployment +**Example 13** - Harmony `/service-deployments-state` response for enabling the service deployment ## Disable the service deployment feature The user must have admin permission in order to invoke this endpoint. User can provide an optional message in the JSON body to indicate the reason for disabling. This message will be persisted in database and returned when user retrieves the service deployment state later. @@ -175,7 +175,7 @@ For example: curl -XPUT -H 'Authorization: Bearer ' -H 'Content-type: application/json' https://harmony.uat.earthdata.nasa.gov/service-deployments-state -d '{"enabled": false, "message": "Manually disabled by David"}' ``` --- -**Example 14** - Harmony `service-image-tags` request for disabling the service deployment +**Example 14** - Harmony `service-deployments-state` request for disabling the service deployment The returned JSON response is the same as the get current state of the service deployment feature request above, indicating the current state: @@ -185,7 +185,7 @@ The returned JSON response is the same as the get current state of the service d "message": "Manually disabled by David" } ``` -**Example 15** - Harmony `/service-image-tags` response for disabling the service deployment +**Example 15** - Harmony `/service-deployments-state` response for disabling the service deployment ## Getting the Deployment History for All Services ``` From d89934f7119b4fd40b2167763943fc4ed2b790ce Mon Sep 17 00:00:00 2001 From: Yonggang Liu Date: Fri, 27 Sep 2024 13:49:00 -0400 Subject: [PATCH 3/4] HARMONY-1878: Wait longer for port forwarding when running locally. --- bin/port-forward | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/port-forward b/bin/port-forward index 78c8b3faf..67d4d1ec5 100755 --- a/bin/port-forward +++ b/bin/port-forward @@ -15,7 +15,7 @@ function start_port_forwarding() { stop_port_forwarding "$service_name" - local max_iterations=60 + local max_iterations=120 local iteration=0 while [ "$iteration" -lt "$max_iterations" ]; do @@ -37,7 +37,7 @@ function start_port_forwarding() { ((iteration++)) if [ "$EXEC_CONTEXT" == "workflow" ]; then - sleep 60 + sleep 30 else sleep 1 fi From dbb6f2f99f0bbe393a5e87d4109d842cef995f86 Mon Sep 17 00:00:00 2001 From: Yonggang Liu Date: Fri, 27 Sep 2024 15:27:06 -0400 Subject: [PATCH 4/4] HARMONY-1878: Add decorator to wktPrecision to make sure it is a positive number. --- services/harmony/app/util/env.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/harmony/app/util/env.ts b/services/harmony/app/util/env.ts index 45a0656d0..b224c03cb 100644 --- a/services/harmony/app/util/env.ts +++ b/services/harmony/app/util/env.ts @@ -1,4 +1,4 @@ -import { IsInt, IsNotEmpty, Matches, Min } from 'class-validator'; +import { IsInt, IsNotEmpty, IsPositive, Matches, Min } from 'class-validator'; import { HarmonyEnv, memorySizeRegex } from '@harmony/util/env'; import _ from 'lodash'; import * as path from 'path'; @@ -108,6 +108,7 @@ class HarmonyServerEnv extends HarmonyEnv { @Min(1) maxDataOperationCacheSize: number; + @IsPositive() wktPrecision: number; locallyDeployedServices: string;