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

feat(jobs): Show hostname of worker assigned to the job #574

Open
wants to merge 1 commit into
base: master
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
1 change: 1 addition & 0 deletions server/core/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type (
Build *Build `gorm:"preload:false" json:"build,omitempty"`
BuildID uint `json:"buildID"`
Timestamp
AssignedWorker string `json:"assignedWorker"`
}

// JobStore defines operations for working with jobs database table.
Expand Down
2 changes: 2 additions & 0 deletions server/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func (s *scheduler) Next(job *core.Job) error {
job.Log = ""
job.StartTime = nil
job.EndTime = nil
job.AssignedWorker = ""
if err := s.saveJob(job); err != nil {
s.logger.Errorf("error saving job %d: %v", job.ID, err.Error())
}
Expand Down Expand Up @@ -282,6 +283,7 @@ func (s *scheduler) startJob(job *core.Job, worker *core.Worker) {
job.Log = ""
job.StartTime = lib.TimeNow()
job.EndTime = nil
job.AssignedWorker = worker.Host.Hostname
if err := s.saveJob(job); err != nil {
s.logger.Errorf("error saving job %d: %v", job.ID, err.Error())
}
Expand Down
9 changes: 5 additions & 4 deletions server/store/job/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ func (s jobStore) Update(job *core.Job) error {
log := []byte(job.Log)

err := s.db.Model(job).Updates(map[string]interface{}{
"status": job.Status,
"start_time": job.StartTime,
"end_time": job.EndTime,
"log": job.Log,
"status": job.Status,
"start_time": job.StartTime,
"end_time": job.EndTime,
"log": job.Log,
"assignedWorker": job.AssignedWorker,
}).Error

if err == nil {
Expand Down
1 change: 1 addition & 0 deletions web/abstruse/src/app/builds/job/job.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ <h2 class="is-link" [routerLink]="['/builds', job?.build?.id]">
<h2>Job #{{ job?.id }}</h2>
</div>
<div class="subheader-right">
<h2>Worker: {{ job?.assignedWorker }}</h2>
<button
type="button"
class="button"
Expand Down
7 changes: 4 additions & 3 deletions web/abstruse/src/app/builds/job/job.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Component, OnInit, OnDestroy, ChangeDetectorRef } from '@angular/core';
import { SocketEvent } from 'src/app/shared/models/socket.model';
import { Job } from '../shared/build.model';
import { ActivatedRoute } from '@angular/router';
Expand Down Expand Up @@ -36,7 +36,8 @@ export class JobComponent implements OnInit, OnDestroy {
private route: ActivatedRoute,
private buildsService: BuildsService,
private dataService: DataService,
private authService: AuthService
private authService: AuthService,
private changeDetector: ChangeDetectorRef
) {
if (!localStorage.getItem(THEME_KEY)) {
localStorage.setItem(THEME_KEY, 'light');
Expand Down Expand Up @@ -93,7 +94,7 @@ export class JobComponent implements OnInit, OnDestroy {
this.buildsService
.restartJob(this.job.id)
.pipe(
finalize(() => (this.job.processing = false)),
finalize(() => { this.findJob(); this.changeDetector.detectChanges(); this.job.processing = false; }),
untilDestroyed(this)
)
.subscribe(
Expand Down
6 changes: 4 additions & 2 deletions web/abstruse/src/app/builds/shared/build.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ export class Job {
public createdAt: Date | null,
public updatedAt: Date | null,
public buildId: number,
public build: Build | null
public build: Build | null,
public assignedWorker: string,
) {
this.time = new TimeService();
this.runningTime = new BehaviorSubject<string>(this.getTimeRunning.time);
Expand Down Expand Up @@ -197,6 +198,7 @@ export function generateJobModel(data: any): Job {
data.createdAt ? new Date(data.createdAt) : null,
data.updatedAt ? new Date(data.updatedAt) : null,
Number(data.buildID),
data.build ? generateBuildModel(data.build) : null
data.build ? generateBuildModel(data.build) : null,
data.assignedWorker
);
}
11 changes: 11 additions & 0 deletions web/abstruse/src/styles/subheader.sass
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ $subheader-height: 70px

.subheader-right

h2
color: $heading-light
text-transform: none
margin-right: 15px
padding-right: 15px
font-weight: $weight-medium
border-right: 1px solid $border-default
display: inline-flex
align-items: center
font-size: 13px

.link
+unselectable
padding: 10px 0
Expand Down