-
Notifications
You must be signed in to change notification settings - Fork 31
Support deployment_config/working_dir value #356
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
base: main
Are you sure you want to change the base?
Changes from all commits
393f902
a254a36
6f88fba
d78fca5
36e549c
3ef7843
875a710
afe9c25
84b46af
5af9455
5bed47f
e74176a
04fe95e
71264de
ba851bb
48a1f65
c48cf0b
0af6e77
fc60ca6
f49fd5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,14 @@ | ||
| exports_files(["hedron_compile_commands_env_vars.patch"]) | ||
| # ******************************************************************************* | ||
| # Copyright (c) 2026 Contributors to the Eclipse Foundation | ||
| # | ||
| # See the NOTICE file(s) distributed with this work for additional | ||
| # information regarding copyright ownership. | ||
| # | ||
| # This program and the accompanying materials are made available under the | ||
| # terms of the Apache License Version 2.0 which is available at | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # ******************************************************************************* | ||
|
|
||
| exports_files(["score_bazel_tools.patch"]) | ||
|
|
||
| exports_files(["score_bazel_tools_python.patch"]) | ||
| exports_files(glob(["*.patch"])) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ | |
| script_dir.parent.parent | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think because this file is referenced like this I wonder if the bazel test might not recognise cache misses correctly 🤔. I also don't like storing all of the location of these files as these variables. I think we can use pytest args and make a custom conftest.py so that the location of this is taken from the args of the pytest command. I tested this idea out with this patch and the test passes, do you think it would make sense to do it this way? |
||
| / "score" | ||
| / "launch_manager" | ||
| / "src" | ||
| / "daemon" | ||
| / "src" | ||
| / "configuration" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,6 @@ | |
| "shutdown_timeout": 0.5, | ||
| "environmental_variables": {}, | ||
| "bin_dir": "/opt", | ||
| "working_dir": "/tmp", | ||
| "ready_recovery_action": { | ||
| "restart": { | ||
| "number_of_attempts": 0, | ||
|
|
@@ -108,6 +107,14 @@ def get_recovery_process_group_state(config): | |
| def sec_to_ms(sec: float) -> int: | ||
| return int(sec * 1000) | ||
|
|
||
| def get_working_dir(deployment_config): | ||
| """ | ||
| Get the working directory for a component. If not specified, default to the bin_dir. | ||
| """ | ||
| return deployment_config.get( | ||
| "working_dir", deployment_config["bin_dir"] | ||
| ) | ||
|
|
||
|
|
||
| def preprocess_defaults(global_defaults, config): | ||
| """ | ||
|
|
@@ -185,9 +192,13 @@ def dict_merge_recursive(dict_a, dict_b): | |
| merged_defaults["watchdog"], config.get("watchdog", {}) | ||
| ) | ||
|
|
||
| new_config["initial_run_target"] = config.get( | ||
| "initial_run_target", merged_defaults["initial_run_target"] | ||
| ) | ||
| # Only emit initial_run_target when it can be derived from the input config | ||
| # or the defaults. This keeps preprocess_defaults usable with minimal | ||
| # defaults that don't define run-target keys. | ||
| if "initial_run_target" in config or "initial_run_target" in merged_defaults: | ||
| new_config["initial_run_target"] = config.get( | ||
| "initial_run_target", merged_defaults.get("initial_run_target") | ||
| ) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this change it redundant. There is a validation that ensures that initial_run_target must always be defined (to Startup state) |
||
|
|
||
| if "fallback_run_target" in config: | ||
| fallback_defaults = { | ||
|
|
@@ -289,7 +300,9 @@ def gen_config(output_dir, config, input_filename, schema_version=None): | |
| "ready_timeout": depl_cfg["ready_timeout"], | ||
| "shutdown_timeout": depl_cfg["shutdown_timeout"], | ||
| "bin_dir": depl_cfg["bin_dir"], | ||
| "working_dir": depl_cfg["working_dir"], | ||
| # Default the working directory to bin_dir (the directory the | ||
| # executable lives in) when not set explicitly. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you update the user docs to inform of the default value https://eclipse-score.github.io/lifecycle/main/score/launch_manager/docs/user_guide/configuration.html#deployment-config-object |
||
| "working_dir": get_working_dir(depl_cfg), | ||
| "sandbox": sandbox_out, | ||
| } | ||
|
|
||
|
|
@@ -668,6 +681,7 @@ def get_terminating_behavior(component_config): | |
| process["number_of_restart_attempts"] = component_config["deployment_config"][ | ||
| "ready_recovery_action" | ||
| ]["restart"]["number_of_attempts"] | ||
| process["working_dir"] = get_working_dir(component_config["deployment_config"]) | ||
|
|
||
| match component_config["component_properties"]["application_profile"][ | ||
| "application_type" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| # ******************************************************************************* | ||
| # Copyright (c) 2026 Contributors to the Eclipse Foundation | ||
| # | ||
| # See the NOTICE file(s) distributed with this work for additional | ||
| # information regarding copyright ownership. | ||
| # | ||
| # This program and the accompanying materials are made available under the | ||
| # terms of the Apache License Version 2.0 which is available at | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # ******************************************************************************* | ||
| load("@rules_cc//cc:defs.bzl", "cc_binary") | ||
| load("//tests/utils/bazel:integration.bzl", "integration_test") | ||
|
|
||
| cc_binary( | ||
| name = "control_daemon_mock", | ||
| srcs = ["control_daemon_mock.cpp"], | ||
| data = [], | ||
| deps = [ | ||
| "//score/launch_manager:control_cc", | ||
| "//score/launch_manager:lifecycle_cc", | ||
| "//tests/utils/test_helper", | ||
| "@googletest//:gtest_main", | ||
| ], | ||
| ) | ||
|
|
||
| # Two binaries are built from the same source. Each verifies the sandbox options passed to it on | ||
| # the command line (see sandbox_options.json), and derives its GTest XML result file name from its | ||
| # own executable name so the results do not collide. | ||
| cc_binary( | ||
| name = "sandbox_options_process_a", | ||
| srcs = ["sandbox_options_process.cpp"], | ||
| deps = [ | ||
| "//score/launch_manager:control_cc", | ||
| "//score/launch_manager:lifecycle_cc", | ||
| "//tests/utils/test_helper", | ||
| "@googletest//:gtest_main", | ||
| ], | ||
| ) | ||
|
|
||
| cc_binary( | ||
| name = "sandbox_options_process_b", | ||
| srcs = ["sandbox_options_process.cpp"], | ||
| deps = [ | ||
| "//score/launch_manager:control_cc", | ||
| "//score/launch_manager:lifecycle_cc", | ||
| "//tests/utils/test_helper", | ||
| "@googletest//:gtest_main", | ||
| ], | ||
| ) | ||
|
|
||
| integration_test( | ||
| name = "sandbox_options", | ||
| srcs = ["sandbox_options.py"], | ||
| binaries = [ | ||
| ":control_daemon_mock", | ||
| ":sandbox_options_process_a", | ||
| ":sandbox_options_process_b", | ||
| "//score/launch_manager", | ||
| ], | ||
| config = ":sandbox_options.json", | ||
| ) |
Uh oh!
There was an error while loading. Please reload this page.