Skip to content

Commit 2f8b630

Browse files
committed
Merge branch 'release/11.0b7'
2 parents 8c36ad9 + e250f01 commit 2f8b630

File tree

47 files changed

+1169
-448
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1169
-448
lines changed

.github/workflows/js-sdk.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Gathering deps
1818
run: |
1919
sudo apt-get update
20-
sudo apt-get install -y git python3-pip python3-venv python3-setuptools tmux redis
20+
sudo apt-get install -y git python3-pip python3-venv python3-setuptools tmux redis nginx
2121
sudo pip3 install poetry
2222
sudo poetry run pip3 install pytest
2323
- name: Install
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# 8. add_kwargs_to_3bot_start
2+
3+
Date: 2020-09-27
4+
5+
## Status
6+
7+
Accepted
8+
9+
## Context
10+
11+
Adding packages with kwargs has some limitations and hence kwargs are needed every time start is called not only once when adding package.
12+
13+
## Decision
14+
15+
Add kwargs passed to the package instance that will be saved locally, and can be retrieved everytime the threebot server restarts and starts the package.
16+
17+
## Consequences
18+
19+
Any package that is added with kwargs will save them and hence with every restart of the package, they are reloaded and used in the install of the package.

docs/wiki/tutorials/add_marketplace_chatflow.md

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,34 @@
7070
- And for returning your solution count should append your `{SOLUTION_TYPE}` in the `count_dict` in `count_solutions` method in the same module
7171

7272
## Add app in frontend
73-
- In the frontend, you just need to add your app object in `apps` dict in `packages/marketplace/frontend/App.vue`
74-
```js
75-
{
76-
name: "App Name in frontend",
77-
type: "{SOLUTION_TYPE}",
78-
path: "/{your_app_name}",
79-
meta: { icon: "app_icon" },
80-
}
81-
```
73+
- In the frontend, you just need to add your app object as below in `apps` dict under the section you want to list your app in `packages/marketplace/frontend/data.js`
74+
- If you need to add another section, just create new one in the `SECTIONS` object with the same structure:
75+
```js
76+
"SECTION NAME": {
77+
titleToolTip: "Tooltip shown on hovering on section title in the frontend",
78+
apps: {
79+
// list your applications objects as below structure
80+
"App Name": {
81+
name: "App Name in frontend",
82+
type: "{SOLUTION_TYPE}", // defined in the previous steps
83+
image: "./assets/appImage.png", // add your app image in the assets dir
84+
disable: false, // make it true if you want to hide your app in the marketplace frontend
85+
helpLink: "https://now10.threefold.io/docs", // link to application manual
86+
description: "Description of your application"
87+
},
88+
},
89+
},
90+
```
91+
- If you just need to add your application in an existing section, add a new app object with below structure in the section object you want to list in:
92+
```js
93+
{
94+
"App Name": {
95+
name: "App Name in frontend",
96+
type: "{SOLUTION_TYPE}", // defined in the previous steps
97+
image: "./assets/appImage.png", // add your app image in the assets dir
98+
disable: false, // make it true if you want to hide your app in the marketplace frontend
99+
helpLink: "https://now10.threefold.io/docs", // link to application manual
100+
description: "Description of your application"
101+
},
102+
}
103+
```

examplescripts/minio.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
PASSWORD = "supersecurepassowrd"
1919
network_name = str(uuid.uuid4())
2020
print(f"network name: {network_name}")
21-
BAD_NODES = set([])
21+
BAD_NODES = set(["A7FmQZ72h7FzjkJMGXmzLDFyfyxzitDZYuernGG97nv7"])
2222
UP_FOR = 60 * 20 # number of seconds
2323

2424

@@ -55,6 +55,21 @@ def wait_workload(wid):
5555
workload = zos.workloads.get(wid)
5656

5757

58+
def wait_zdb_workloads(zdb_wids):
59+
# Looks like the workload_id can be set before the namespace
60+
for wid in zdb_wids:
61+
workload = zos.workloads.get(wid)
62+
data = j.data.serializers.json.loads(workload.info.result.data_json)
63+
if workload.info.result.message:
64+
x = workload.info.result.message
65+
raise Exception(f"Failed to initialize ZDB: {x}")
66+
elif data.get("IP") or data.get("IPs"):
67+
return
68+
else:
69+
sleep(1)
70+
continue
71+
72+
5873
def wait_pools(pools):
5974
for pool in pools:
6075
while pool.cus == 0:
@@ -286,6 +301,7 @@ def pick_minio_nodes(nodes):
286301
backup_vol_id = deploy_volume(minio_backup_node.node_id, backup_pool)
287302
zdb_wids = [x.id for x in zdb_workloads]
288303
wait_workloads(zdb_wids)
304+
wait_zdb_workloads(zdb_wids)
289305
wait_workload(tlog_workload.id)
290306
wait_workload(master_vol_id)
291307
wait_workload(backup_vol_id)
@@ -325,6 +341,7 @@ def pick_minio_nodes(nodes):
325341
zdb_new_workloads = deploy_zdbs(zdb_later_nodes, zdb_new_pools)
326342
zdb_new_wids = [x.id for x in zdb_new_workloads]
327343
wait_workloads(zdb_new_wids)
344+
wait_zdb_workloads(zdb_new_wids)
328345
new_namespace_config = get_namespace_config(zdb_new_workloads)
329346

330347
print("Removing three backup storages")

jumpscale/clients/explorer/explorer.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@
1818
from .users import Users
1919
from .workloads import Workloads
2020

21+
from jumpscale.loader import j
22+
23+
24+
def log_request(r, *args, **kwargs):
25+
if j.config.get("EXPLORER_LOGS"):
26+
j.logger.debug(
27+
f"Request {r.request.url} method: {r.request.method} body: {r.request.body} headers: {r.request.headers}"
28+
)
29+
2130

2231
class Explorer(Client):
2332
url = fields.String()
@@ -30,7 +39,7 @@ def __init__(self, url=None, identity_name=None, **kwargs):
3039
else:
3140
self._loaded_identity = identity.get_identity()
3241
self._session = requests.Session()
33-
self._session.hooks = dict(response=raise_for_status)
42+
self._session.hooks = dict(response=[log_request, raise_for_status])
3443

3544
secret = self._loaded_identity.nacl.signing_key.encode(Base64Encoder)
3645
auth = HTTPSignatureAuth(

jumpscale/clients/explorer/models.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class Location(Base):
4242
def __str__(self):
4343
return ",".join([x for x in [self.continent, self.country, self.city] if x])
4444

45+
4546
class Farm(Base):
4647
id = fields.Integer()
4748
threebot_id = fields.Integer()
@@ -55,7 +56,6 @@ class Farm(Base):
5556

5657
def __str__(self):
5758
return " - ".join([x for x in [self.name, str(self.location)] if x])
58-
5959

6060

6161
class WorkloadsAmount(Base):
@@ -250,9 +250,14 @@ class ContainerNetworkConnection(Base):
250250

251251

252252
class ContainerLogsRedis(Base):
253+
# deprecated, please use secret_stdout instead
253254
stdout = fields.String(default="")
255+
# deprecated, please use secret_stderr instead
254256
stderr = fields.String(default="")
255257

258+
secret_stdout = fields.String(default="")
259+
secret_stderr = fields.String(default="")
260+
256261

257262
class ContainerLogs(Base):
258263
type = fields.String(default="")

jumpscale/clients/sendgrid/sendgrid.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
class SendGridClient(Client):
1313
apikey = fields.String()
1414

15-
def __init__(self):
16-
super().__init__()
15+
def __init__(self, *args, **kwargs):
16+
super().__init__(*args, **kwargs)
1717

1818
def build_attachment(self, filepath, typ="application/pdf"):
1919
"""

jumpscale/clients/stellar/stellar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ def transfer(
387387
if asset != "XLM":
388388
assetStr = asset.split(":")
389389
if len(assetStr) != 2:
390-
raise Exception("Wrong asset format should be in format 'assetcode:issuer'")
390+
raise Exception(f"Wrong asset format should be in format 'assetcode:issuer', but received {assetStr}")
391391
asset = assetStr[0]
392392
issuer = assetStr[1]
393393

jumpscale/core/identity/__init__.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
from jumpscale.sals.nettools import get_default_ip_config
1313

1414
DEFAULT_EXPLORER_URLS = {
15-
"mainnet": "https://explorer.grid.tf/api/v1/",
16-
"testnet": "https://explorer.testnet.grid.tf/api/v1/",
17-
"devnet": "https://explorer.devnet.grid.tf/api/v1/",
15+
"mainnet": "https://explorer.grid.tf/api/v1",
16+
"testnet": "https://explorer.testnet.grid.tf/api/v1",
17+
"devnet": "https://explorer.devnet.grid.tf/api/v1",
1818
}
1919

2020
EXPLORER_URLS = js_config.set_default("explorer_api_urls", DEFAULT_EXPLORER_URLS)
@@ -54,6 +54,7 @@ def __init__(
5454
Raises: Input: when params are missing
5555
"""
5656
self._explorer = None
57+
explorer_url = explorer_url.rstrip("/")
5758
super().__init__(
5859
tname=tname, email=email, words=words, explorer_url=explorer_url, _tid=_tid, admins=admins, *args, **kwargs,
5960
)
@@ -108,6 +109,7 @@ def explorer(self):
108109
js_config.set("has_migrated_explorer_url", True)
109110

110111
if self.explorer_url:
112+
self.explorer_url = self.explorer_url.rstrip("/")
111113
self._explorer = ex_factory.get_by_url_and_identity(self.explorer_url, identity_name=self.instance_name)
112114
else:
113115
self._explorer = ex_factory.get_default()
@@ -169,6 +171,11 @@ def register(self, host=None):
169171
self.save()
170172
return tid
171173

174+
def set_default(self):
175+
from jumpscale.loader import j
176+
177+
return j.core.identity.set_default(self.instance_name)
178+
172179

173180
def get_identity():
174181
return IdentityFactory(Identity).me

jumpscale/packages/admin/actors/admin.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,24 @@ def delete_identity(self, identity_instance_name: str) -> str:
116116
def get_developer_options(self) -> str:
117117
test_cert = j.core.config.set_default("TEST_CERT", False)
118118
over_provision = j.core.config.set_default("OVER_PROVISIONING", False)
119-
return j.data.serializers.json.dumps({"data": {"test_cert": test_cert, "over_provision": over_provision}})
119+
explorer_logs = j.core.config.set_default("EXPLORER_LOGS", False)
120+
return j.data.serializers.json.dumps(
121+
{"data": {"test_cert": test_cert, "over_provision": over_provision, "explorer_logs": explorer_logs}}
122+
)
120123

121124
@actor_method
122-
def set_developer_options(self, test_cert: bool, over_provision: bool) -> str:
125+
def set_developer_options(self, test_cert: bool, over_provision: bool, explorer_logs: bool) -> str:
123126
j.core.config.set("TEST_CERT", test_cert)
124127
j.core.config.set("OVER_PROVISIONING", over_provision)
125-
return j.data.serializers.json.dumps({"data": {"test_cert": test_cert, "over_provision": over_provision}})
128+
j.core.config.set("EXPLORER_LOGS", explorer_logs)
129+
return j.data.serializers.json.dumps(
130+
{"data": {"test_cert": test_cert, "over_provision": over_provision, "explorer_logs": explorer_logs}}
131+
)
126132

127133
@actor_method
128134
def clear_blocked_nodes(self) -> str:
129-
j.sals.reservation_chatflow.reservation_chatflow.clear_blocked_nodes()
135+
j.sals.reservation_chatflow.reservation_chatflow.clear_blocked_nodes()
130136
return j.data.serializers.json.dumps({"data": "blocked nodes got cleared successfully."})
131137

138+
132139
Actor = Admin

0 commit comments

Comments
 (0)