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
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
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_checkfunctionThis example for Jira also includes:
DonestateHealth check demo
Components
SupportSupportdomain, in draggable package Jira_Support_Domain_Package.zipDemo summary
Post Setup Health Checkcalledhealth_check_orch_hook_post_setup(friendly nameRun Health Checks)Run Health ChecksonManual Health Check Service.health_checkattached. Most resources with official shells have ahealth_checkdriver function.hook_teardownfinds a teardown hook onResource Quarantine Serviceand calls itSupportdomainOpen in Quali CloudShellin the top rightSupportdomainDone), the Quali web hook moves the resource fromSupportto 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
Donetransition 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




->Donetransitions: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_setupandhook_teardownattached.Jira Manual Health Check Demo has
Default Sandbox Setup 2.0andhook_teardownattached.This means the health checks must be run manually on
Manual Health Check Service.DUTs
Two abstract resource requests for
Example Modelthat will match resourcesDUT 1andDUT 2.Example Modelhas a scripthealth_checkattached that is hard-coded to fail onDUT 2.Post Setup Health Check Service
(Blueprint
Jira Auto Health Check Demoonly)Contains a hook
health_check_orch_hook_post_setupaliased asRun Health Checks.When included in a blueprint, at the end of Setup it will search for a
health_checkfunctionon every resource in the reservation and automatically execute any
health_checkfound.health_checkis expected to set the live status of the resource, with "Error" indicatinga failure.
Manual Health Check Service
(Blueprint
Jira Manual Health Check Demoonly)Contains a function
Run Health Checksthat searches for ahealth_checkfunctionon every resource in the reservation and automatically executes any
health_checkfound.health_checkis 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:Supportdomainquarantine_handlerin the namequarantine_handlerwith 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.SupportSettings:
Support Domain- the domain where bad resources should be moved, e.g.SupportLive 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:Supportdomainquarantine_handlerin the namequarantine_handlerwith 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.SupportSettings:
Support Domain- the domain where a bad blueprint should be moved, e.g.SupportThis 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 ServiceorBlueprint Quarantine Servicehooks, which run during Teardown.Handles all Jira-specific aspects of the quarantine process. The generic
Resource Quarantine Serviceand/orBlueprint Quarantine Servicemust be added to the blueprint inaddition to
Jira Quarantine Handler Service.Contains a function
jira_quarantine_handlerwith 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.SupportInputs:
Endpoint URL Base: Jira endpoint URL, e.g.http://localhost:2990/jiraUser: 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 ServiceorBlueprint Quarantine Service.DebugSandboxWorker blueprint
!!! MUST BE MARKED PUBLIC !!!
Contains a function
CreateSandboxwith 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 sandboxCreateSandboxcreates an immediate reservation (in theSupportdomain) containing the specified resource and returns the id of this reservation.A third-party tool is expected to:
CreateSandboxin the worker sandbox using the sandbox API —CreateSandboxin turn will create the debug sandboxUnquarantineWorker blueprint
!!! MUST BE MARKED PUBLIC !!!
Contains a function
Unquarantinewith 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.SupportUnquarantinemoves the resource or blueprint from theSupportdomain to the specified domains.A third-party tool such as Jira is expected to reserve this blueprint and execute
Unquarantineusing the sandbox API.Note that
Unquarantineactually unquarantines the resource in CloudShell, and is platform-independent.Quali plugin for Jira
Adds a button to the Jira issue page:
Open in Quali CloudShellOpen in Quali CloudShell:SupportdomainSupportdomainCreateSandboxthat creates a debug sandbox containing the resource referenced by the Jira issueSupportdomain)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
UnquarantineWorkerwith scriptUnquarantineattached. 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
Supportdomain, drag Jira_Main_Package.zip into the portalSupportdomain, 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