Skip to content

Commit 141cd55

Browse files
committed
Separation of Status and Orch API
The main improvements and fixes are: 1) The Status and Orch API were separated into two services. 2) A fix for the entry point for the render driver. Signed-off-by: Anton Kremenetsky <anton.kremenetsky@gmail.com>
1 parent 9bbde7a commit 141cd55

15 files changed

Lines changed: 286 additions & 90 deletions

File tree

etc/genesis_universal_agent/genesis_universal_agent.conf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ debug = True
44

55
[universal_agent]
66
orch_endpoint = http://localhost:11011
7-
status_endpoint = http://localhost:11011
7+
status_endpoint = http://localhost:11012
88
caps_drivers = CoreCapabilityDriver
99

1010

1111
[CoreCapabilityDriver]
1212
username = admin
1313
password = admin
1414
user_api_base_url = http://localhost:11010
15+
project_id = 12345678-c625-4fee-81d5-f691897b8142

etc/systemd/gc-status-api.service

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[Unit]
2+
Description=Genesis Core Status API
3+
After=network-online.target
4+
5+
[Service]
6+
TimeoutStopSec=5
7+
Restart=on-failure
8+
RestartSec=5s
9+
KillSignal=SIGINT
10+
ExecStartPre=/bin/sleep 2
11+
ExecStart=gc-status-api --config-file /etc/genesis_core/genesis_core.conf
12+
13+
[Install]
14+
WantedBy=multi-user.target

genesis/images/install.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,18 @@ deactivate
9393
# Create links to venv
9494
sudo ln -sf "$VENV_PATH/bin/gc-user-api" "/usr/bin/gc-user-api"
9595
sudo ln -sf "$VENV_PATH/bin/gc-orch-api" "/usr/bin/gc-orch-api"
96+
sudo ln -sf "$VENV_PATH/bin/gc-status-api" "/usr/bin/gc-status-api"
9697
sudo ln -sf "$VENV_PATH/bin/gc-gservice" "/usr/bin/gc-gservice"
9798
sudo ln -sf "$VENV_PATH/bin/gc-bootstrap" "/usr/bin/gc-bootstrap"
9899
sudo ln -sf "$VENV_PATH/bin/genesis-universal-agent" "/usr/bin/genesis-universal-agent"
99100

100101
# Install Systemd service files
101102
sudo cp "$GC_PATH/etc/systemd/gc-user-api.service" $SYSTEMD_SERVICE_DIR
102103
sudo cp "$GC_PATH/etc/systemd/gc-orch-api.service" $SYSTEMD_SERVICE_DIR
104+
sudo cp "$GC_PATH/etc/systemd/gc-status-api.service" $SYSTEMD_SERVICE_DIR
103105
sudo cp "$GC_PATH/etc/systemd/gc-gservice.service" $SYSTEMD_SERVICE_DIR
104106
sudo cp "$GC_PATH/etc/systemd/genesis-universal-agent.service" $SYSTEMD_SERVICE_DIR
105107

106108
# Enable genesis core services
107-
sudo systemctl enable gc-user-api gc-orch-api gc-gservice genesis-universal-agent
109+
sudo systemctl enable gc-user-api gc-orch-api gc-status-api \
110+
gc-gservice genesis-universal-agent

genesis_core/agent/universal/driver.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import bazooka
2121

22-
from gcl_sdk.agents.universal.driver import direct
22+
from gcl_sdk.agents.universal.drivers import direct
2323
from gcl_sdk.agents.universal.clients.http import base
2424
from gcl_sdk.agents.universal.clients.backend import rest as back
2525
from gcl_sdk.agents.universal.storage import fs
@@ -42,6 +42,7 @@ def __init__(
4242
self,
4343
username: str,
4444
password: str,
45+
project_id: str,
4546
user_api_base_url: str,
4647
):
4748
http = bazooka.Client()
@@ -54,8 +55,8 @@ def __init__(
5455
)
5556

5657
storage = fs.FileAgentStorage(AGENT_WORK_DIR)
57-
rest_client = back.RestApiBackendClient(
58-
rest_client, self.__collection_map__
58+
rest_client = back.GCRestApiBackendClient(
59+
rest_client, self.__collection_map__, project_id
5960
)
6061

6162
super().__init__(storage=storage, client=rest_client)

genesis_core/cmd/core_agent.py

Lines changed: 0 additions & 67 deletions
This file was deleted.

genesis_core/cmd/orch_api.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import sys
1919

2020
from gcl_looper.services import bjoern_service
21+
from gcl_looper.services import hub
2122
from oslo_config import cfg
2223
from restalchemy.common import config_opts as ra_config_opts
2324
from restalchemy.storage.sql import engines
@@ -81,22 +82,28 @@ def main():
8182
infra_log.configure()
8283
log = logging.getLogger(__name__)
8384

84-
engines.engine_factory.configure_postgresql_factory(CONF)
85+
serv_hub = hub.ProcessHubService()
8586

86-
log.info(
87-
"Start service on %s:%s",
88-
CONF[DOMAIN].bind_host,
89-
CONF[DOMAIN].bind_port,
90-
)
87+
for _ in range(CONF[DOMAIN].workers):
88+
service = bjoern_service.BjoernService(
89+
wsgi_app=app.build_wsgi_application(),
90+
host=CONF[DOMAIN].bind_host,
91+
port=CONF[DOMAIN].bind_port,
92+
bjoern_kwargs=dict(reuse_port=True),
93+
)
9194

92-
service = bjoern_service.BjoernService(
93-
wsgi_app=app.build_wsgi_application(),
94-
host=CONF[DOMAIN].bind_host,
95-
port=CONF[DOMAIN].bind_port,
96-
bjoern_kwargs=dict(reuse_port=True),
97-
)
95+
service.add_setup(
96+
lambda: engines.engine_factory.configure_postgresql_factory(
97+
conf=CONF
98+
)
99+
)
98100

99-
service.start()
101+
serv_hub.add_service(service)
102+
103+
if CONF[DOMAIN].workers > 1:
104+
serv_hub.start()
105+
else:
106+
service.start()
100107

101108
log.info("Bye!!!")
102109

genesis_core/cmd/status_api.py

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# Copyright 2025 Genesis Corporation.
2+
#
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
17+
import logging
18+
import sys
19+
20+
from gcl_looper.services import bjoern_service
21+
from gcl_looper.services import hub
22+
from oslo_config import cfg
23+
from restalchemy.common import config_opts as ra_config_opts
24+
from restalchemy.storage.sql import engines
25+
26+
from genesis_core.status_api.api import app
27+
from genesis_core.common import config
28+
from genesis_core.common import log as infra_log
29+
30+
31+
api_cli_opts = [
32+
cfg.StrOpt(
33+
"bind-host",
34+
default="127.0.0.1",
35+
help="The host IP to bind to",
36+
),
37+
cfg.IntOpt(
38+
"bind-port",
39+
default=11012,
40+
help="The port to bind to",
41+
),
42+
cfg.IntOpt(
43+
"workers",
44+
default=1,
45+
help="How many http servers should be started",
46+
),
47+
]
48+
49+
50+
DOMAIN = "status_api"
51+
52+
CONF = cfg.CONF
53+
CONF.register_cli_opts(api_cli_opts, DOMAIN)
54+
ra_config_opts.register_posgresql_db_opts(CONF)
55+
56+
57+
def main():
58+
# Parse config
59+
config.parse(sys.argv[1:])
60+
61+
# Configure logging
62+
infra_log.configure()
63+
log = logging.getLogger(__name__)
64+
65+
engines.engine_factory.configure_postgresql_factory(CONF)
66+
67+
log.info(
68+
"Start service on %s:%s",
69+
CONF[DOMAIN].bind_host,
70+
CONF[DOMAIN].bind_port,
71+
)
72+
73+
serv_hub = hub.ProcessHubService()
74+
75+
for _ in range(CONF[DOMAIN].workers):
76+
service = bjoern_service.BjoernService(
77+
wsgi_app=app.build_wsgi_application(),
78+
host=CONF[DOMAIN].bind_host,
79+
port=CONF[DOMAIN].bind_port,
80+
bjoern_kwargs=dict(reuse_port=True),
81+
)
82+
83+
service.add_setup(
84+
lambda: engines.engine_factory.configure_postgresql_factory(
85+
conf=CONF
86+
)
87+
)
88+
89+
serv_hub.add_service(service)
90+
91+
if CONF[DOMAIN].workers > 1:
92+
serv_hub.start()
93+
else:
94+
service.start()
95+
96+
log.info("Bye!!!")
97+
98+
99+
if __name__ == "__main__":
100+
main()

genesis_core/orch_api/api/routes.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from restalchemy.api import routes
1818

1919
from gcl_sdk.agents.universal.orch_api import routes as orch_routes
20-
from gcl_sdk.agents.universal.status_api import routes as status_routers
2120
from genesis_core.orch_api.api import controllers
2221

2322

@@ -57,6 +56,4 @@ class ApiEndpointRoute(routes.Route):
5756
boots = routes.route(NetbootRoute)
5857
nodes = routes.route(NodeRoute)
5958
machines = routes.route(MachineRoute)
60-
agents = routes.route(status_routers.UniversalAgentsRoute)
61-
resources = routes.route(status_routers.ResourcesRoute)
62-
orch_agents = routes.route(orch_routes.UniversalAgentsRoute)
59+
agents = routes.route(orch_routes.UniversalAgentsRoute)

genesis_core/status_api/__init__.py

Whitespace-only changes.

genesis_core/status_api/api/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)