Skip to content

Commit a650a6a

Browse files
skip shipping plugin whitelist for now; /unit_api/jobs/stop uses body instead of query params
1 parent e1f8c05 commit a650a6a

File tree

10 files changed

+72
-32
lines changed

10 files changed

+72
-32
lines changed

core/pioreactor/web/static/asset-manifest.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"files": {
33
"main.css": "/static/static/css/main.9c7a48b7.css",
4-
"main.js": "/static/static/js/main.00e6ec24.js",
4+
"main.js": "/static/static/js/main.0d15d7d5.js",
55
"static/media/pioreactor_cloud.webp": "/static/static/media/pioreactor_cloud.b15b29e435797dc69d76.webp",
66
"static/media/roboto-all-500-normal.woff": "/static/static/media/roboto-all-500-normal.0ab669b7a0d19b178f57.woff",
77
"static/media/roboto-all-700-normal.woff": "/static/static/media/roboto-all-700-normal.a457fde362a540fcadff.woff",
@@ -30,10 +30,10 @@
3030
"static/media/roboto-greek-ext-700-normal.woff2": "/static/static/media/roboto-greek-ext-700-normal.bd9854c751441ccc1a70.woff2",
3131
"index.html": "/static/index.html",
3232
"main.9c7a48b7.css.map": "/static/static/css/main.9c7a48b7.css.map",
33-
"main.00e6ec24.js.map": "/static/static/js/main.00e6ec24.js.map"
33+
"main.0d15d7d5.js.map": "/static/static/js/main.0d15d7d5.js.map"
3434
},
3535
"entrypoints": [
3636
"static/css/main.9c7a48b7.css",
37-
"static/js/main.00e6ec24.js"
37+
"static/js/main.0d15d7d5.js"
3838
]
3939
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/static/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Pioreactor"/><link rel="apple-touch-icon" href="/static/logo192.png"/><link rel="manifest" href="/static/manifest.json"/><script defer="defer" src="/static/static/js/main.00e6ec24.js"></script><link href="/static/static/css/main.9c7a48b7.css" rel="stylesheet"></head><body><div id="root"></div></body></html>
1+
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/static/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Pioreactor"/><link rel="apple-touch-icon" href="/static/logo192.png"/><link rel="manifest" href="/static/manifest.json"/><script defer="defer" src="/static/static/js/main.0d15d7d5.js"></script><link href="/static/static/css/main.9c7a48b7.css" rel="stylesheet"></head><body><div id="root"></div></body></html>

core/pioreactor/web/static/static/js/main.00e6ec24.js renamed to core/pioreactor/web/static/static/js/main.0d15d7d5.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/pioreactor/web/static/static/js/main.00e6ec24.js.LICENSE.txt renamed to core/pioreactor/web/static/static/js/main.0d15d7d5.js.LICENSE.txt

File renamed without changes.

core/pioreactor/web/static/static/js/main.00e6ec24.js.map renamed to core/pioreactor/web/static/static/js/main.0d15d7d5.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/pioreactor/web/tasks.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,9 @@ def update_clock(new_time: str) -> bool:
379379
def sync_clock() -> bool:
380380
if whoami.is_testing_env():
381381
return True
382-
r = run(["sudo", "chronyc", "-a", "makestep"])
382+
run(["sudo", "systemctl", "stop", "chrony"])
383+
run(["sudo", "chronyd", "-q"])
384+
r = run(["sudo", "systemctl", "start", "chrony"])
383385
return r.returncode == 0
384386

385387

core/pioreactor/web/unit_api.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,12 @@ def stop_all_jobs() -> DelayedResponseReturnValue:
310310

311311
@unit_api_bp.route("/jobs/stop", methods=["PATCH", "POST"])
312312
def stop_jobs() -> DelayedResponseReturnValue:
313-
job_name = request.args.get("job_name")
314-
experiment = request.args.get("experiment")
315-
job_source = request.args.get("job_source")
316-
job_id = request.args.get("job_id") # note job_id is typically an int, so you might convert it.
313+
json = current_app.get_json(request.data)
314+
315+
job_name = json.get("job_name")
316+
experiment = json.get("experiment")
317+
job_source = json.get("job_source")
318+
job_id = json.get("job_id") # note job_id is typically an int, so you might convert it.
317319

318320
if not any([job_name, experiment, job_source, job_id]):
319321
return abort(400, "No job filter specified")
@@ -535,12 +537,12 @@ def install_plugin() -> DelayedResponseReturnValue:
535537
if os.path.isfile(Path(os.environ["DOT_PIOREACTOR"]) / "DISALLOW_UI_INSTALLS"):
536538
abort(403, "DISALLOW_UI_INSTALLS is present")
537539

538-
allowlist = _load_plugin_allowlist()
539-
if not allowlist:
540-
abort(
541-
403,
542-
"Plugin installs via API are disabled: plugins_allowlist.json missing, empty, or invalid.",
543-
)
540+
# allowlist = _load_plugin_allowlist()
541+
# if not allowlist:
542+
# abort(
543+
# 403,
544+
# "Plugin installs via API are disabled: plugins_allowlist.json missing, empty, or invalid.",
545+
# )
544546

545547
body = current_app.get_json(request.data, type=structs.ArgsOptionsEnvs)
546548

@@ -549,12 +551,12 @@ def install_plugin() -> DelayedResponseReturnValue:
549551
if len(body.args) > 1:
550552
abort(400, "Install one plugin at a time via the API")
551553

552-
requested_plugin = _canonicalize_package_name(body.args[0])
553-
if requested_plugin not in allowlist:
554-
abort(
555-
403,
556-
f"Plugin '{requested_plugin}' is not in the allowlist for API installs.",
557-
)
554+
# requested_plugin = _canonicalize_package_name(body.args[0])
555+
# if requested_plugin not in allowlist:
556+
# abort(
557+
# 403,
558+
# f"Plugin '{requested_plugin}' is not in the allowlist for API installs.",
559+
# )
558560

559561
commands: tuple[str, ...] = ("install",)
560562
commands += tuple(body.args)

frontend/src/Leader.jsx

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,17 @@ function ClusterClockCard({leaderHostname}){
666666
const [updatingClock, setUpdatingClock] = React.useState(false);
667667
const [error, setError] = React.useState(null);
668668
const [timestampLocal, setTimestampLocal] = React.useState(dayjs().local().format('YYYY-MM-DD HH:mm:ss'));
669+
const hasUserEditedTimestamp = React.useRef(false);
670+
671+
const normalizeClockData = (result) => Object.fromEntries(
672+
Object.entries(result || {}).map(([unitName, info]) => {
673+
const baseInfo = info || {};
674+
const clockTimeMs = baseInfo.clock_time
675+
? dayjs.utc(baseInfo.clock_time, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]').local().valueOf()
676+
: null;
677+
return [unitName, { ...baseInfo, clock_time_ms: clockTimeMs }];
678+
})
679+
);
669680

670681
async function fetchBroadcastData() {
671682
try {
@@ -685,7 +696,7 @@ function ClusterClockCard({leaderHostname}){
685696
// Poll for the final result using checkTaskCallback
686697
const finalResult = await checkTaskCallback(broadcastData.result_url_path);
687698

688-
setClockData(finalResult.result);
699+
setClockData(normalizeClockData(finalResult.result));
689700
} catch (err) {
690701
setError(err.message);
691702
console.error(err);
@@ -698,6 +709,28 @@ function ClusterClockCard({leaderHostname}){
698709
fetchBroadcastData();
699710
}, []);
700711

712+
React.useEffect(() => {
713+
const intervalId = setInterval(() => {
714+
setClockData((prev) => {
715+
if (!prev) return prev;
716+
return Object.fromEntries(Object.entries(prev).map(([unitName, info]) => {
717+
if (info?.clock_time_ms == null) return [unitName, info];
718+
return [unitName, { ...info, clock_time_ms: info.clock_time_ms + 1000 }];
719+
}));
720+
});
721+
722+
if (!hasUserEditedTimestamp.current) {
723+
setTimestampLocal((prev) => {
724+
const parsed = dayjs(prev, 'YYYY-MM-DD HH:mm:ss', true);
725+
const baseMs = parsed.isValid() ? parsed.valueOf() : dayjs().local().valueOf();
726+
return dayjs(baseMs + 1000).format('YYYY-MM-DD HH:mm:ss');
727+
});
728+
}
729+
}, 1000);
730+
731+
return () => clearInterval(intervalId);
732+
}, []);
733+
701734

702735
async function handlePostTimestamp() {
703736
setUpdatingClock(true)
@@ -766,7 +799,7 @@ function ClusterClockCard({leaderHostname}){
766799
to={leaderHostname === unitName ? "/leader" : "/pioreactors/" + unitName}
767800
/>
768801
</TableCell>
769-
<TableCell align="right" sx={{padding: "6px 0px"}}>{info?.clock_time ? dayjs.utc(info.clock_time, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]').local().format('MMM D, YYYY HH:mm:ss') : "No data received"}</TableCell>
802+
<TableCell align="right" sx={{padding: "6px 0px"}}>{info?.clock_time_ms ? dayjs(info.clock_time_ms).format('MMM D, YYYY HH:mm:ss') : "No data received"}</TableCell>
770803
</TableRow>
771804
);
772805
})}
@@ -781,7 +814,10 @@ function ClusterClockCard({leaderHostname}){
781814
variant="outlined"
782815
label="Timestamp (localtime)"
783816
value={timestampLocal}
784-
onChange={(e) => setTimestampLocal(e.target.value)}
817+
onChange={(e) => {
818+
setTimestampLocal(e.target.value);
819+
hasUserEditedTimestamp.current = true;
820+
}}
785821
/>
786822
<LoadingButton
787823
variant="text"

frontend/src/providers/RunningProfilesContext.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ export function RunningProfilesProvider({ children, experiment }) {
5757
const stopProfile = React.useCallback(
5858
async (job_id) => {
5959
try {
60-
const response = await fetch(`/unit_api/jobs/stop?job_id=${job_id}`, {
60+
const response = await fetch(`/unit_api/jobs/stop`, {
6161
method: 'PATCH',
62-
body: JSON.stringify({ settings: { $state: 'disconnected' } }),
62+
body: JSON.stringify({ job_id: job_id }),
6363
headers: {
6464
Accept: 'application/json',
6565
'Content-Type': 'application/json'

scripts/pioreactor_agent_smoke_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ check_experiment_scoping() {
596596

597597
sleep 2
598598

599-
if curl -fsS -X PATCH -H "Content-Type: application/json" -d '{"experiment":"exp2"}' http://localhost/unit_api/jobs/stop/all >/dev/null; then
599+
if curl -fsS -X PATCH -H "Content-Type: application/json" -d '{"experiment":"exp2"}' http://localhost/unit_api/jobs/stop >/dev/null; then
600600
ok "stopped jobs in exp2"
601601
else
602602
fail "stop jobs exp2 failed"

0 commit comments

Comments
 (0)