Skip to content

Commit

Permalink
better agent health status
Browse files Browse the repository at this point in the history
  • Loading branch information
wpbonelli committed Jul 28, 2021
1 parent cc2acb4 commit 5294262
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 43 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ jobs:
CONFIG: prod
run: |
chmod +x scripts/deploy.sh
# chmod +x scripts/deploy-ssh.sh
# bash scripts/deploy-ssh.sh
eval "$(ssh-agent -s)" # Start ssh-agent cache
chmod 600 ~/.ssh/id_rsa # Allow read access to the private key
Expand Down
33 changes: 10 additions & 23 deletions plantit/front_end/src/components/agents/agent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -125,27 +125,7 @@
: 'text-dark'
"
>
<i
v-if="
!getAgent.disabled
"
class="fas fa-server fa-fw"
></i>
<span
v-b-tooltip:hover
title="Disabled"
class="fa-stack fa-1x m-0 p-0"
v-else
><i
class="fas fa-server fa-stack-1x"
></i
><i
class="fas fa-slash fa-stack-1x text-danger"
></i
><i
class="far fa-circle fa-stack-2x text-danger"
></i
></span>
{{ getAgent.name }}
<i
v-if="
getAgent.is_healthy
Expand All @@ -159,8 +139,15 @@
v-b-tooltip:hover
title="Unhealthy"
class="fas fa-medkit text-danger fa-fw"
></i>
{{ getAgent.name }}
></i><i
v-if="
getAgent.disabled
"
v-b-tooltip:hover
title="Disabled"
class="fas fa-times-circle text-danger fa-fw"
></i
>
</h1>
<b-badge
v-if="
Expand Down
19 changes: 19 additions & 0 deletions plantit/front_end/src/components/agents/agents.vue
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,25 @@
>
{{ agent.name }}
</b-link>
<small>
<i
v-if="agent.is_healthy"
v-b-tooltip:hover
title="Healthy"
class="fas fa-heartbeat text-warning fa-fw"
></i
><i
v-else
v-b-tooltip:hover
title="Unhealthy"
class="fas fa-medkit text-danger fa-fw"
></i
><i
v-if="agent.disabled"
v-b-tooltip:hover
title="Disabled"
class="fas fa-times-circle text-danger fa-fw"
></i></small>
</h2>
<b-badge
v-if="!agent.public"
Expand Down
69 changes: 60 additions & 9 deletions plantit/front_end/src/components/tasks/task.vue
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,10 @@
: 'text-warning'
"
><b>{{
getTask.job_status === 'PENDING' ? 'PENDING' : getTask.status.toUpperCase()
getTask.job_status ===
'PENDING' && !getTask.is_complete
? 'PENDING'
: getTask.status.toUpperCase()
}}</b></b-col
></b-row
>
Expand Down Expand Up @@ -1873,7 +1876,9 @@
:body-bg-variant="profile.darkMode ? 'dark' : 'white'"
:header-border-variant="profile.darkMode ? 'dark' : 'white'"
:footer-border-variant="profile.darkMode ? 'dark' : 'white'"
:title="'Authenticate with ' + this.getTask.agent.name"
:title="
'Authenticate with ' + this.getTask.agent.name + ' to download'
"
@ok="downloadFile"
ok-variant="success"
>
Expand All @@ -1890,6 +1895,36 @@
required
></b-form-input>
</b-modal>
<b-modal
id="authenticate-cancel"
:title-class="profile.darkMode ? 'text-white' : 'text-dark'"
centered
close
:header-text-variant="profile.darkMode ? 'white' : 'dark'"
:header-bg-variant="profile.darkMode ? 'dark' : 'white'"
:footer-bg-variant="profile.darkMode ? 'dark' : 'white'"
:body-bg-variant="profile.darkMode ? 'dark' : 'white'"
:header-border-variant="profile.darkMode ? 'dark' : 'white'"
:footer-border-variant="profile.darkMode ? 'dark' : 'white'"
:title="
'Authenticate with ' + this.getTask.agent.name + ' to cancel'
"
@ok="cancel"
ok-variant="success"
>
<b-form-input
v-model="authenticationUsername"
type="text"
placeholder="Your username"
required
></b-form-input>
<b-form-input
v-model="authenticationPassword"
type="password"
placeholder="Your password"
required
></b-form-input>
</b-modal>
<b-modal
size="lg"
id="transfer"
Expand Down Expand Up @@ -2315,12 +2350,29 @@ export default {
name: this.$router.currentRoute.params.name
});
},
cancel() {
preCancel() {
if (this.mustAuthenticate)
this.$bvModal.show('authenticate-cancel');
else this.cancel();
},
async cancel() {
this.canceled = true;
axios
.get(
`/apis/v1/tasks/${this.$router.currentRoute.params.owner}/${this.$router.currentRoute.params.name}/cancel/`
)
this.$bvModal.hide('authenticate-cancel');
var data = {};
if (this.mustAuthenticate)
data['auth'] = {
username: this.authenticationUsername,
password: this.authenticationPassword
};
else
data['auth'] = {
username: this.getTask.agent.user
};
await axios({
method: 'post',
url: `/apis/v1/tasks/${this.$router.currentRoute.params.owner}/${this.$router.currentRoute.params.name}/cancel/`,
data: data
})
.then(response => {
this.canceled = false;
if (response.status === 200) {
Expand Down Expand Up @@ -2649,8 +2701,7 @@ export default {
taskLogs() {
let all = this.getTask.orchestrator_logs.slice();
var firstI = all.findIndex(l => l.includes('PENDING')) + 1;
if (firstI < 1)
firstI = all.findIndex(l => l.includes('RUNNING'));
if (firstI < 1) firstI = all.findIndex(l => l.includes('RUNNING'));
if (firstI === -1) return all;
all.reverse();
let lastI =
Expand Down
33 changes: 29 additions & 4 deletions plantit/front_end/src/components/workflows/workflow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,10 @@
></template
><b-row>
<b-col>
<b-card-group columns deck>
<b-card-group
columns
deck
>
<b-card
style="min-width: 60rem"
:bg-variant="
Expand Down Expand Up @@ -2558,8 +2561,30 @@
>{{
agent.name
}}</b-button
></b-col
>
>
<i
v-if="
agent.is_healthy
"
v-b-tooltip:hover
title="Healthy"
class="fas fa-heartbeat text-warning fa-fw"
></i
><i
v-else
v-b-tooltip:hover
title="Unhealthy"
class="fas fa-medkit text-danger fa-fw"
></i
><i
v-if="
agent.disabled
"
v-b-tooltip:hover
title="Disabled"
class="fas fa-times-circle text-danger fa-fw"
></i
></b-col>
<b-col
align-self="end"
class="mb-2"
Expand Down Expand Up @@ -4061,7 +4086,7 @@ export default {
}
config.output = this.getWorkflow.config.output;
if (this.getWorkflow.config.logo !== null)
config.logo = this.getWorkflow.config.logo;
config.logo = this.getWorkflow.config.logo;
// save config
this.$store.dispatch('workflows/setRecentlyRun', {
Expand Down
8 changes: 3 additions & 5 deletions plantit/plantit/tasks/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from django.views.decorators.csrf import csrf_exempt

from plantit import settings
from plantit.agents.models import Agent, AgentExecutor
from plantit.agents.models import Agent, AgentExecutor, AgentAuthentication
from plantit.celery_tasks import submit_task
from plantit.redis import RedisClient
from plantit.tasks.models import Task, DelayedTask, RepeatingTask, TaskStatus
Expand Down Expand Up @@ -472,10 +472,8 @@ def cancel(request, owner, name):
if task.agent.executor == AgentExecutor.LOCAL and task.celery_task_id is not None:
AsyncResult(task.celery_task_id).revoke() # cancel the Celery task
else:
# TODO figure out how to handle auth for password agents- should the user have to re-enter auth info to cancel tasks?
# auth = parse_task_auth_options(json.loads(request.body.decode('utf-8'))['auth'])
# cancel_task(task, auth)
pass
auth = parse_task_auth_options(json.loads(request.body.decode('utf-8'))['auth'])
cancel_task(task, auth)

now = timezone.now()
task.status = TaskStatus.CANCELED
Expand Down

0 comments on commit 5294262

Please sign in to comment.