Skip to content

Commit

Permalink
V2 dpsetup (#265)
Browse files Browse the repository at this point in the history
* MCPODS-7636:
* Use latest code deploy setup for v2
* Use naksha-hub service instead of xyz-hub
* Use AWS secret key path with v2 suffix
* in start-app.sh use service.namespace=Naksha-v2-${EC2_ENV_UPPER}

* renamed xyz-hub.service to naksha-hub.service

* MCPODS-7636: parameterise extension config

* MCPODS-7636: pipeline changes

* MCPODS-7636: pipeline changes

* MCPODS-7636: SED command change

* MCPODS-7636: pipeline changes

* MCPODS-7636: swagger url change

* MCPODS-7636: swagger url changes

* MCPODS-7636: pipeline changes

* MCPODS-7636: Add Env and Ext jar name in log

* MCPODS-7636: remove v2_dpsetup branch from pipeline

* MCPODS-7636: review comments fixed

---------

Co-authored-by: Rajeev Jain <[email protected]>
  • Loading branch information
gururajiv and Rajeev Jain authored May 21, 2024
1 parent 5670771 commit 6cc5acd
Show file tree
Hide file tree
Showing 16 changed files with 46 additions and 23 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/main-dev-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
s3-bucket-name: ${{ vars.RELEASE_S3_BUCKET_NAME }}
s3-bucket-dir-path: ${{ needs.Build-and-Publish.outputs.app-version }}
s3-artifact-version: ${{ needs.Build-and-Publish.outputs.codedeploy-artifact-version }}
extension-s3-bucket-name: naksha-pvt-releases
secrets:
aws-key: ${{ secrets.AWS_KEY }}
aws-secret: ${{ secrets.AWS_SECRET }}
Expand All @@ -49,7 +50,7 @@ jobs:
uses: ./.github/workflows/reusable-codedeploy-deployment.yml
with:
aws-region: ${{ vars.AWS_REGION }}
codedeploy-app-name: ${{ vars.CODEDEPLOY_APP_NAME }}
codedeploy-app-name: Naksha_v2_App
codedeploy-group-name: ${{ vars.CODEDEPLOY_DEV_GROUP_NAME }}
deployment-description: 'Deployment triggered by ${{ github.triggering_actor }} from Github repo [${{ github.repository }}], ${{ github.ref_type }} [${{ github.ref_name }}], commit sha [${{ github.sha }}]'
s3-bucket-name: ${{ vars.RELEASE_S3_BUCKET_NAME }}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/main-e2e-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
s3-bucket-name: ${{ vars.RELEASE_S3_BUCKET_NAME }}
s3-bucket-dir-path: ${{ needs.Build-and-Publish.outputs.app-version }}
s3-artifact-version: ${{ needs.Build-and-Publish.outputs.codedeploy-artifact-version }}
extension-s3-bucket-name: naksha-pvt-releases
secrets:
aws-key: ${{ secrets.AWS_KEY }}
aws-secret: ${{ secrets.AWS_SECRET }}
Expand All @@ -45,7 +46,7 @@ jobs:
uses: ./.github/workflows/reusable-codedeploy-deployment.yml
with:
aws-region: ${{ vars.AWS_REGION }}
codedeploy-app-name: ${{ vars.CODEDEPLOY_APP_NAME }}
codedeploy-app-name: Naksha_v2_App
codedeploy-group-name: ${{ vars.CODEDEPLOY_E2E_GROUP_NAME }}
deployment-description: 'Deployment triggered by ${{ github.triggering_actor }} from Github repo [${{ github.repository }}], ${{ github.ref_type }} [${{ github.ref_name }}], commit sha [${{ github.sha }}]'
s3-bucket-name: ${{ vars.RELEASE_S3_BUCKET_NAME }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/main-prd-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ name: Prod Workflow
on:
push:
tags:
- '2.[0-9]+.[0-9]+'
- '!*rc*'
- '2.[0-9]+.[0-9]+-preprod'

permissions:
checks: write # for junit reporting
Expand Down Expand Up @@ -34,6 +33,7 @@ jobs:
s3-bucket-name: ${{ vars.RELEASE_S3_BUCKET_NAME }}
s3-bucket-dir-path: ${{ needs.Build-and-Publish.outputs.app-version }}
s3-artifact-version: ${{ needs.Build-and-Publish.outputs.codedeploy-artifact-version }}
extension-s3-bucket-name: ${{ vars.PRD_PVT_RELEASE_S3_BUCKET_NAME }}
secrets:
aws-key: ${{ secrets.AWS_KEY }}
aws-secret: ${{ secrets.AWS_SECRET }}
Expand All @@ -46,7 +46,7 @@ jobs:
uses: ./.github/workflows/reusable-codedeploy-deployment.yml
with:
aws-region: ${{ vars.PRD_AWS_REGION }}
codedeploy-app-name: ${{ vars.CODEDEPLOY_APP_NAME }}
codedeploy-app-name: Naksha_v2_App
codedeploy-group-name: ${{ vars.CODEDEPLOY_PRD_GROUP_NAME }}
deployment-description: 'Deployment triggered by ${{ github.triggering_actor }} from Github repo [${{ github.repository }}], ${{ github.ref_type }} [${{ github.ref_name }}], commit sha [${{ github.sha }}]'
# we use Prod access point (eu-west-1) to fetch deployment artifacts from E2E S3 bucket (us-east-1)
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/reusable-s3-codedeploy-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ on:
type: string
description: 'A version (or suffix) to be used in artifact name while uploading it to AWS S3 bucket'
required: true
extension-s3-bucket-name:
type: string
description: 'AWS S3 bucket name, where extension artifacts are uploaded'
required: true
secrets:
aws-key:
description: 'AWS Access key of a user, who is allowed to upload artifact to S3 bucket'
Expand Down Expand Up @@ -55,6 +59,10 @@ jobs:
run: |
BUNDLE_NAME=deployment_${{ inputs.s3-artifact-version }}.tar.gz
echo "name=$BUNDLE_NAME" >> "$GITHUB_OUTPUT"
- name: Set extension s3 bucket name in cloud-config.json
run: |
export ACTUAL_BUCKET=${{ inputs.extension-s3-bucket-name }}
sed -i "s+SOME_S3_BUCKET+${ACTUAL_BUCKET}+g" download/contents/naksha-hub/.config/cloud-config.json
- name: Preparing S3 artifact bundle
run: |
cd download
Expand Down
6 changes: 3 additions & 3 deletions deployment/codedeploy/appspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ file_exists_behavior: OVERWRITE
files:
- source: /contents
destination: /home/admin
- source: /contents/naksha-hub/xyz-hub.service
- source: /contents/naksha-hub/naksha-hub.service
destination: /etc/systemd/system
# For deployments to Amazon Linux, Ubuntu Server, or RHEL instances,
# you can specify a "permissions"
Expand Down Expand Up @@ -68,9 +68,9 @@ permissions:
mode: 755
type:
- file
# change permission for file xyz-hub.service
# change permission for file naksha-hub.service
- object: /etc/systemd/system
pattern: "xyz-hub.service"
pattern: "naksha-hub.service"
owner: admin
group: admin
type:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"extensionConfigParams": {
"whitelistClasses": [ "java.*", "javax.*", "com.here.*", "jdk.internal.reflect.*", "com.sun.*", "org.w3c.dom.*", "sun.misc.*"],
"intervalms": 30000,
"extensionsRootPath": "s3://naksha-pvt-releases/extensions/"
"extensionsRootPath": "s3://SOME_S3_BUCKET/extensions/"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Description=Naksha-Hub
[Service]
User=admin
Type=simple
PIDFile=/run/xyz-hub.pid
PIDFile=/run/naksha-hub.pid
WorkingDirectory=/home/admin/naksha-hub
ExecStart=/home/admin/naksha-hub/start-app.sh
# ExecReload=/home/transang/startup.sh reload
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### Set env params based on App secrets fetched from AWS Secrets Manager

SECRET_ID="$EC2_ENV/heremap/service/naksha"
SECRET_ID="$EC2_ENV/heremap/service/naksha-v2"
SECRET_RESPONSE_JSON=`aws secretsmanager get-secret-value --region $EC2_REGION --secret-id $SECRET_ID`

# Validate that we really got the successful response
Expand Down
2 changes: 1 addition & 1 deletion deployment/codedeploy/contents/naksha-hub/start-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if [ ! -d logs ]; then
fi

# Set local parameters
export OTEL_RESOURCE_ATTRIBUTES=service.name=${EC2_INSTANCE_NAME},service.namespace=Naksha-${EC2_ENV_UPPER}
export OTEL_RESOURCE_ATTRIBUTES=service.name=${EC2_INSTANCE_NAME},service.namespace=Naksha-v2-${EC2_ENV_UPPER}

# Print basic parameters (avoid printing secrets)
echo "NAKSHA_CONFIG_PATH : $NAKSHA_CONFIG_PATH"
Expand Down
2 changes: 1 addition & 1 deletion deployment/codedeploy/scripts/ApplicationStart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

# Start application
echo "Starting Naksha service..."
sudo systemctl start xyz-hub
sudo systemctl start naksha-hub
echo "Start triggered!"
8 changes: 4 additions & 4 deletions deployment/codedeploy/scripts/ApplicationStop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

# Stop Naksha service (only if it was configured)
CODE=0
sudo systemctl list-unit-files --all | grep -Fq "xyz-hub.service" || CODE=1
sudo systemctl list-unit-files --all | grep -Fq "naksha-hub.service" || CODE=1
if [[ $CODE -eq 0 ]]; then
echo ">> Stopping service [xyz-hub]..."
sudo systemctl stop xyz-hub
echo ">> Stopping service [naksha-hub]..."
sudo systemctl stop naksha-hub
else
echo ">> Service [xyz-hub] not found. Nothing to stop"
echo ">> Service [naksha-hub] not found. Nothing to stop"
fi
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ servers:
# description: "PRD"
#- url: "https://naksha-e2e.ext.mapcreator.here.com/"
# description: "E2E"
- url: "https://naksha-dev.ext.mapcreator.here.com/"
- url: "https://naksha-v2-dev.ext.mapcreator.here.com/"
description: "DEV"

info:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class ExtensionConfig {
public static final String EXPIRY = "expiry";
public static final String EXTENSIONS = "extensions";
public static final String WHITELIST_DELEGATE_CLASSES = "whitelistDelegateClasses";
public static final String ENV_NAME = "env";

@JsonProperty(EXPIRY)
long expiry;
Expand All @@ -42,14 +43,19 @@ public class ExtensionConfig {
@JsonProperty(WHITELIST_DELEGATE_CLASSES)
List<String> whitelistDelegateClasses;

@JsonProperty(ENV_NAME)
String env;

@JsonCreator
public ExtensionConfig(
@JsonProperty(EXPIRY) @NotNull Long expiry,
@JsonProperty(EXTENSIONS) @Nullable List<Extension> extensions,
@JsonProperty(WHITELIST_DELEGATE_CLASSES) @Nullable List<String> whitelistDelegateClasses) {
@JsonProperty(WHITELIST_DELEGATE_CLASSES) @Nullable List<String> whitelistDelegateClasses,
@JsonProperty(ENV_NAME) @NotNull String env) {
this.expiry = expiry;
this.extensions = extensions;
this.whitelistDelegateClasses = whitelistDelegateClasses;
this.env = env;
}

public long getExpiry() {
Expand All @@ -63,4 +69,8 @@ public List<Extension> getExtensions() {
public List<String> getWhilelistDelegateClass() {
return whitelistDelegateClasses;
}

public String getEnv() {
return env;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,11 @@ private void publishIntoCache(KVPair<Extension, File> result, ExtensionConfig ex
loaderCache.put(extension.getId(), new KVPair<Extension, ClassLoader>(extension, loader));
PluginCache.removeExtensionCache(extension.getId());
logger.info(
"Extension {},{} is successfully loaded into the cache.",
"Extension id={}, version={} is successfully loaded into the cache, using Jar at {} for env={}.",
extension.getId(),
extension.getVersion());
extension.getVersion(),
extension.getUrl().substring(extension.getUrl().lastIndexOf("/") + 1),
extensionConfig.getEnv());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ public ExtensionConfig getExtensionConfig() {
} catch (IOException e) {
throw new RuntimeException(e);
}
return new ExtensionConfig(System.currentTimeMillis() + 6000, list,whitelistUrls);
return new ExtensionConfig(System.currentTimeMillis() + 6000, list,whitelistUrls,"test");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@ private static WriteXyzCollections createAdminCollectionsRequest() {
return new ExtensionConfig(
System.currentTimeMillis() + extensionConfigParams.getIntervalMs(),
extList,
extensionConfigParams.getWhiteListClasses());
extensionConfigParams.getWhiteListClasses(),
this.nakshaHubConfig.env.toLowerCase());
}

private List<Extension> loadExtensionConfigFromS3(String extensionRootPath) {
Expand Down

0 comments on commit 6cc5acd

Please sign in to comment.