Skip to content

Commit 6831098

Browse files
committed
update not working domains to the new domains in zosbase
1 parent cf49efc commit 6831098

File tree

16 files changed

+167
-77
lines changed

16 files changed

+167
-77
lines changed

bootstrap/bootstrap/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ will do a multiple stage bootstrap. Currently this is only two stages:
1919
- Bootstrap is used by [0-initramfs](https://github.com/threefoldtech/0-initramfs/blob/development-zos-v3/packages/modules.sh) to basically add `internet` and `bootstrap` services to the base image
2020
- After internet service is fully started, bootstrap will start to download flists needed for zos node to work properly
2121
- As described above bootstrap run in two stages:
22-
- The first stage is used to update bootstrap itself, and it is done like that to avoid re-building the image if we only changed the bootstrap code. this update is basically done from `tf-autobuilder` repo in the [hub/tf-autobuilder](https://hub.grid.tf/tf-autobuilder) and download the latest bootstrap flist
23-
- For the second stage bootstrap will download the flists for that env. bootstrap cares about `runmode` argument that we pass during the start of the node. for example if we passed `runmode=dev` it will get the the tag `development` under [hub/tf-zos](https://hub.grid.tf/tf-zos) each tag is linked to a sub-directory where all flists for this env exists to be downloaded and installed on the node
22+
- The first stage is used to update bootstrap itself, and it is done like that to avoid re-building the image if we only changed the bootstrap code. this update is basically done from `tf-autobuilder` repo in the [hub/tf-autobuilder](https://hub.threefold.me/tf-autobuilder) and download the latest bootstrap flist
23+
- For the second stage bootstrap will download the flists for that env. bootstrap cares about `runmode` argument that we pass during the start of the node. for example if we passed `runmode=dev` it will get the the tag `development` under [hub/tf-zos](https://hub.threefold.me/tf-zos) each tag is linked to a sub-directory where all flists for this env exists to be downloaded and installed on the node
2424

2525
## Testing in Developer setup
2626

@@ -40,6 +40,6 @@ after:
4040
- internet
4141
```
4242

43-
- remove overlay link under `qemu/overlay `
43+
- remove overlay link under `qemu/overlay`
4444
- create a new link pointing to overlay.custom under zos/qemu `ln -s overlay.custom overlay`
4545
- boot your vm as normal

bootstrap/bootstrap/src/hub.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::fs::{write, OpenOptions};
66
use std::io::copy;
77
use std::path::Path;
88

9-
const HUB: &str = "https://hub.grid.tf";
9+
const HUB: &str = "https://hub.threefold.me";
1010

1111
pub struct Repo {
1212
name: String,
@@ -172,7 +172,7 @@ mod tests {
172172
let flist = repo.get("test.flist")?;
173173
assert_eq!(flist.name, "test.flist");
174174
assert_eq!(flist.kind, Kind::Regular);
175-
assert_eq!(flist.url, "https://hub.grid.tf/azmy/test.flist");
175+
assert_eq!(flist.url, "https://hub.threefold.me/azmy/test.flist");
176176

177177
Ok(())
178178
}
@@ -227,7 +227,7 @@ mod tests {
227227

228228
let found = found.unwrap();
229229
assert_eq!(found.name, "test.flist");
230-
assert_eq!(found.url, "https://hub.grid.tf/azmy/test.flist");
230+
assert_eq!(found.url, "https://hub.threefold.me/azmy/test.flist");
231231

232232
Ok(())
233233
}

pkg/container/README.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,43 +14,43 @@ the container rootfs
1414
package main
1515

1616
import (
17-
"github.com/threefoldtech/zbus"
18-
"github.com/threefoldtech/zosbase/pkg"
19-
"github.com/threefoldtech/zosbase/pkg/stubs"
17+
"github.com/threefoldtech/zbus"
18+
"github.com/threefoldtech/zosbase/pkg"
19+
"github.com/threefoldtech/zosbase/pkg/stubs"
2020
)
2121

2222
func main() {
23-
client, err := zbus.NewRedisClient("tcp://localhost:6379")
24-
if err != nil {
25-
panic(client)
26-
}
23+
client, err := zbus.NewRedisClient("tcp://localhost:6379")
24+
if err != nil {
25+
panic(client)
26+
}
2727

28-
containerd := stubs.NewContainerModuleStub(client)
29-
namespace := "example"
28+
containerd := stubs.NewContainerModuleStub(client)
29+
namespace := "example"
3030

31-
// make sure u have a network namespace ready using ip
32-
// sudo ip netns add mynetns
31+
// make sure u have a network namespace ready using ip
32+
// sudo ip netns add mynetns
3333

34-
info := pkg.Container{
35-
Name: "test",
36-
FList: "https://hub.grid.tf/thabet/redis.flist",
37-
Env: []string{},
38-
Network: pkg.NetworkInfo{Namespace: "mynetns"},
39-
Mounts: nil,
40-
Entrypoint: "redis-server",
41-
}
34+
info := pkg.Container{
35+
Name: "test",
36+
FList: "https://hub.threefold.me/thabet/redis.flist",
37+
Env: []string{},
38+
Network: pkg.NetworkInfo{Namespace: "mynetns"},
39+
Mounts: nil,
40+
Entrypoint: "redis-server",
41+
}
4242

43-
id, err := containerd.Run(namespace, info)
43+
id, err := containerd.Run(namespace, info)
4444

45-
if err != nil {
46-
panic(err)
47-
}
45+
if err != nil {
46+
panic(err)
47+
}
4848

49-
// DO WORK WITH CONTAINER ...
49+
// DO WORK WITH CONTAINER ...
5050

51-
if err = containerd.Delete(namespace, id); err != nil {
52-
panic(err)
53-
}
51+
if err = containerd.Delete(namespace, id); err != nil {
52+
panic(err)
53+
}
5454

5555
}
5656
```

pkg/environment/environment.go

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package environment
22

33
import (
4+
"net/http"
45
"os"
56
"slices"
67
"strconv"
@@ -16,6 +17,10 @@ import (
1617

1718
const (
1819
baseExtendedURL = "https://raw.githubusercontent.com/threefoldtech/zos-config/main/"
20+
hubURL = "https://hub.threefold.me"
21+
v4HubURL = "https://v4.hub.threefold.me"
22+
flistURL = "redis://hub.threefold.me:9900"
23+
v4FlistURL = "redis://v4.hub.threefold.me:9940"
1924
)
2025

2126
// PubMac specify how the mac address of the public nic
@@ -53,6 +58,7 @@ type Environment struct {
5358
GraphQL []string
5459
KycURL string
5560
RegistrarURL string
61+
HubURL string
5662

5763
// private vlan to join
5864
// if set, zos will use this as its priv vlan
@@ -121,7 +127,8 @@ var (
121127
"https://activation.dev.grid.tf/activation/activate",
122128
"https://activation.02.dev.grid.tf/activation/activate",
123129
},
124-
FlistURL: "redis://hub.grid.tf:9900",
130+
FlistURL: flistURL,
131+
HubURL: hubURL,
125132
BinRepo: "tf-zos-v3-bins.dev",
126133
GraphQL: []string{
127134
"https://graphql.dev.grid.tf/graphql",
@@ -145,7 +152,8 @@ var (
145152
"https://activation.test.grid.tf/activation/activate",
146153
"https://activation.02.test.grid.tf/activation/activate",
147154
},
148-
FlistURL: "redis://hub.grid.tf:9900",
155+
FlistURL: flistURL,
156+
HubURL: hubURL,
149157
BinRepo: "tf-zos-v3-bins.test",
150158
GraphQL: []string{
151159
"https://graphql.test.grid.tf/graphql",
@@ -169,7 +177,8 @@ var (
169177
"https://activation.qa.grid.tf/activation/activate",
170178
"https://activation.02.qa.grid.tf/activation/activate",
171179
},
172-
FlistURL: "redis://hub.grid.tf:9900",
180+
FlistURL: flistURL,
181+
HubURL: hubURL,
173182
BinRepo: "tf-zos-v3-bins.qanet",
174183
GraphQL: []string{
175184
"https://graphql.qa.grid.tf/graphql",
@@ -193,16 +202,19 @@ var (
193202
// "wss://relay.02.grid.tf",
194203
},
195204
ActivationURL: []string{
205+
"https://activation.grid.threefold.me/activation/activate",
196206
"https://activation.grid.tf/activation/activate",
197207
"https://activation.02.grid.tf/activation/activate",
198208
},
199-
FlistURL: "redis://hub.grid.tf:9900",
209+
HubURL: hubURL,
210+
FlistURL: flistURL,
200211
BinRepo: "tf-zos-v3-bins",
201212
GraphQL: []string{
213+
"https://graphql.grid.threefold.me/graphql",
202214
"https://graphql.grid.tf/graphql",
203215
"https://graphql.02.grid.tf/graphql",
204216
},
205-
KycURL: "https://kyc.grid.tf",
217+
KycURL: "https://kyc.threefold.me",
206218
RegistrarURL: "https://registrar.prod4.grid.tf",
207219
}
208220
)
@@ -269,10 +281,6 @@ func getEnvironmentFromParams(params kernel.Params) (Environment, error) {
269281
if len(runmode) == 0 {
270282
runmode = string(RunningMain)
271283
}
272-
config, err := GetConfig()
273-
if err != nil {
274-
return env, err
275-
}
276284

277285
switch RunMode(runmode) {
278286
case RunningDev:
@@ -287,6 +295,13 @@ func getEnvironmentFromParams(params kernel.Params) (Environment, error) {
287295
env = envProd
288296
}
289297

298+
config, err := getConfig(env.RunningMode, baseExtendedURL, http.DefaultClient)
299+
if err != nil {
300+
// maybe the node can't reach the internet right now
301+
// this will enforce node to skip config
302+
config = Config{}
303+
}
304+
290305
if substrate, ok := params.Get("substrate"); ok {
291306
if len(substrate) > 0 {
292307
env.SubstrateURL = substrate
@@ -408,9 +423,10 @@ func getEnvironmentFromParams(params kernel.Params) (Environment, error) {
408423
env.BinRepo = e
409424
}
410425

411-
// if the node running v4 chage flisturl to use v4.hub.grid.tf
426+
// if the node running v4 chage flisturl to use v4.hub.threefold.me
412427
if params.IsV4() {
413-
env.FlistURL = "redis://v4.hub.grid.tf:9940"
428+
env.FlistURL = v4FlistURL
429+
env.HubURL = v4HubURL
414430
}
415431

416432
return env, nil

pkg/flist/flist_test.go

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package flist
33
import (
44
"bytes"
55
"context"
6+
"net/url"
67
"os"
78
"os/exec"
89
"path/filepath"
@@ -15,6 +16,7 @@ import (
1516
"github.com/stretchr/testify/mock"
1617
"github.com/stretchr/testify/require"
1718
"github.com/threefoldtech/zosbase/pkg"
19+
"github.com/threefoldtech/zosbase/pkg/environment"
1820
"github.com/threefoldtech/zosbase/pkg/gridtypes"
1921
)
2022

@@ -159,7 +161,10 @@ func TestMountUnmount(t *testing.T) {
159161

160162
sys.On("Mount", "overlay", filepath.Join(root, "mountpoint", name), "overlay", uintptr(syscall.MS_NOATIME), mock.Anything).Return(nil)
161163

162-
mnt, err := flister.mountInNamespace(name, "https://hub.grid.tf/thabet/redis.flist", pkg.DefaultMountOptions, "")
164+
redisFlist, err := url.JoinPath(environment.MustGet().HubURL, "thabet", "redis.flist")
165+
require.NoError(t, err)
166+
167+
mnt, err := flister.mountInNamespace(name, redisFlist, pkg.DefaultMountOptions, "")
163168
require.NoError(t, err)
164169

165170
// Trick flister into thinking that 0-fs has exited
@@ -186,7 +191,10 @@ func TestMountUnmountRO(t *testing.T) {
186191
flist := mock.Anything
187192
sys.On("Mount", flist, filepath.Join(root, "mountpoint", name), "bind", uintptr(syscall.MS_BIND), "").Return(nil)
188193

189-
mnt, err := flister.mountInNamespace(name, "https://hub.grid.tf/thabet/redis.flist", pkg.ReadOnlyMountOptions, "")
194+
redisFlist, err := url.JoinPath(environment.MustGet().HubURL, "thabet", "redis.flist")
195+
require.NoError(t, err)
196+
197+
mnt, err := flister.mountInNamespace(name, redisFlist, pkg.ReadOnlyMountOptions, "")
190198
require.NoError(t, err)
191199

192200
// Trick flister into thinking that 0-fs has exited
@@ -223,11 +231,14 @@ func TestIsolation(t *testing.T) {
223231
name2 := "test2"
224232
sys.On("Mount", "overlay", filepath.Join(root, "mountpoint", name2), "overlay", uintptr(syscall.MS_NOATIME), mock.Anything).Return(nil)
225233

226-
path1, err := flister.mountInNamespace(name1, "https://hub.grid.tf/thabet/redis.flist", pkg.DefaultMountOptions, "")
234+
redisFlist, err := url.JoinPath(environment.MustGet().HubURL, "thabet", "redis.flist")
235+
require.NoError(err)
236+
237+
path1, err := flister.mountInNamespace(name1, redisFlist, pkg.DefaultMountOptions, "")
227238
require.NoError(err)
228239
args1 := cmder.m
229240

230-
path2, err := flister.mountInNamespace(name2, "https://hub.grid.tf/thabet/redis.flist", pkg.DefaultMountOptions, "")
241+
path2, err := flister.mountInNamespace(name2, redisFlist, pkg.DefaultMountOptions, "")
231242
require.NoError(err)
232243
args2 := cmder.m
233244

@@ -246,14 +257,17 @@ func TestDownloadFlist(t *testing.T) {
246257

247258
f := newFlister(root, strg, cmder, sys)
248259

249-
hash1, path1, err := f.downloadFlist("https://hub.grid.tf/thabet/redis.flist", "")
260+
redisFlist, err := url.JoinPath(environment.MustGet().HubURL, "thabet", "redis.flist")
261+
require.NoError(err)
262+
263+
hash1, path1, err := f.downloadFlist(redisFlist, "")
250264
require.NoError(err)
251265

252266
// now corrupt the flist
253267
err = os.Truncate(string(path1), 512)
254268
require.NoError(err)
255269

256-
hash2, path2, err := f.downloadFlist("https://hub.grid.tf/thabet/redis.flist", "")
270+
hash2, path2, err := f.downloadFlist(redisFlist, "")
257271
require.NoError(err)
258272

259273
require.EqualValues(path1, path2)

pkg/gateway/flist.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,29 @@ package gateway
33
import (
44
"context"
55
"fmt"
6+
"net/url"
67
"path/filepath"
78

89
"github.com/pkg/errors"
910
"github.com/threefoldtech/zbus"
1011
"github.com/threefoldtech/zosbase/pkg"
12+
"github.com/threefoldtech/zosbase/pkg/environment"
1113
"github.com/threefoldtech/zosbase/pkg/stubs"
1214
)
1315

14-
const (
15-
flist = "https://hub.grid.tf/tf-autobuilder/traefik-2.9.9.flist"
16-
)
17-
1816
// ensureTraefikBin makes sure traefik flist is mounted.
1917
// TODO: we need to "update" traefik and restart the service
2018
// if new version is available!
2119
func ensureTraefikBin(ctx context.Context, cl zbus.Client) (string, error) {
2220
const bin = "traefik"
2321
flistd := stubs.NewFlisterStub(cl)
22+
23+
env := environment.MustGet()
24+
flist, err := url.JoinPath(env.HubURL, "tf-autobuilder", "traefik-2.9.9.flist")
25+
if err != nil {
26+
return "", errors.Wrap(err, "failed to constract traefik flist url")
27+
}
28+
2429
hash, err := flistd.FlistHash(ctx, flist)
2530
if err != nil {
2631
return "", errors.Wrap(err, "failed to get traefik flist hash")

pkg/gateway_light/flist.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,28 @@ package gateway
33
import (
44
"context"
55
"fmt"
6+
"net/url"
67
"path/filepath"
78

89
"github.com/pkg/errors"
910
"github.com/threefoldtech/zbus"
1011
"github.com/threefoldtech/zosbase/pkg"
12+
"github.com/threefoldtech/zosbase/pkg/environment"
1113
"github.com/threefoldtech/zosbase/pkg/stubs"
1214
)
1315

14-
const (
15-
flist = "https://hub.grid.tf/tf-autobuilder/traefik-2.9.9.flist"
16-
)
17-
1816
// ensureTraefikBin makes sure traefik flist is mounted.
1917
// TODO: we need to "update" traefik and restart the service
2018
// if new version is available!
2119
func ensureTraefikBin(ctx context.Context, cl zbus.Client) (string, error) {
2220
const bin = "traefik"
2321
flistd := stubs.NewFlisterStub(cl)
22+
23+
env := environment.MustGet()
24+
flist, err := url.JoinPath(env.HubURL, "tf-autobuilder", "traefik-2.9.9.flist")
25+
if err != nil {
26+
return "", errors.Wrap(err, "failed to construct traefik flist url")
27+
}
2428
hash, err := flistd.FlistHash(ctx, flist)
2529
if err != nil {
2630
return "", errors.Wrap(err, "failed to get traefik flist hash")

pkg/geoip/geoip.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type Location struct {
2020
}
2121

2222
var (
23-
geoipURLs = []string{"https://geoip.grid.tf/", "https://02.geoip.grid.tf/", "https://03.geoip.grid.tf/"}
23+
geoipURLs = []string{"https://geoip.threefold.me/", "https://geoip.grid.tf/", "https://02.geoip.grid.tf/", "https://03.geoip.grid.tf/"}
2424

2525
defaultHTTPClient = retryablehttp.NewClient()
2626
)

0 commit comments

Comments
 (0)