Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt B Krystof committed Jul 26, 2024
2 parents 055d8d5 + 86ef47c commit 35951a7
Show file tree
Hide file tree
Showing 166 changed files with 6,882 additions and 2,815 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/deploy-rc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: "TST/STG - Deploy release candidate"

on:
workflow_dispatch:
push:
tags:
- '*'

jobs:
staging:
uses: ./.github/workflows/remote-cd-trigger-template.yml
with:
WORKFLOW: aks-deployment-pstatus-graphql-stg.yml
REF: '${{ github.ref_name }}' # Resolves to the tag that is pushed
secrets: inherit
21 changes: 21 additions & 0 deletions .github/workflows/graphql-service-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "CI - GraphQL Service"

on:
workflow_dispatch:
pull_request:
paths:
- pstatus-graphql-ktor/**

defaults:
run:
working-directory: pstatus-graphql-ktor/

jobs:
unit-test:
name: Unit Test
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Run Gradle Test
run: ./gradlew test
23 changes: 23 additions & 0 deletions .github/workflows/graphql-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: DEV - GraphQL Service

on:
workflow_dispatch:
inputs:
REF:
description: Branch from CDCgov/data-exchange-processing-status that you want to deploy to the dev environment.
default: main
required: true
type: string
push:
branches:
- main
paths:
- pstatus-graphql-ktor/**

jobs:
remote-trigger:
uses: ./.github/workflows/remote-cd-trigger-template.yml
with:
WORKFLOW: aks-deployment-pstatus-graphql-dev-shared.yml
REF: ${{ inputs.REF }}
secrets: inherit
45 changes: 45 additions & 0 deletions .github/workflows/remote-cd-trigger-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Template - Remote trigger to CDCent
on:
workflow_call:
inputs:
WORKFLOW:
type: string
description: "Workflow yml file that should be triggered."
required: true
REF:
type: string
description: "Git tag or branch the workflow is running on."
required: false
default: 'main'

jobs:
invoke-cd-trigger:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ github.token }}
steps:
- name: Checkout Gen GitHub App Access Token
uses: actions/checkout@v3
with:
repository: kave/github-app-token
- name: Generate Token
run: |
sudo gem install jwt
echo "${{ secrets.CDC_COE_BOTFREY_PEM }}" > app-private-key.pem
chmod +x ./get-github-app-access-token.sh;
. ./get-github-app-access-token.sh;
echo "access_token=${TOKEN}" >> "$GITHUB_ENV"
- name: Manually Dispatch Remote CICD Trigger Event
uses: actions/github-script@v6
with:
github-token: ${{ env.access_token }}
script: |
await github.rest.actions.createWorkflowDispatch({
owner: 'cdcent',
repo: 'data-exchange-pstatus-devops',
workflow_id: '${{ inputs.WORKFLOW }}',
ref: 'main',
inputs: {
REF: '${{ inputs.REF }}'
}
})
3 changes: 0 additions & 3 deletions processing-status-api-function-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ The following is needed in order to build and deploy this function app:
## Required Application Settings
In addition to the standard required application settings, the processing status API function app requires the following.

- `JAEGER_OTEL_COLLECTOR_END_POINT` - URL of the Jaeger trace collector, listening on port 4317
- `JAEGER_TRACE_ENDPOINT` - URL of the Jaeger web UI, listening on port 16686
- `JAEGER_HEALTH_END_POINT` - URL of the Jaeger health end point, listening on port 14269
- `CosmosDbEndpoint` - URL of the cosmos database
- `CosmosDbKey` - shared key used to connect to the cosmos database
- `ServiceBusQueueName` - service bus queue name, which should always be `processing-status-cosmos-db-queue`
Expand Down
7 changes: 0 additions & 7 deletions processing-status-api-function-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ dependencies {
implementation 'com.microsoft.azure:applicationinsights-core:3.4.19'
implementation 'com.azure:azure-cosmos:4.55.0'
implementation "com.fasterxml.jackson.module:jackson-module-kotlin:2.14.2"
implementation 'io.opentelemetry:opentelemetry-api:1.29.0'
implementation 'io.opentelemetry:opentelemetry-sdk:1.29.0'
implementation 'io.opentelemetry:opentelemetry-exporter-logging:1.29.0'
implementation 'io.opentelemetry:opentelemetry-exporter-otlp:1.29.0'
implementation 'io.opentelemetry:opentelemetry-semconv:1.29.0-alpha'
implementation 'com.google.code.gson:gson:2.10.1'
implementation group: 'io.github.microutils', name: 'kotlin-logging-jvm', version: '3.0.5'
implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.36'
Expand All @@ -55,8 +50,6 @@ dependencies {
implementation 'org.owasp.encoder:encoder:1.2.3'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.3.1'

agent "io.opentelemetry.javaagent:opentelemetry-javaagent:1.29.0"

testImplementation("org.mockito.kotlin:mockito-kotlin:4.0.0")
testImplementation "org.testng:testng:7.4.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Jun 07 10:39:15 EDT 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
networkTimeout=10000
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
import gov.cdc.ocio.processingstatusapi.functions.status.GetUploadStatusFunction;
import gov.cdc.ocio.processingstatusapi.functions.reports.ServiceBusProcessor;
import gov.cdc.ocio.processingstatusapi.functions.status.GetStatusFunction;
import gov.cdc.ocio.processingstatusapi.functions.traces.AddSpanToTraceFunction;
import gov.cdc.ocio.processingstatusapi.functions.traces.CreateTraceFunction;
import gov.cdc.ocio.processingstatusapi.functions.traces.GetSpanFunction;
import gov.cdc.ocio.processingstatusapi.functions.traces.GetTraceFunction;
import gov.cdc.ocio.processingstatusapi.model.DispositionType;
import org.owasp.encoder.Encode;

Expand All @@ -35,72 +31,6 @@ public HttpResponseMessage healthCheck(
return new HealthCheckFunction(request).run();
}

@FunctionName("CreateTrace")
public HttpResponseMessage createTrace(
@HttpTrigger(
name = "req",
methods = {HttpMethod.POST},
route = "trace",
authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request) {
return new CreateTraceFunction(request).create();
}

@FunctionName("TraceStartSpan")
public HttpResponseMessage traceStartSpan(
@HttpTrigger(
name = "req",
methods = {HttpMethod.PUT},
route = "trace/startSpan/{traceId}/{parentSpanId}",
authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request,
@BindingName("traceId") String traceId,
@BindingName("parentSpanId") String parentSpanId) {
return new AddSpanToTraceFunction(request).startSpan(traceId, parentSpanId);
}

@FunctionName("TraceStopSpan")
public HttpResponseMessage traceStopSpan(
@HttpTrigger(
name = "req",
methods = {HttpMethod.PUT},
route = "trace/stopSpan/{traceId}/{spanId}",
authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request,
@BindingName("traceId") String traceId,
@BindingName("spanId") String spanId) {
return new AddSpanToTraceFunction(request).stopSpan(traceId, spanId);
}

@FunctionName("GetTraceByTraceId")
public HttpResponseMessage getTraceByTraceId(
@HttpTrigger(
name = "req",
methods = {HttpMethod.GET},
route = "trace/traceId/{traceId}",
authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request,
@BindingName("traceId") String traceId) {
return new GetTraceFunction(request).withTraceId(traceId);
}

@FunctionName("GetTraceByUploadId")
public HttpResponseMessage getTraceByUploadId(
@HttpTrigger(
name = "req",
methods = {HttpMethod.GET},
route = "trace/uploadId/{uploadId}",
authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request,
@BindingName("uploadId") String uploadId) {
return new GetTraceFunction(request).withUploadId(uploadId);
}

@FunctionName("GetTraceSpan")
public HttpResponseMessage getTraceSpanByUploadIdStageName(
@HttpTrigger(
name = "req",
methods = {HttpMethod.GET},
route = "trace/span",
authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request) {
return new GetSpanFunction(request).withQueryParams();
}

/***
* Process a message from the service bus queue.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import com.microsoft.azure.servicebus.primitives.ServiceBusException
import gov.cdc.ocio.processingstatusapi.cosmos.CosmosClientManager
import gov.cdc.ocio.processingstatusapi.model.CosmosDb
import gov.cdc.ocio.processingstatusapi.model.HealthCheck
import gov.cdc.ocio.processingstatusapi.model.Jaeger
import gov.cdc.ocio.processingstatusapi.model.ServiceBus
import gov.cdc.ocio.processingstatusapi.model.reports.Report
import mu.KotlinLogging
Expand All @@ -33,10 +32,8 @@ class HealthCheckFunction(
fun run(): HttpResponseMessage {
var cosmosDBHealthy = false
var serviceBusHealthy = false
var jaegerHealthy = false
val cosmosDBHealth = CosmosDb()
val serviceBusHealth = ServiceBus()
val jaegerHealth = Jaeger()
val time = measureTimeMillis {
try {
cosmosDBHealthy = isCosmosDBHealthy()
Expand All @@ -54,23 +51,13 @@ class HealthCheckFunction(
logger.error("Azure Service Bus is not healthy: ${ex.message}")
}

try {
jaegerHealthy = isJaegerHealthy()
if(jaegerHealthy){
jaegerHealth.status = "UP"
}
} catch (ex: Exception) {
jaegerHealth.healthIssues = ex.message
logger.error("Jaeger is not healthy: ${ex.message}")
}
}

val result = HealthCheck().apply {
status = if (cosmosDBHealthy && serviceBusHealthy && jaegerHealthy) "UP" else "DOWN"
status = if (cosmosDBHealthy && serviceBusHealthy) "UP" else "DOWN"
totalChecksDuration = formatMillisToHMS(time)
dependencyHealthChecks.add(cosmosDBHealth)
dependencyHealthChecks.add(serviceBusHealth)
dependencyHealthChecks.add(jaegerHealth)
}

if(result.status == "DOWN"){
Expand Down Expand Up @@ -122,14 +109,6 @@ class HealthCheckFunction(
return true
}

private fun isJaegerHealthy(): Boolean {
val healthEndPoint = System.getenv("JAEGER_HEALTH_END_POINT")
logger.info("healthEndPoint: $healthEndPoint")
val response = khttp.get(healthEndPoint)
logger.info("response.statusCode:" + response.statusCode)
return response.statusCode == HttpStatus.OK.value();
}

/**
* Format the time in milliseconds to 00:00:00.000 format.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ class ReportManager {
}

HttpStatus.TOO_MANY_REQUESTS.value() -> {
// See: https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/performance-tips?tabs=trace-net-core#429
// https://learn.microsoft.com/en-us/rest/api/cosmos-db/common-cosmosdb-rest-response-headers
// https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/troubleshoot-request-rate-too-large?tabs=resource-specific
val recommendedDuration = response.responseHeaders["x-ms-retry-after-ms"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import gov.cdc.ocio.processingstatusapi.model.reports.*
import gov.cdc.ocio.processingstatusapi.model.reports.stagereports.HL7Debatch
import gov.cdc.ocio.processingstatusapi.model.reports.stagereports.HL7Redactor
import gov.cdc.ocio.processingstatusapi.model.reports.stagereports.HL7Validation
import gov.cdc.ocio.processingstatusapi.model.traces.*
import gov.cdc.ocio.processingstatusapi.utils.DateUtils
import gov.cdc.ocio.processingstatusapi.utils.JsonUtils
import gov.cdc.ocio.processingstatusapi.utils.PageUtils
Expand Down
Loading

0 comments on commit 35951a7

Please sign in to comment.