Sandbox Health Check with Atlassian Jira #1597
Quali-Community
started this conversation in
Integrations
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Sandbox Health Check with Atlassian Jira
A Jira integration that also demonstrates a general error handling infrastructure:
This example has several components:
Install the Jira plugin from the Jira marketplace:
https://marketplace.atlassian.com/plugins/com.quali.jira.QualiJiraPlugin/server/overview
Uses the hook setup and teardown scripts.
Repository
Latest Release
README.md
Name
Jira-Integration
Owner
QualiSystemsLab
Type
Script
Category
DevOps
Min. Compatible CloudShell Version
8.1
Total Downloads
(All Releases)
34
Link
2.0.0
(Version / Tag)
TAR / ZIP
2.0.0 (TAR)
2.0.0 (ZIP)
Author
ericrqs
Published On
11/04/2017 05:15 AM
Assets
Jira_Main_Package.zip
[17 KB]
Jira_Support_Domain_Package.zip
[2 KB]
quali_jira_hook.py
[4 KB]
Jira-Integration
This Jira integration has been refactored into a general-purpose error handling infrastructure:
health_check
functionThis example for Jira also includes:
Done
stateHealth check demo
Components
Support
Support
domain, in draggable package Jira_Support_Domain_Package.zipDemo summary
Post Setup Health Check
calledhealth_check_orch_hook_post_setup
(friendly nameRun Health Checks
)Run Health Checks
onManual Health Check Service
.health_check
attached. Most resources with official shells have ahealth_check
driver function.hook_teardown
finds a teardown hook onResource Quarantine Service
and calls itSupport
domainOpen in Quali CloudShell
in the top rightSupport
domainDone
), the Quali web hook moves the resource fromSupport
to its original domain(s), returning it to circulationDemo details
Install the Jira plugin from the Atlassian marketplace, or run a development mode Jira server as described later.
Configure the Jira plugin:
Open the CloudShell blueprint:
One-time setup: Enter Jira server settings:
Reserve the blueprint:
Sandbox based on the blueprint (note: services could be hidden for a non-admin user):
See that the post-Setup health check failed for DUT 2:
End the sandbox:
The resource quarantine service in the sandbox quarantines DUT 2 and calls the Jira quarantine handler service, which creates a new Jira issue:
New issue in Jira:
Click the button provided by the Jira plugin to open the quarantined resource in a debug sandbox:
Access the debug sandbox:
Setting up the Quali custom
Done
transition web hook in Jira:Go to the System section of Administration:
Scroll down to WebHooks under ADVANCED:
Create a WebHook:
Attaching the Quali web hook to Jira
->Done
transitions:Setting up the web hook:
Running the web hook:
Component details
hook_setup, hook_teardown
General-purpose 8.1-compliant Setup and Teardown scripts that execute any hook functions found on
resources and services in the reservation, based on keywords in the name:
Must be attached to any sandbox where hooks will be used. Can safely replace the default
Setup and Teardown.
Jira Auto Health Check Demo and Jira Manual Health Check Demo blueprints
Jira Auto Health Check Demo has
hook_setup
andhook_teardown
attached.Jira Manual Health Check Demo has
Default Sandbox Setup 2.0
andhook_teardown
attached.This means the health checks must be run manually on
Manual Health Check Service
.DUTs
Two abstract resource requests for
Example Model
that will match resourcesDUT 1
andDUT 2
.Example Model
has a scripthealth_check
attached that is hard-coded to fail onDUT 2
.Post Setup Health Check Service
(Blueprint
Jira Auto Health Check Demo
only)Contains a hook
health_check_orch_hook_post_setup
aliased asRun Health Checks
.When included in a blueprint, at the end of Setup it will search for a
health_check
functionon every resource in the reservation and automatically execute any
health_check
found.health_check
is expected to set the live status of the resource, with "Error" indicatinga failure.
Manual Health Check Service
(Blueprint
Jira Manual Health Check Demo
only)Contains a function
Run Health Checks
that searches for ahealth_check
functionon every resource in the reservation and automatically executes any
health_check
found.health_check
is expected to set the live status of the resource, with "Error" indicatinga failure.
Resource Quarantine Service
Contains a hook
quarantine_resources_orch_hook_post_teardown
:Support
domainquarantine_handler
in the namequarantine_handler
with inputs:subject_name
: the name of the resource that was quarantinedblueprint_or_resource
: "RESOURCE"error_details
: the live status name and descriptionoriginal_domains_csv
: comma-separated list of domains the resource has been removed fromsupport_domain
: the support domain where the resource has been quarantined, e.g.Support
Settings:
Support Domain
- the domain where bad resources should be moved, e.g.Support
Live Status Error Regex
- a pattern that indicates a bad live status if found in the live status name or description, default "Error"This service is platform-independent and can be used even without platform-specific handlers.
Blueprint Quarantine Service
(Not used in this demo, may need further work)
Contains a hook
quarantine_blueprint_orch_hook_post_teardown
:Support
domainquarantine_handler
in the namequarantine_handler
with inputs:subject_name
: the name of the resource that was quarantinedblueprint_or_resource
: "BLUEPRINT"error_details
: the error(s) from the Activity feedoriginal_domains_csv
: today, only the current domain where the blueprint ran -- TODOsupport_domain
: the support domain where the blueprint has been quarantined, e.g.Support
Settings:
Support Domain
- the domain where a bad blueprint should be moved, e.g.Support
This service is platform-independent and can be used even without platform-specific handlers.
Jira Quarantine Handler Service
Creates a Jira issue to track a resource or blueprint that has just been quarantined during teardown.
Called by
Resource Quarantine Service
orBlueprint Quarantine Service
hooks, which run during Teardown.Handles all Jira-specific aspects of the quarantine process. The generic
Resource Quarantine Service
and/orBlueprint Quarantine Service
must be added to the blueprint inaddition to
Jira Quarantine Handler Service
.Contains a function
jira_quarantine_handler
with inputs:subject_name
: the name of the resource or blueprint that was quarantinedblueprint_or_resource
: "BLUEPRINT" or "RESOURCE"error_details
: for a blueprint, the error(s) from the Activity feed; for a resource, the live status name and descriptionoriginal_domains_csv
: the domains the item has been removed fromsupport_domain
: the support domain where the item has been quarantined, e.g.Support
Inputs:
Endpoint URL Base
: Jira endpoint URL, e.g.http://localhost:2990/jira
User
: Jira usernamePassword
: Jira passwordJira Project Name
: Jira project where issues should be opened. Can be blank if there is only one project.Issue Type
: issue type to create, e.g. TaskCreates a Jira issue with a specially formatted description:
Note that the Jira quarantine handler doesn't quarantine the resource, it only performs Jira-specific actions in reaction to
the generic quarantine already performed by
Resource Quarantine Service
orBlueprint Quarantine Service
.DebugSandboxWorker blueprint
!!! MUST BE MARKED PUBLIC !!!
Contains a function
CreateSandbox
with inputs:reservation_name
: name of the debug sandbox to createresource_name
: name of the quarantined resource to add to the sandboxduration_in_minutes
: duration of the debug sandbox in minutesuser
: CloudShell owner to set as the owner of the sandboxCreateSandbox
creates an immediate reservation (in theSupport
domain) containing the specified resource and returns the id of this reservation.A third-party tool is expected to:
CreateSandbox
in the worker sandbox using the sandbox API —CreateSandbox
in turn will create the debug sandboxUnquarantineWorker blueprint
!!! MUST BE MARKED PUBLIC !!!
Contains a function
Unquarantine
with inputs:subject_name
: resource or blueprint nameblueprint_or_resource
: "BLUEPRINT" or "RESOURCE"original_domains_csv
: comma-separated list of domains the resource or blueprint should be moved back tosupport_domain
: the domain where the resource or blueprint is currently quarantined, e.g.Support
Unquarantine
moves the resource or blueprint from theSupport
domain to the specified domains.A third-party tool such as Jira is expected to reserve this blueprint and execute
Unquarantine
using the sandbox API.Note that
Unquarantine
actually unquarantines the resource in CloudShell, and is platform-independent.Quali plugin for Jira
Adds a button to the Jira issue page:
Open in Quali CloudShell
Open in Quali CloudShell
:Support
domainSupport
domainCreateSandbox
that creates a debug sandbox containing the resource referenced by the Jira issueSupport
domain)Issue transition web hook
Attached to issue transitions in Jira, e.g.
To Do -> Done
.Must be registered in the Jira GUI according to the screenshots above.
When triggered, it will log in to CloudShell and restore the resource named in the issue
back to its original CloudShell domains, thus returning it to circulation.
Implemented as a Flask-based Python web server.
Edit the top of
quali_jira_hook.py
:Requires a worker blueprint with a name like
UnquarantineWorker
with scriptUnquarantine
attached. This is included in the installable package.Be sure to "Publish" the blueprint, or it can't be used by the sandbox API.
It is recommended to run the web server on the Jira host, listening on 127.0.0.1 only (port 5000).
Start the web hook:
For special situations, set the listening addresses and port according to the Flask documentation.
Development
Support
domain, drag Jira_Main_Package.zip into the portalSupport
domain, drag Jira_Support_Domain_Package.zip into the portal* Please allow 30-60 seconds for manual update changes to take effect.
Eric Rosenquist 11/07/2017 05:35 PM
· 2177 ·
Beta Was this translation helpful? Give feedback.
All reactions