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

Added a health check button for Stores. #748

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
27 changes: 27 additions & 0 deletions core/api_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -2610,6 +2610,33 @@ func (c *Core) v2API() *route.Router {

r.OK(store)
})
r.Dispatch("POST /v2/tenants/:uuid/stores/:uuid/test", func(r *route.Request) { // {{{
// if c.IsNotTenantOperator(r, r.Args[1]) {
// return
// }

store, err := c.db.GetStore(r.Args[2])
if err != nil {
r.Fail(route.Oops(err, "Unable to retrieve storage system information"))
return
}

if store == nil || store.TenantUUID != r.Args[1] {
r.Fail(route.NotFound(nil, "No such store"))
return
}

// if _, err = c.db.PauseJob(job.UUID); err != nil {
// r.Fail(route.Oops(err, "Unable to pause job"))
// return
// }
if _, err := c.db.CreateTestStoreTask("system", store); err != nil {
log.Errorf("failed to schedule storage test task (non-critical) for %s (%s): %s",
store.Name, store.UUID, err)
}

r.Success("Testing store")
})
// }}}
r.Dispatch("DELETE /v2/tenants/:uuid/stores/:uuid", func(r *route.Request) { // {{{
if c.IsNotTenantEngineer(r, r.Args[1]) {
Expand Down
2 changes: 2 additions & 0 deletions t/urls
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ system engineer #!/admin/stores/store
system engineer #!/admin/stores/new
system engineer #!/admin/stores/edit
system engineer #!/admin/stores/delete
system engineer #!/admin/stores/test

system engineer #!/admin/policies
system engineer #!/admin/policies/store
Expand All @@ -39,6 +40,7 @@ tenant operator #!/stores/store
tenant engineer #!/stores/new
tenant engineer #!/stores/edit
tenant engineer #!/stores/delete
tenant engineer #!/stores/test

tenant operator #!/policies
tenant operator #!/policies/store
Expand Down
23 changes: 22 additions & 1 deletion web/htdocs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2524,6 +2524,7 @@ <h2>[[= store.name ]][[ if (store.global) { ]]<span class="tag">global</span>[[
|| (!_.admin && AEGIS.is(store.tenant_uuid, 'engineer'))) { ]]
<a class="edit" href="#!/[[= _.admin ? 'admin/' : '' ]]stores/edit:uuid:[[= store.uuid ]]">Edit</a>
<a class="delete" href="#!/[[= _.admin ? 'admin/' : '' ]]stores/delete:uuid:[[= store.uuid ]]">Delete</a>
<a class="edit" href="#!/[[= _.admin ? 'admin/' : '' ]]stores/test:uuid:[[= store.uuid ]]">Test</a>
[[ } ]]
[[ } ]]

Expand Down Expand Up @@ -2780,7 +2781,27 @@ <h2>Delete The <em>[[= h(_.store.name) ]]</em> Cloud Storage System?</h2>
<button class="danger" rel="yes">Yes, Delete It</button>
</div>
</div>
<!-- }}} --></script>
<!-- }}} --></script><script type="text/html" id="template:stores-test"><!-- {{{ -->
[[#
{stores-test}

A modal interaction screen that requires the operator to acknowledge
that what they are about to do is in fact to test a storage system, that it
might be dangerous, and it might not work out.
]]
<div class="confirm">
<h2>Test The <em>[[= h(_.store.name) ]]</em> Cloud Storage System?</h2>
<p>You have requested that SHIELD perform a health check for
the cloud storage system "[[= h(_.store.name) ]]"</p>

<p class="q">Are you sure you want to test <em>[[= h(_.store.name) ]]</em>?</p>

<div class="a">
<button class="closes danger" rel="close">No, Cancel This Operation</button>
<button class="closes safe" rel="yes">Yes, Initiate Test</button>
</div>
</div>
<!-- }}} --></script>

<script type="text/html" id="template:tenants"><!-- {{{ -->
[[#
Expand Down
37 changes: 37 additions & 0 deletions web/htdocs/js/shield.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,43 @@ function dispatch(page) {

break; /* #!/stores/edit */
// }}}
case '#!/stores/test': /* {{{ */
if (!AEGIS.current) {
$('#main').template('you-have-no-tenants');
break;
}
api({
type: 'GET',
url: '/v2/tenants/'+AEGIS.current.uuid+'/stores/'+args.uuid,
error: "Failed to retrieve storage system information from the SHIELD API.",
success: function (store) {
modal($($.template('stores-test', { store: store }))
.on('click', '[rel="yes"]', function (event) {
event.preventDefault();
api({
type: 'POST',
url: '/v2/tenants/'+AEGIS.current.uuid+'/stores/'+args.uuid+'/test',
complete: function () {
modal(true);
},
success: function (event) {
goto('#!/stores/store:uuid:');
banner('Started storage health check.');
},
error: function (event) {
banner('Unable to test the storage system');
}
});
})
.on('click', '[rel="close"]', function (event) {
modal(true);
goto('#!/stores/store:uuid:'+args.uuid);
})
);
}
});
break; /* #!/stores/test */
// // }}}
case '#!/stores/delete': /* {{{ */
if (!AEGIS.current) {
$('#main').template('you-have-no-tenants');
Expand Down