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

Fix/542/demo srg ownership #548

Merged
merged 4 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ variables:
BUILD_ID:
value: "1"
description: "Build ID. Please set to 1, 2, 3 or 4."

RELEASE_VERSION: "$BUILD_ID.0.0"
RELEASE_BUILD_VERSION: "$BUILD_ID.0.0-$CI_COMMIT_SHORT_SHA"

STAGE_NAME_STAGING: "staging"
STAGE_NAME_PROD: "prod"
STAGE_NAME: "$STAGE_NAME_STAGING" # default

RELEASE_PRODUCT: "simplenodeservice"
RELEASE_STAGE: "simplenode-gitlab-$STAGE_NAME"

IMAGE_NAME: "$DOCKER_REGISTRY_URL/$RELEASE_PRODUCT"
IMAGE_TAG: "$RELEASE_BUILD_VERSION"
#monaco
MANIFEST_FILE: ./monaco/manifest.yaml
MONACO_IMAGE_VERSION: 2.3.0
#dta and srg
DTA_IMAGE_VERSION: latest
SRG_EVALUATION_SERVICE: "$RELEASE_PRODUCT"
SRG_EVALUATION_SERVICE: "$RELEASE_PRODUCT"
SRG_EVALUATION_STAGE: "$STAGE_NAME_STAGING"
TEST_TIMEFRAME: "5m"

Expand Down Expand Up @@ -55,11 +55,12 @@ workflow:
- echo "BUILD_ID $BUILD_ID is being deployed to $RELEASE_STAGE namespace"
- >
helm upgrade --install $RELEASE_PRODUCT helm/simplenodeservice
--set image="$IMAGE_NAME:$IMAGE_TAG"
--set image="$IMAGE_NAME:$IMAGE_TAG"
--set domain="$INGRESS_DOMAIN"
--set version="$RELEASE_VERSION"
--set version="$RELEASE_VERSION"
--set build_version="$RELEASE_BUILD_VERSION"
--set environment="$RELEASE_STAGE"
--set dt_owner="$RELEASE_PRODUCT-$DEMO_IDENTIFIER"
--namespace "$RELEASE_STAGE" --create-namespace
--wait
- sleep 150
Expand Down Expand Up @@ -104,7 +105,7 @@ Build Image:
DOCKER_DAEMON_OPTIONS: "--insecure-registry=$DOCKER_REGISTRY_URL"
services:
- name: docker:20.10.16-dind
entrypoint: [ "sh", "-c", "dockerd-entrypoint.sh $DOCKER_DAEMON_OPTIONS" ]
entrypoint: ["sh", "-c", "dockerd-entrypoint.sh $DOCKER_DAEMON_OPTIONS"]
before_script:
- until docker info; do sleep 1; done
script:
Expand Down Expand Up @@ -138,17 +139,17 @@ Build Image:
extends: .dt_config_event_common
stage: Deploy Staging
variables:
STAGE_NAME: "$STAGE_NAME_STAGING"
STAGE_NAME: "$STAGE_NAME_STAGING"
needs: ["1-Configure DT Staging - Monaco"]

3-Deploy App Staging:
variables:
STAGE_NAME: "$STAGE_NAME_STAGING"
STAGE_NAME: "$STAGE_NAME_STAGING"
stage: Deploy Staging
needs: ["1-Configure DT Staging - Monaco"]
extends:
- .deployment_common

4-Send DT Deploy Event Staging:
extends: .dt_deployment_event_common
stage: Deploy Staging
Expand Down Expand Up @@ -191,7 +192,6 @@ Validate Release with SRG:
- export LOG_LEVEL=verbose
- dta srg evaluate --service $SRG_EVALUATION_SERVICE --stage $SRG_EVALUATION_STAGE --start-time=$eval_start --end-time=$eval_end --stop-on-failure


1-Configure DT Production - Monaco:
extends:
- .monaco_common
Expand All @@ -212,7 +212,7 @@ Validate Release with SRG:
extends: .dt_config_event_common
stage: Deploy Production
variables:
STAGE_NAME: "$STAGE_NAME_PROD"
STAGE_NAME: "$STAGE_NAME_PROD"
needs: ["1-Configure DT Production - Monaco"]

3-Deploy App Production:
Expand All @@ -227,20 +227,20 @@ Validate Release with SRG:
extends: .dt_deployment_event_common
stage: Deploy Production
variables:
STAGE_NAME: "$STAGE_NAME_PROD"
STAGE_NAME: "$STAGE_NAME_PROD"
needs: ["3-Deploy App Production"]

Cleanup DT Configs - Monaco:
image: dynatrace/dynatrace-configuration-as-code:$MONACO_IMAGE_VERSION
stage: Build and Initialize
script:
- RELEASE_STAGE="simplenode-gitlab-$STAGE_NAME_STAGING"
- sed -e "s/\$RELEASE_STAGE/$RELEASE_STAGE/g" -e "s/\$DEMO_IDENTIFIER/$DEMO_IDENTIFIER/g" -e "s/\$RELEASE_PRODUCT/$RELEASE_PRODUCT/g" ./monaco/delete-app.yaml > ./monaco/delete-app-staging-optimized.yaml
- sed -e "s/\$RELEASE_STAGE/$RELEASE_STAGE/g" -e "s/\$DEMO_IDENTIFIER/$DEMO_IDENTIFIER/g" -e "s/\$RELEASE_PRODUCT/$RELEASE_PRODUCT/g" ./monaco/delete-app.yaml > ./monaco/delete-app-staging-optimized.yaml
- RELEASE_STAGE="simplenode-gitlab-$STAGE_NAME_PROD"
- sed -e "s/\$RELEASE_STAGE/$RELEASE_STAGE/g" -e "s/\$DEMO_IDENTIFIER/$DEMO_IDENTIFIER/g" -e "s/\$RELEASE_PRODUCT/$RELEASE_PRODUCT/g" ./monaco/delete-app.yaml > ./monaco/delete-app-prod-optimized.yaml
- sed -e "s/\$RELEASE_STAGE/$RELEASE_STAGE/g" -e "s/\$DEMO_IDENTIFIER/$DEMO_IDENTIFIER/g" -e "s/\$RELEASE_PRODUCT/$RELEASE_PRODUCT/g" ./monaco/delete-app.yaml > ./monaco/delete-app-prod-optimized.yaml
- MONACO_FEAT_AUTOMATION_RESOURCES=1 monaco delete --manifest $MANIFEST_FILE --file ./monaco/delete-app-prod-optimized.yaml --group production
- MONACO_FEAT_AUTOMATION_RESOURCES=1 monaco delete --manifest $MANIFEST_FILE --file ./monaco/delete-app-staging-optimized.yaml --group staging

- sleep 15 # wait for the deletion to be completed before the dependent configs are deleted
- sed -e "s/\$DEMO_IDENTIFIER/$DEMO_IDENTIFIER/g" ./monaco/delete-infra.yaml > ./monaco/delete-infra-optimized.yaml
- MONACO_FEAT_AUTOMATION_RESOURCES=1 monaco delete --manifest $MANIFEST_FILE --file ./monaco/delete-infra-optimized.yaml --group production
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ configs:
config:
name: "Simplenode Guardian for ACE Demo"
template: srg.json

parameters:
description: "Simplenode Guardian for ACE Demo - created by Monaco"
tags:
Expand All @@ -26,7 +25,7 @@ configs:
warning_dql: 400
# objective - slo - success rate
objective_name_slo_success_rate: "Success Rate"
reference_slo_success_rate: ["app","slo", "slo_success_rate", "name"]
reference_slo_success_rate: ["app", "slo", "slo_success_rate", "name"]
reference_slo_metric_success_rate:
type: compound
format: "func:slo.{{ .reference_slo_success_rate }}"
Expand All @@ -36,7 +35,7 @@ configs:
warning_slo_success_rate: 99
# objective - slo - availability
objective_name_slo_availability: "Availability of Service"
reference_slo_availability: ["app","slo", "slo_availability", "name"]
reference_slo_availability: ["app", "slo", "slo_availability", "name"]
reference_slo_metric_availability:
type: compound
format: "func:slo.{{ .reference_slo_availability }}"
Expand All @@ -50,15 +49,13 @@ configs:
failure_dql_cpu_usage: 0.4
warning_dql_cpu_usage: 0.3
skip: false

# workflow
- id: simplenodeworkflow
config:
name: Simplenode SRG Evaluation
template: wf.json
skip: false

parameters:
parameters:
#wf related
wf_description: "Simplenode Workflow with Guardians by Monaco for demo purposes"
wf_isPrivate: false
Expand All @@ -75,7 +72,7 @@ configs:
configType: app:dynatrace.site.reliability.guardian:guardians
property: id
type: reference
configId: simplenodeguardian
configId: simplenodeguardian
#gitlab related
gitlab_task_description: "Create a Gitlab Issue when SRG fails"
gitlab_url:
Expand All @@ -89,11 +86,26 @@ configs:
name: GITLAB_USERNAME
gitlab_passwd:
type: environment
name: GITLAB_PASSWORD
name: GITLAB_PASSWORD
dt_url:
type: environment
name: DT_TENANT_URL
owner_entity_id: ["app","builtin:ownership.teams", "owner_simplenode_rv_srg_staging", "id"]
# Query service entities
releaseProduct:
type: environment
name: RELEASE_PRODUCT
releaseStage:
type: environment
name: RELEASE_STAGE
dql_service_entities_query:
type: compound
format: |
fetch dt.entity.service
| filter matchesValue(tags,"[Environment]DT_RELEASE_PRODUCT:{{ .releaseProduct }}")
and matchesValue(tags,"[Environment]DT_RELEASE_STAGE:{{ .releaseStage }}")
references:
- releaseProduct
- releaseStage
type:
automation:
resource: workflow
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"type": "event",
"value": {
"eventType": "bizevents",
"query": "event.type == \"guardian.validation.triggered\" AND tag.service==\"{{ .tag_service }}\" AND tag.stage==\"{{ .tag_stage }}\""
"query": "event.type == \"guardian.validation.triggered\" AND tag.service==\"{{ .tag_service }}\" AND tag.stage==\"{{ .tag_stage }}\""
}
},
"uniqueExpression": null
Expand All @@ -41,52 +41,43 @@
},
"predecessors": []
},
"refresh_gitlab_token": {
"action": "dynatrace.automations:http-function",
"conditions": {
"custom": "{{`{{`}} result('evaluate_srg').validation_status == \"fail\" {{`}}`}}",
"states": {
"evaluate_srg": "OK"
}
},
"description": "refresh gitlab token",
"query_service_entities": {
"name": "query_service_entities",
"input": {
"headers": {
"Content-Type": "application/json"
},
"method": "POST",
"url": "{{ .gitlab_url }}/oauth/token",
"payload": "{\"grant_type\": \"password\",\"username\": \"{{ .gitlab_username }}\",\"password\": \"{{ .gitlab_passwd }}\"}"
"query": "{{ .dql_service_entities_query }}"
},
"name": "refresh_gitlab_token",
"action": "dynatrace.automations:execute-dql-query",
"position": {
"x": 1,
"x": 0,
"y": 2
},
"predecessors": [
"evaluate_srg"
]
"conditions": {
"custom": "{{ `{{` }} result(\"evaluate_srg\").validation_status != \"pass\" {{ `}}` }}",
"states": {
"evaluate_srg": "OK"
}
},
"description": "Executes DQL query",
"predecessors": ["evaluate_srg"]
},
"identify_ownership": {
"name": "identify_ownership",
"input": {
"entityIds": "{{ .owner_entity_id }}",
"entityIds": "{{ `{{` }} result(\"query_service_entities\").records[0].id {{ `}}` }}",
"responsibilities": []
},
"action": "dynatrace.ownership:get-ownership-from-entity",
"position": {
"x": 1,
"x": 0,
"y": 3
},
"conditions": {
"states": {
"refresh_gitlab_token": "SUCCESS"
"query_service_entities": "SUCCESS"
}
},
"description": "Retrieves entity and extracts ownership data from it.",
"predecessors": [
"refresh_gitlab_token"
]
"predecessors": ["query_service_entities"]
},
"create_gitlab_issue": {
"action": "dynatrace.automations:http-function",
Expand All @@ -100,21 +91,18 @@
"input": {
"headers": {
"Content-Type": "application/json",
"PRIVATE-TOKEN": "{{`{{`}} result(\"refresh_gitlab_token\").json.access_token {{`}}`}}"
"PRIVATE-TOKEN": "{{ .gitlab_private_token }}"
},
"method": "POST",
"url": "{{ .gitlab_url }}/api/v4/projects/{{`{{`}} result(\"identify_ownership\").owners[0].contactDetails | selectattr('integrationType', 'equalto', 'JIRA') | map(attribute='jira.project') | first() {{`}}`}}/issues",
"payload": "{\n \"title\": \"Site Reliability Guardian validation failed\",\n \"description\": \"For the SRG validation details, go to {{ .dt_url }}/ui/apps/dynatrace.site.reliability.guardian/analysis/{{`{{`}} result(\"evaluate_srg\").guardian_id {{`}}`}}?validationId={{`{{`}} result(\"evaluate_srg\").validation_id {{`}}`}}\"\n}"
"payload": "{\n \"title\": \"Site Reliability Guardian validation failed\",\n \"description\": \"For the SRG validation details, go to {{`{{`}} result(\"evaluate_srg\").validation_url {{`}}`}}\"\n}"
},
"name": "create_gitlab_issue",
"position": {
"x": 1,
"x": 0,
"y": 4
},
"predecessors": [
"identify_ownership"
]
"predecessors": ["identify_ownership"]
}
}

}