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

Do not poll jobs from dashboard if jobs are disabled #5761

Merged
merged 6 commits into from
Oct 11, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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
3 changes: 2 additions & 1 deletion CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
-

### Fixed
-
- Jobs status is no longer polled if jobs are not enabled, avoiding backend logging spam [#5761](https://github.com/scalableminds/webknossos/pull/5761)


### Removed
-
Expand Down
5 changes: 4 additions & 1 deletion app/controllers/JobsController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ import oxalis.telemetry.SlackNotificationService
import play.api.i18n.Messages
import play.api.libs.json._
import play.api.mvc.{Action, AnyContent}
import utils.ObjectId
import utils.{ObjectId, WkConf}

import scala.concurrent.ExecutionContext

class JobsController @Inject()(jobDAO: JobDAO,
sil: Silhouette[WkEnv],
jobService: JobService,
wkconf: WkConf,
slackNotificationService: SlackNotificationService,
organizationDAO: OrganizationDAO)(implicit ec: ExecutionContext)
extends Controller {
Expand All @@ -38,6 +39,7 @@ class JobsController @Inject()(jobDAO: JobDAO,

def list: Action[AnyContent] = sil.SecuredAction.async { implicit request =>
for {
_ <- bool2Fox(wkconf.Features.jobsEnabled) ?~> "job.disabled"
_ <- jobService.updateCeleryInfos()
jobs <- jobDAO.findAll
jobsJsonList <- Fox.serialCombined(jobs.sortBy(-_.created))(jobService.publicWrites)
Expand All @@ -46,6 +48,7 @@ class JobsController @Inject()(jobDAO: JobDAO,

def get(id: String): Action[AnyContent] = sil.SecuredAction.async { implicit request =>
for {
_ <- bool2Fox(wkconf.Features.jobsEnabled) ?~> "job.disabled"
_ <- jobService.updateCeleryInfos()
job <- jobDAO.findOne(ObjectId(id))
js <- jobService.publicWrites(job)
Expand Down
2 changes: 1 addition & 1 deletion app/models/job/Job.scala
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ class JobService @Inject()(wkConf: WkConf,

def runJob(command: String, commandArgs: JsObject, owner: User): Fox[Job] =
for {
_ <- bool2Fox(wkConf.Features.jobsEnabled) ?~> "jobs.disabled"
_ <- bool2Fox(wkConf.Features.jobsEnabled) ?~> "job.disabled"
argsWrapped = Json.obj("kwargs" -> commandArgs)
result <- flowerRpc(s"/api/task/async-apply/tasks.$command")
.postWithJsonResponse[JsValue, Map[String, JsValue]](argsWrapped)
Expand Down
17 changes: 12 additions & 5 deletions frontend/javascripts/dashboard/dataset_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
HourglassOutlined,
} from "@ant-design/icons";
import { PropTypes } from "@scalableminds/prop-types";
import useInterval from "@use-it/interval";

import type { APIJob, APIUser } from "types/api_flow_types";
import { OptionCard } from "admin/onboarding";
Expand Down Expand Up @@ -83,7 +82,9 @@ function DatasetView(props: Props) {
if (state.datasetFilteringMode != null) {
setDatasetFilteringMode(state.datasetFilteringMode);
}
getJobs().then(newJobs => setJobs(newJobs));
if (features().jobsEnabled) {
getJobs().then(newJobs => setJobs(newJobs));
}
context.fetchDatasets({
applyUpdatePredicate: _newDatasets => {
// Only update the datasets when there are none currently.
Expand All @@ -98,9 +99,15 @@ function DatasetView(props: Props) {
});
}, []);

useInterval(() => {
getJobs().then(newJobs => setJobs(newJobs));
}, CONVERSION_JOBS_REFRESH_INTERVAL);
useEffect(() => {
let interval = null;
if (features().jobsEnabled) {
interval = setInterval(() => {
getJobs().then(newJobs => setJobs(newJobs));
}, CONVERSION_JOBS_REFRESH_INTERVAL);
}
return () => (interval != null ? clearInterval(interval) : undefined);
}, []);

useEffect(() => {
persistence.persist(history, {
Expand Down
2 changes: 1 addition & 1 deletion tools/postgres/diff_schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function initTmpDB() {
.toString()
.trim(); // "trim" to remove the line break
if (dbName !== tempDbName) {
console.log("Wrong dbName");
console.log("Wrong temporary dbName, got", dbName, "expected", tempDbName);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This slipped in here, it’s a small addition to the logging for debugging the diff schema script in production

process.exit(1);
}
const dbHost = execSync(scriptdir + "/db_host.sh", { env: { POSTGRES_URL: postgresUrl } })
Expand Down