From 667bbe2fc6918e0f8f83a7a171ac6db2e1a462b7 Mon Sep 17 00:00:00 2001 From: Eslam-Nawara Date: Tue, 10 Jun 2025 12:11:17 +0300 Subject: [PATCH 01/19] use urls from zos-config if exists --- pkg/environment/config.go | 9 ++++++++- pkg/environment/environment.go | 30 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/pkg/environment/config.go b/pkg/environment/config.go index 292fd7fc..211784a7 100644 --- a/pkg/environment/config.go +++ b/pkg/environment/config.go @@ -30,7 +30,14 @@ type Config struct { RolloutUpgrade struct { TestFarms []uint32 `json:"test_farms"` } `json:"rollout_upgrade"` - RelaysURLs []string `json:"relays_urls"` + RelaysURLs []string `json:"relays_urls"` + SubstrateURL []string `json:"substrate_urls"` + ActivationURL []string `json:"activation_urls"` + GraphQL []string `json:"graphql_urls"` + KycURL string `json:"kyc_url"` + RegistrarURL string `json:"registrar_url"` + FlistURL string `json:"flist_url"` + BinRepo string `json:"bin_repo"` } // Merge, updates current config with cfg merging and override config diff --git a/pkg/environment/environment.go b/pkg/environment/environment.go index 37498c9d..346ce3f4 100644 --- a/pkg/environment/environment.go +++ b/pkg/environment/environment.go @@ -269,6 +269,10 @@ func getEnvironmentFromParams(params kernel.Params) (Environment, error) { if len(runmode) == 0 { runmode = string(RunningMain) } + config, err := GetConfig() + if err != nil { + return env, err + } switch RunMode(runmode) { case RunningDev: @@ -287,18 +291,44 @@ func getEnvironmentFromParams(params kernel.Params) (Environment, error) { if len(substrate) > 0 { env.SubstrateURL = substrate } + } else if substrate := config.SubstrateURL; len(substrate) > 0 { + env.SubstrateURL = substrate } if relay, ok := params.Get("relay"); ok { if len(relay) > 0 { env.relaysURLs = relay } + } else if relay := config.RelaysURLs; len(relay) > 0 { + env.relaysURLs = relay } if activation, ok := params.Get("activation"); ok { if len(activation) > 0 { env.ActivationURL = activation } + } else if activation := config.ActivationURL; len(activation) > 0 { + env.ActivationURL = activation + } + + if graphql := config.GraphQL; len(graphql) > 0 { + env.GraphQL = graphql + } + + if flist := config.FlistURL; len(flist) > 0 { + env.FlistURL = flist + } + + if bin := config.FlistURL; len(bin) > 0 { + env.FlistURL = bin + } + + if kyc := config.FlistURL; len(kyc) > 0 { + env.FlistURL = kyc + } + + if registrar := config.FlistURL; len(registrar) > 0 { + env.FlistURL = registrar } if farmSecret, ok := params.Get("secret"); ok { From cf49efc8fea14b7bcd13caaeff9fae216756d232 Mon Sep 17 00:00:00 2001 From: Eslam-Nawara Date: Wed, 11 Jun 2025 12:40:06 +0300 Subject: [PATCH 02/19] fix check urls length --- pkg/environment/environment.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/environment/environment.go b/pkg/environment/environment.go index 346ce3f4..caad2023 100644 --- a/pkg/environment/environment.go +++ b/pkg/environment/environment.go @@ -319,15 +319,15 @@ func getEnvironmentFromParams(params kernel.Params) (Environment, error) { env.FlistURL = flist } - if bin := config.FlistURL; len(bin) > 0 { + if bin := config.BinRepo; len(bin) > 0 { env.FlistURL = bin } - if kyc := config.FlistURL; len(kyc) > 0 { + if kyc := config.KycURL; len(kyc) > 0 { env.FlistURL = kyc } - if registrar := config.FlistURL; len(registrar) > 0 { + if registrar := config.RegistrarURL; len(registrar) > 0 { env.FlistURL = registrar } From 2bade3b87213cda7a3a3a081a55b431e0e84ec8f Mon Sep 17 00:00:00 2001 From: Eslam-Nawara Date: Mon, 16 Jun 2025 16:05:29 +0300 Subject: [PATCH 03/19] update not working domains to the new domains in zosbase --- bootstrap/bootstrap/README.md | 6 ++-- bootstrap/bootstrap/src/hub.rs | 6 ++-- pkg/container/README.md | 54 +++++++++++++++++----------------- pkg/environment/environment.go | 40 +++++++++++++++++-------- pkg/flist/flist_test.go | 26 ++++++++++++---- pkg/gateway/flist.go | 13 +++++--- pkg/gateway_light/flist.go | 12 +++++--- pkg/geoip/geoip.go | 2 +- pkg/primitives/vm-light/vm.go | 11 +++++-- pkg/primitives/vm/vm.go | 11 +++++-- pkg/primitives/zdb/zdb.go | 38 ++++++++++++++++++++++-- pkg/qsfsd/qsfs.go | 11 +++++-- pkg/upgrade/README.md | 2 +- pkg/upgrade/hub/hub.go | 8 ++--- scripts/debug_image.md | 4 +-- scripts/debug_image.sh | 2 +- 16 files changed, 168 insertions(+), 78 deletions(-) diff --git a/bootstrap/bootstrap/README.md b/bootstrap/bootstrap/README.md index e36b4bfd..a71c1723 100644 --- a/bootstrap/bootstrap/README.md +++ b/bootstrap/bootstrap/README.md @@ -19,8 +19,8 @@ will do a multiple stage bootstrap. Currently this is only two stages: - 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 - After internet service is fully started, bootstrap will start to download flists needed for zos node to work properly - As described above bootstrap run in two stages: - - 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 - - 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 + - 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 + - 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 ## Testing in Developer setup @@ -40,6 +40,6 @@ after: - internet ``` -- remove overlay link under `qemu/overlay ` +- remove overlay link under `qemu/overlay` - create a new link pointing to overlay.custom under zos/qemu `ln -s overlay.custom overlay` - boot your vm as normal diff --git a/bootstrap/bootstrap/src/hub.rs b/bootstrap/bootstrap/src/hub.rs index e1de1490..21217e32 100644 --- a/bootstrap/bootstrap/src/hub.rs +++ b/bootstrap/bootstrap/src/hub.rs @@ -6,7 +6,7 @@ use std::fs::{write, OpenOptions}; use std::io::copy; use std::path::Path; -const HUB: &str = "https://hub.grid.tf"; +const HUB: &str = "https://hub.threefold.me"; pub struct Repo { name: String, @@ -172,7 +172,7 @@ mod tests { let flist = repo.get("test.flist")?; assert_eq!(flist.name, "test.flist"); assert_eq!(flist.kind, Kind::Regular); - assert_eq!(flist.url, "https://hub.grid.tf/azmy/test.flist"); + assert_eq!(flist.url, "https://hub.threefold.me/azmy/test.flist"); Ok(()) } @@ -227,7 +227,7 @@ mod tests { let found = found.unwrap(); assert_eq!(found.name, "test.flist"); - assert_eq!(found.url, "https://hub.grid.tf/azmy/test.flist"); + assert_eq!(found.url, "https://hub.threefold.me/azmy/test.flist"); Ok(()) } diff --git a/pkg/container/README.md b/pkg/container/README.md index 781e4d59..b06ca64d 100644 --- a/pkg/container/README.md +++ b/pkg/container/README.md @@ -14,43 +14,43 @@ the container rootfs package main import ( - "github.com/threefoldtech/zbus" - "github.com/threefoldtech/zosbase/pkg" - "github.com/threefoldtech/zosbase/pkg/stubs" + "github.com/threefoldtech/zbus" + "github.com/threefoldtech/zosbase/pkg" + "github.com/threefoldtech/zosbase/pkg/stubs" ) func main() { - client, err := zbus.NewRedisClient("tcp://localhost:6379") - if err != nil { - panic(client) - } + client, err := zbus.NewRedisClient("tcp://localhost:6379") + if err != nil { + panic(client) + } - containerd := stubs.NewContainerModuleStub(client) - namespace := "example" + containerd := stubs.NewContainerModuleStub(client) + namespace := "example" - // make sure u have a network namespace ready using ip - // sudo ip netns add mynetns + // make sure u have a network namespace ready using ip + // sudo ip netns add mynetns - info := pkg.Container{ - Name: "test", - FList: "https://hub.grid.tf/thabet/redis.flist", - Env: []string{}, - Network: pkg.NetworkInfo{Namespace: "mynetns"}, - Mounts: nil, - Entrypoint: "redis-server", - } + info := pkg.Container{ + Name: "test", + FList: "https://hub.threefold.me/thabet/redis.flist", + Env: []string{}, + Network: pkg.NetworkInfo{Namespace: "mynetns"}, + Mounts: nil, + Entrypoint: "redis-server", + } - id, err := containerd.Run(namespace, info) + id, err := containerd.Run(namespace, info) - if err != nil { - panic(err) - } + if err != nil { + panic(err) + } - // DO WORK WITH CONTAINER ... + // DO WORK WITH CONTAINER ... - if err = containerd.Delete(namespace, id); err != nil { - panic(err) - } + if err = containerd.Delete(namespace, id); err != nil { + panic(err) + } } ``` diff --git a/pkg/environment/environment.go b/pkg/environment/environment.go index caad2023..62da75ed 100644 --- a/pkg/environment/environment.go +++ b/pkg/environment/environment.go @@ -1,6 +1,7 @@ package environment import ( + "net/http" "os" "slices" "strconv" @@ -16,6 +17,10 @@ import ( const ( baseExtendedURL = "https://raw.githubusercontent.com/threefoldtech/zos-config/main/" + hubURL = "https://hub.threefold.me" + v4HubURL = "https://v4.hub.threefold.me" + flistURL = "redis://hub.threefold.me:9900" + v4FlistURL = "redis://v4.hub.threefold.me:9940" ) // PubMac specify how the mac address of the public nic @@ -53,6 +58,7 @@ type Environment struct { GraphQL []string KycURL string RegistrarURL string + HubURL string // private vlan to join // if set, zos will use this as its priv vlan @@ -121,7 +127,8 @@ var ( "https://activation.dev.grid.tf/activation/activate", "https://activation.02.dev.grid.tf/activation/activate", }, - FlistURL: "redis://hub.grid.tf:9900", + FlistURL: flistURL, + HubURL: hubURL, BinRepo: "tf-zos-v3-bins.dev", GraphQL: []string{ "https://graphql.dev.grid.tf/graphql", @@ -145,7 +152,8 @@ var ( "https://activation.test.grid.tf/activation/activate", "https://activation.02.test.grid.tf/activation/activate", }, - FlistURL: "redis://hub.grid.tf:9900", + FlistURL: flistURL, + HubURL: hubURL, BinRepo: "tf-zos-v3-bins.test", GraphQL: []string{ "https://graphql.test.grid.tf/graphql", @@ -169,7 +177,8 @@ var ( "https://activation.qa.grid.tf/activation/activate", "https://activation.02.qa.grid.tf/activation/activate", }, - FlistURL: "redis://hub.grid.tf:9900", + FlistURL: flistURL, + HubURL: hubURL, BinRepo: "tf-zos-v3-bins.qanet", GraphQL: []string{ "https://graphql.qa.grid.tf/graphql", @@ -193,17 +202,20 @@ var ( // "wss://relay.02.grid.tf", }, ActivationURL: []string{ + "https://activation.grid.threefold.me/activation/activate", "https://activation.grid.tf/activation/activate", "https://activation.02.grid.tf/activation/activate", }, - FlistURL: "redis://hub.grid.tf:9900", + HubURL: hubURL, + FlistURL: flistURL, BinRepo: "tf-zos-v3-bins", GraphQL: []string{ + "https://graphql.grid.threefold.me/graphql", "https://graphql.grid.tf/graphql", "https://graphql.02.grid.tf/graphql", }, - KycURL: "https://kyc.grid.tf", - RegistrarURL: "https://registrar.prod4.grid.tf", + KycURL: "https://kyc.threefold.me", + RegistrarURL: "https://registrar.prod4.threefold.me", } ) @@ -269,10 +281,6 @@ func getEnvironmentFromParams(params kernel.Params) (Environment, error) { if len(runmode) == 0 { runmode = string(RunningMain) } - config, err := GetConfig() - if err != nil { - return env, err - } switch RunMode(runmode) { case RunningDev: @@ -287,6 +295,13 @@ func getEnvironmentFromParams(params kernel.Params) (Environment, error) { env = envProd } + config, err := getConfig(env.RunningMode, baseExtendedURL, http.DefaultClient) + if err != nil { + // maybe the node can't reach the internet right now + // this will enforce node to skip config + config = Config{} + } + if substrate, ok := params.Get("substrate"); ok { if len(substrate) > 0 { env.SubstrateURL = substrate @@ -408,9 +423,10 @@ func getEnvironmentFromParams(params kernel.Params) (Environment, error) { env.BinRepo = e } - // if the node running v4 chage flisturl to use v4.hub.grid.tf + // if the node running v4 chage flisturl to use v4.hub.threefold.me if params.IsV4() { - env.FlistURL = "redis://v4.hub.grid.tf:9940" + env.FlistURL = v4FlistURL + env.HubURL = v4HubURL } return env, nil diff --git a/pkg/flist/flist_test.go b/pkg/flist/flist_test.go index 24025e36..2592a4c0 100644 --- a/pkg/flist/flist_test.go +++ b/pkg/flist/flist_test.go @@ -3,6 +3,7 @@ package flist import ( "bytes" "context" + "net/url" "os" "os/exec" "path/filepath" @@ -15,6 +16,7 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" "github.com/threefoldtech/zosbase/pkg" + "github.com/threefoldtech/zosbase/pkg/environment" "github.com/threefoldtech/zosbase/pkg/gridtypes" ) @@ -159,7 +161,10 @@ func TestMountUnmount(t *testing.T) { sys.On("Mount", "overlay", filepath.Join(root, "mountpoint", name), "overlay", uintptr(syscall.MS_NOATIME), mock.Anything).Return(nil) - mnt, err := flister.mountInNamespace(name, "https://hub.grid.tf/thabet/redis.flist", pkg.DefaultMountOptions, "") + redisFlist, err := url.JoinPath(environment.MustGet().HubURL, "thabet", "redis.flist") + require.NoError(t, err) + + mnt, err := flister.mountInNamespace(name, redisFlist, pkg.DefaultMountOptions, "") require.NoError(t, err) // Trick flister into thinking that 0-fs has exited @@ -186,7 +191,10 @@ func TestMountUnmountRO(t *testing.T) { flist := mock.Anything sys.On("Mount", flist, filepath.Join(root, "mountpoint", name), "bind", uintptr(syscall.MS_BIND), "").Return(nil) - mnt, err := flister.mountInNamespace(name, "https://hub.grid.tf/thabet/redis.flist", pkg.ReadOnlyMountOptions, "") + redisFlist, err := url.JoinPath(environment.MustGet().HubURL, "thabet", "redis.flist") + require.NoError(t, err) + + mnt, err := flister.mountInNamespace(name, redisFlist, pkg.ReadOnlyMountOptions, "") require.NoError(t, err) // Trick flister into thinking that 0-fs has exited @@ -223,11 +231,14 @@ func TestIsolation(t *testing.T) { name2 := "test2" sys.On("Mount", "overlay", filepath.Join(root, "mountpoint", name2), "overlay", uintptr(syscall.MS_NOATIME), mock.Anything).Return(nil) - path1, err := flister.mountInNamespace(name1, "https://hub.grid.tf/thabet/redis.flist", pkg.DefaultMountOptions, "") + redisFlist, err := url.JoinPath(environment.MustGet().HubURL, "thabet", "redis.flist") + require.NoError(err) + + path1, err := flister.mountInNamespace(name1, redisFlist, pkg.DefaultMountOptions, "") require.NoError(err) args1 := cmder.m - path2, err := flister.mountInNamespace(name2, "https://hub.grid.tf/thabet/redis.flist", pkg.DefaultMountOptions, "") + path2, err := flister.mountInNamespace(name2, redisFlist, pkg.DefaultMountOptions, "") require.NoError(err) args2 := cmder.m @@ -246,14 +257,17 @@ func TestDownloadFlist(t *testing.T) { f := newFlister(root, strg, cmder, sys) - hash1, path1, err := f.downloadFlist("https://hub.grid.tf/thabet/redis.flist", "") + redisFlist, err := url.JoinPath(environment.MustGet().HubURL, "thabet", "redis.flist") + require.NoError(err) + + hash1, path1, err := f.downloadFlist(redisFlist, "") require.NoError(err) // now corrupt the flist err = os.Truncate(string(path1), 512) require.NoError(err) - hash2, path2, err := f.downloadFlist("https://hub.grid.tf/thabet/redis.flist", "") + hash2, path2, err := f.downloadFlist(redisFlist, "") require.NoError(err) require.EqualValues(path1, path2) diff --git a/pkg/gateway/flist.go b/pkg/gateway/flist.go index 99fdce5b..344c48b0 100644 --- a/pkg/gateway/flist.go +++ b/pkg/gateway/flist.go @@ -3,24 +3,29 @@ package gateway import ( "context" "fmt" + "net/url" "path/filepath" "github.com/pkg/errors" "github.com/threefoldtech/zbus" "github.com/threefoldtech/zosbase/pkg" + "github.com/threefoldtech/zosbase/pkg/environment" "github.com/threefoldtech/zosbase/pkg/stubs" ) -const ( - flist = "https://hub.grid.tf/tf-autobuilder/traefik-2.9.9.flist" -) - // ensureTraefikBin makes sure traefik flist is mounted. // TODO: we need to "update" traefik and restart the service // if new version is available! func ensureTraefikBin(ctx context.Context, cl zbus.Client) (string, error) { const bin = "traefik" flistd := stubs.NewFlisterStub(cl) + + env := environment.MustGet() + flist, err := url.JoinPath(env.HubURL, "tf-autobuilder", "traefik-2.9.9.flist") + if err != nil { + return "", errors.Wrap(err, "failed to constract traefik flist url") + } + hash, err := flistd.FlistHash(ctx, flist) if err != nil { return "", errors.Wrap(err, "failed to get traefik flist hash") diff --git a/pkg/gateway_light/flist.go b/pkg/gateway_light/flist.go index 99fdce5b..b3e179ea 100644 --- a/pkg/gateway_light/flist.go +++ b/pkg/gateway_light/flist.go @@ -3,24 +3,28 @@ package gateway import ( "context" "fmt" + "net/url" "path/filepath" "github.com/pkg/errors" "github.com/threefoldtech/zbus" "github.com/threefoldtech/zosbase/pkg" + "github.com/threefoldtech/zosbase/pkg/environment" "github.com/threefoldtech/zosbase/pkg/stubs" ) -const ( - flist = "https://hub.grid.tf/tf-autobuilder/traefik-2.9.9.flist" -) - // ensureTraefikBin makes sure traefik flist is mounted. // TODO: we need to "update" traefik and restart the service // if new version is available! func ensureTraefikBin(ctx context.Context, cl zbus.Client) (string, error) { const bin = "traefik" flistd := stubs.NewFlisterStub(cl) + + env := environment.MustGet() + flist, err := url.JoinPath(env.HubURL, "tf-autobuilder", "traefik-2.9.9.flist") + if err != nil { + return "", errors.Wrap(err, "failed to construct traefik flist url") + } hash, err := flistd.FlistHash(ctx, flist) if err != nil { return "", errors.Wrap(err, "failed to get traefik flist hash") diff --git a/pkg/geoip/geoip.go b/pkg/geoip/geoip.go index 43966cbf..72ca179d 100644 --- a/pkg/geoip/geoip.go +++ b/pkg/geoip/geoip.go @@ -20,7 +20,7 @@ type Location struct { } var ( - geoipURLs = []string{"https://geoip.grid.tf/", "https://02.geoip.grid.tf/", "https://03.geoip.grid.tf/"} + geoipURLs = []string{"https://geoip.threefold.me/", "https://geoip.grid.tf/", "https://02.geoip.grid.tf/", "https://03.geoip.grid.tf/"} defaultHTTPClient = retryablehttp.NewClient() ) diff --git a/pkg/primitives/vm-light/vm.go b/pkg/primitives/vm-light/vm.go index cc5c0d99..a0d13160 100644 --- a/pkg/primitives/vm-light/vm.go +++ b/pkg/primitives/vm-light/vm.go @@ -6,12 +6,14 @@ import ( "fmt" "io" "net" + "net/url" "os" "github.com/pkg/errors" "github.com/rs/zerolog/log" "github.com/threefoldtech/zbus" "github.com/threefoldtech/zosbase/pkg" + "github.com/threefoldtech/zosbase/pkg/environment" "github.com/threefoldtech/zosbase/pkg/gridtypes" "github.com/threefoldtech/zosbase/pkg/gridtypes/zos" "github.com/threefoldtech/zosbase/pkg/primitives/vmgpu" @@ -20,7 +22,6 @@ import ( ) const ( - cloudContainerFlist = "https://hub.grid.tf/tf-autobuilder/cloud-container-9dba60e.flist" cloudContainerName = "cloud-container" ) @@ -109,7 +110,6 @@ func (p *Manager) mountVolume(ctx context.Context, wl *gridtypes.WorkloadWithID, } func (p *Manager) mountQsfs(wl *gridtypes.WorkloadWithID, mount zos.MachineMount, vm *pkg.VM) error { - var info zos.QuatumSafeFSResult if err := wl.Result.Unmarshal(&info); err != nil { return fmt.Errorf("invalid qsfs result '%s': %w", mount.Name, err) @@ -216,6 +216,12 @@ func (p *Manager) virtualMachineProvisionImpl(ctx context.Context, wl *gridtypes log.Debug().Msgf("detected flist type: %+v", imageInfo) // mount cloud-container flist (or reuse) which has kernel, initrd and also firmware + env := environment.MustGet() + cloudContainerFlist, err := url.JoinPath(env.FlistURL, "tf-autobuilder", "cloud-container-9dba60e.flist") + if err != nil { + return zos.ZMachineLightResult{}, errors.Wrap(err, "failed to construct cloud-container flist url") + } + hash, err := flist.FlistHash(ctx, cloudContainerFlist) if err != nil { return zos.ZMachineLightResult{}, errors.Wrap(err, "failed to get cloud-container flist hash") @@ -237,7 +243,6 @@ func (p *Manager) virtualMachineProvisionImpl(ctx context.Context, wl *gridtypes if err = p.prepVirtualMachine(ctx, cloudImage, imageInfo, &machine, &config, &deployment, wl); err != nil { return result, err } - } // - Attach mounts diff --git a/pkg/primitives/vm/vm.go b/pkg/primitives/vm/vm.go index 1a1655ee..ab0d2b30 100644 --- a/pkg/primitives/vm/vm.go +++ b/pkg/primitives/vm/vm.go @@ -6,12 +6,14 @@ import ( "fmt" "io" "net" + "net/url" "os" "github.com/pkg/errors" "github.com/rs/zerolog/log" "github.com/threefoldtech/zbus" "github.com/threefoldtech/zosbase/pkg" + "github.com/threefoldtech/zosbase/pkg/environment" "github.com/threefoldtech/zosbase/pkg/gridtypes" "github.com/threefoldtech/zosbase/pkg/gridtypes/zos" "github.com/threefoldtech/zosbase/pkg/primitives/vmgpu" @@ -20,8 +22,7 @@ import ( ) const ( - cloudContainerFlist = "https://hub.grid.tf/tf-autobuilder/cloud-container-9dba60e.flist" - cloudContainerName = "cloud-container" + cloudContainerName = "cloud-container" ) // ZMachine type @@ -254,6 +255,12 @@ func (p *Manager) virtualMachineProvisionImpl(ctx context.Context, wl *gridtypes log.Debug().Msgf("detected flist type: %+v", imageInfo) // mount cloud-container flist (or reuse) which has kernel, initrd and also firmware + env := environment.MustGet() + cloudContainerFlist, err := url.JoinPath(env.FlistURL, "tf-autobuilder", "cloud-container-9dba60e.flist") + if err != nil { + return zos.ZMachineResult{}, errors.Wrap(err, "failed to construct cloud-container flist url") + } + hash, err := flist.FlistHash(ctx, cloudContainerFlist) if err != nil { return zos.ZMachineResult{}, errors.Wrap(err, "failed to get cloud-container flist hash") diff --git a/pkg/primitives/zdb/zdb.go b/pkg/primitives/zdb/zdb.go index 79f10194..0bd02910 100644 --- a/pkg/primitives/zdb/zdb.go +++ b/pkg/primitives/zdb/zdb.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "net" + "net/url" "os" "path/filepath" "regexp" @@ -13,6 +14,7 @@ import ( "github.com/cenkalti/backoff/v3" "github.com/threefoldtech/zbus" + "github.com/threefoldtech/zosbase/pkg/environment" "github.com/threefoldtech/zosbase/pkg/gridtypes" "github.com/threefoldtech/zosbase/pkg/gridtypes/zos" "github.com/threefoldtech/zosbase/pkg/kernel" @@ -29,7 +31,8 @@ import ( const ( // https://hub.grid.tf/api/flist/tf-autobuilder/threefoldtech-0-db-development.flist/light // To get the latest symlink pointer - zdbFlistURL = "https://hub.grid.tf/tf-autobuilder/threefoldtech-0-db-release-v2.0.8-55737c9202.flist" + flistRepo = "tf-autobuilder" + flistName = "threefoldtech-0-db-release-v2.0.8-55737c9202.flist" zdbContainerNS = "zdb" zdbContainerDataMnt = "/zdb" zdbPort = 9900 @@ -160,7 +163,6 @@ func (p *Manager) zdbProvisionImpl(ctx context.Context, wl *gridtypes.WorkloadWi if kernel.GetParams().IsLight() { containerIPs, err = p.waitZDBIPsLight(ctx, container.Network.Namespace, container.CreatedAt) } else { - containerIPs, err = p.waitZDBIPs(ctx, container.Network.Namespace, container.CreatedAt) } if err != nil { @@ -202,7 +204,6 @@ func (p *Manager) zdbProvisionImpl(ctx context.Context, wl *gridtypes.WorkloadWi if kernel.GetParams().IsLight() { containerIPs, err = p.waitZDBIPsLight(ctx, cont.Network.Namespace, cont.CreatedAt) } else { - containerIPs, err = p.waitZDBIPs(ctx, cont.Network.Namespace, cont.CreatedAt) } if err != nil { @@ -255,6 +256,12 @@ func (p *Manager) zdbRootFS(ctx context.Context) (string, error) { var err error var rootFS string + env := environment.MustGet() + zdbFlistURL, err := url.JoinPath(env.FlistURL, flistRepo, flistName) + if err != nil { + return "", errors.Wrap(err, "failed to construct zdb flist url") + } + hash, err := flist.FlistHash(ctx, zdbFlistURL) if err != nil { return "", errors.Wrap(err, "failed to get flist hash") @@ -282,6 +289,11 @@ func (p *Manager) createZdbContainer(ctx context.Context, device pkg.Device) err slog = log.With().Str("containerID", string(name)).Logger() ) + env := environment.MustGet() + zdbFlistURL, err := url.JoinPath(env.FlistURL, flistRepo, flistName) + if err != nil { + return errors.Wrap(err, "failed to construct zdb flist url") + } slog.Debug().Str("flist", zdbFlistURL).Msg("mounting flist") rootFS, err := p.zdbRootFS(ctx) @@ -369,6 +381,7 @@ func (p *Manager) dataMigration(ctx context.Context, volume string) { } } } + func (p *Manager) createZdbContainerLight(ctx context.Context, device pkg.Device) error { var ( name = pkg.ContainerID(device.ID) @@ -380,6 +393,11 @@ func (p *Manager) createZdbContainerLight(ctx context.Context, device pkg.Device slog = log.With().Str("containerID", string(name)).Logger() ) + env := environment.MustGet() + zdbFlistURL, err := url.JoinPath(env.FlistURL, flistRepo, flistName) + if err != nil { + return errors.Wrap(err, "failed to construct zdb flist url") + } slog.Debug().Str("flist", zdbFlistURL).Msg("mounting flist") rootFS, err := p.zdbRootFS(ctx) @@ -565,6 +583,7 @@ func (p *Manager) waitZDBIPs(ctx context.Context, namespace string, created time return containerIPs, nil } + func (p *Manager) waitZDBIPsLight(ctx context.Context, namespace string, created time.Time) ([]net.IP, error) { // TODO: is there a need for retrying anymore?? var ( @@ -932,6 +951,12 @@ func (p *Manager) initialize(ctx context.Context) error { flistmod = stubs.NewFlisterStub(p.zbus) ) // fetching extected hash + env := environment.MustGet() + zdbFlistURL, err := url.JoinPath(env.FlistURL, flistRepo, flistName) + if err != nil { + return errors.Wrap(err, "failed to construct zdb flist url") + } + log.Debug().Msg("fetching flist hash") expected, err := flistmod.FlistHash(ctx, zdbFlistURL) if err != nil { @@ -993,6 +1018,12 @@ func (p *Manager) initializeLight(ctx context.Context) error { flistmod = stubs.NewFlisterStub(p.zbus) ) // fetching extected hash + env := environment.MustGet() + zdbFlistURL, err := url.JoinPath(env.FlistURL, flistRepo, flistName) + if err != nil { + return errors.Wrap(err, "failed to construct zdb flist url") + } + log.Debug().Msg("fetching flist hash") expected, err := flistmod.FlistHash(ctx, zdbFlistURL) if err != nil { @@ -1039,6 +1070,7 @@ func (p *Manager) initializeLight(ctx context.Context) error { } return nil } + func (p *Manager) upgradeRuntime(ctx context.Context, expected string, container pkg.ContainerID) error { var ( flistmod = stubs.NewFlisterStub(p.zbus) diff --git a/pkg/qsfsd/qsfs.go b/pkg/qsfsd/qsfs.go index fd1a5978..e4107e27 100644 --- a/pkg/qsfsd/qsfs.go +++ b/pkg/qsfsd/qsfs.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "net/url" "os" "os/exec" "path/filepath" @@ -15,13 +16,13 @@ import ( "github.com/rs/zerolog/log" "github.com/threefoldtech/zbus" "github.com/threefoldtech/zosbase/pkg" + "github.com/threefoldtech/zosbase/pkg/environment" "github.com/threefoldtech/zosbase/pkg/gridtypes" "github.com/threefoldtech/zosbase/pkg/gridtypes/zos" "github.com/threefoldtech/zosbase/pkg/stubs" ) const ( - qsfsFlist = "https://hub.grid.tf/tf-autobuilder/qsfs-0.2.0-rc2.flist" qsfsContainerNS = "qsfs" qsfsRootFsPropagation = pkg.RootFSPropagationSlave zstorSocket = "/var/run/zstor.sock" @@ -122,6 +123,13 @@ func (q *QSFS) Mount(wlID string, cfg zos.QuantumSafeFS) (info pkg.QSFSInfo, err if err != nil { return info, errors.Wrap(err, "failed to prepare qsfs") } + + env := environment.MustGet() + qsfsFlist, err := url.JoinPath(env.HubURL, "tf-autobuilder", "qsfs-0.2.0-rc2.flist") + if err != nil { + err = errors.Wrap(err, "failed to construct url") + return + } flistPath, err := flistd.Mount(ctx, wlID, qsfsFlist, pkg.MountOptions{ ReadOnly: false, Limit: cfg.Cache, @@ -195,7 +203,6 @@ func (f *QSFS) waitUntilMounted(ctx context.Context, path string) error { return fmt.Errorf("waiting for zdbfs mount %s timedout: context cancelled", path) } } - } func (f *QSFS) isMounted(path string) (bool, error) { diff --git a/pkg/upgrade/README.md b/pkg/upgrade/README.md index 607906c0..6ac17006 100644 --- a/pkg/upgrade/README.md +++ b/pkg/upgrade/README.md @@ -15,7 +15,7 @@ To run the upgrade module you first need to create a new upgrader instance with | Option | Description | Default | | :------------: | :------------------------------------------: | :-------------------: | | `NoZosUpgrade` | enable or disable the update of zos binaries | enabled by default | -| `Storage` | overrides the default hub storage url | `hub.grid.tf` | +| `Storage` | overrides the default hub storage url | `hub.threefold.me` | | `Zinit` | overrides the default zinit socket | "/var/run/zinit.sock" | ```go diff --git a/pkg/upgrade/hub/hub.go b/pkg/upgrade/hub/hub.go index 5c8ba4f8..d3f22988 100644 --- a/pkg/upgrade/hub/hub.go +++ b/pkg/upgrade/hub/hub.go @@ -20,12 +20,12 @@ import ( const ( // hubBaseURL base hub url - hubBaseURL = "https://hub.grid.tf/" - hubv4BaseURL = "https://v4.hub.grid.tf/" + hubBaseURL = "https://hub.threefold.me/" + hubv4BaseURL = "https://v4.hub.threefold.me" // hubStorage default hub db - hubStorage = "zdb://hub.grid.tf:9900" - hubv4Storage = "zdb://hub.grid.tf:9940" + hubStorage = "zdb://hub.threefold.me:9900" + hubv4Storage = "zdb://hub.threefold.me:9940" defaultHubCallTimeout = 20 * time.Second ) diff --git a/scripts/debug_image.md b/scripts/debug_image.md index 19f070b6..518476bd 100644 --- a/scripts/debug_image.md +++ b/scripts/debug_image.md @@ -19,7 +19,7 @@ sudo -i ./install_deps # run image from a directory -./debug_image.sh -d --image https://hub.grid.tf/omarabdulaziz.3bot/ubuntu-jammy.flist +./debug_image.sh -d --image https://hub.threefold.me/omarabdulaziz.3bot/ubuntu-jammy.flist ``` ## Image Types @@ -28,7 +28,7 @@ sudo -i the creation tutorial [here](../docs/manual/zmachine/zmachine.md) - Container: Contains only the rootfs. - in this case wil use kernel and initramfs from cloud container [flist](https://hub.grid.tf/tf-autobuilder/cloud-container-9dba60e.flist.md) + in this case wil use kernel and initramfs from cloud container [flist](https://hub.threefold.me/tf-autobuilder/cloud-container-9dba60e.flist.md) ## Flags diff --git a/scripts/debug_image.sh b/scripts/debug_image.sh index fbe9b01f..fd8beb2d 100755 --- a/scripts/debug_image.sh +++ b/scripts/debug_image.sh @@ -4,7 +4,7 @@ readonly SOCKET="/tmp/virtiofs.sock" readonly CH_API_SOCKET="/tmp/ch-api.sock" readonly OVERLAYFS="/tmp/overlay" -readonly CCFLIST="https://hub.grid.tf/tf-autobuilder/cloud-container-9dba60e.flist" +readonly CCFLIST="https://hub.threefold.me/tf-autobuilder/cloud-container-9dba60e.flist" readonly MACHINE_TYPE="machine" readonly CONTAINER_TYPE="container" From 0a89f06d07500f21df0edeeabc0733e8fb6a12f3 Mon Sep 17 00:00:00 2001 From: Eslam-Nawara Date: Mon, 16 Jun 2025 18:26:43 +0300 Subject: [PATCH 04/19] load huburl from zos-conf --- pkg/environment/config.go | 1 + pkg/environment/environment.go | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/environment/config.go b/pkg/environment/config.go index 211784a7..468023d9 100644 --- a/pkg/environment/config.go +++ b/pkg/environment/config.go @@ -37,6 +37,7 @@ type Config struct { KycURL string `json:"kyc_url"` RegistrarURL string `json:"registrar_url"` FlistURL string `json:"flist_url"` + HubURL string `json:"hub_url"` BinRepo string `json:"bin_repo"` } diff --git a/pkg/environment/environment.go b/pkg/environment/environment.go index 62da75ed..f75a2b57 100644 --- a/pkg/environment/environment.go +++ b/pkg/environment/environment.go @@ -334,12 +334,16 @@ func getEnvironmentFromParams(params kernel.Params) (Environment, error) { env.FlistURL = flist } + if hub := config.HubURL; len(hub) > 0 { + env.FlistURL = hub + } + if bin := config.BinRepo; len(bin) > 0 { env.FlistURL = bin } if kyc := config.KycURL; len(kyc) > 0 { - env.FlistURL = kyc + env.KycURL = kyc } if registrar := config.RegistrarURL; len(registrar) > 0 { From 35c21b42b397abef8c3a4b82b196b46f66679284 Mon Sep 17 00:00:00 2001 From: Eslam-Nawara Date: Mon, 16 Jun 2025 18:30:10 +0300 Subject: [PATCH 05/19] update hub storage --- pkg/upgrade/upgrade.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/upgrade/upgrade.go b/pkg/upgrade/upgrade.go index 5adc4c46..7a7a8211 100644 --- a/pkg/upgrade/upgrade.go +++ b/pkg/upgrade/upgrade.go @@ -42,8 +42,8 @@ var ( const ( service = "upgrader" - defaultHubStorage = "zdb://hub.grid.tf:9900" - defaultHubv4Storage = "zdb://hub.grid.tf:9940" + defaultHubStorage = "zdb://hub.threefold.me:9900" + defaultHubv4Storage = "zdb://v4.hub.threefold.me:9940" defaultZinitSocket = "/var/run/zinit.sock" checkForUpdateEvery = 60 * time.Minute From f20708ea5997e66da925044cfe510e3577651e21 Mon Sep 17 00:00:00 2001 From: Ashraf Fouda Date: Tue, 17 Jun 2025 10:33:23 +0300 Subject: [PATCH 06/19] fix typos in getting config from zos-config Signed-off-by: Ashraf Fouda --- pkg/environment/environment.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/environment/environment.go b/pkg/environment/environment.go index f75a2b57..e5110236 100644 --- a/pkg/environment/environment.go +++ b/pkg/environment/environment.go @@ -339,7 +339,7 @@ func getEnvironmentFromParams(params kernel.Params) (Environment, error) { } if bin := config.BinRepo; len(bin) > 0 { - env.FlistURL = bin + env.BinRepo = bin } if kyc := config.KycURL; len(kyc) > 0 { @@ -347,7 +347,7 @@ func getEnvironmentFromParams(params kernel.Params) (Environment, error) { } if registrar := config.RegistrarURL; len(registrar) > 0 { - env.FlistURL = registrar + env.RegistrarURL = registrar } if farmSecret, ok := params.Get("secret"); ok { From 239cdf7c3392acf9354cd9a775d24f66b579e95f Mon Sep 17 00:00:00 2001 From: Ashraf Fouda Date: Wed, 18 Jun 2025 12:51:38 +0300 Subject: [PATCH 07/19] fixing huburl Signed-off-by: Ashraf Fouda --- pkg/environment/environment.go | 2 +- pkg/primitives/vm-light/vm.go | 4 ++-- pkg/primitives/vm/vm.go | 2 +- pkg/primitives/zdb/zdb.go | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/environment/environment.go b/pkg/environment/environment.go index e5110236..be2ae748 100644 --- a/pkg/environment/environment.go +++ b/pkg/environment/environment.go @@ -335,7 +335,7 @@ func getEnvironmentFromParams(params kernel.Params) (Environment, error) { } if hub := config.HubURL; len(hub) > 0 { - env.FlistURL = hub + env.HubURL = hub } if bin := config.BinRepo; len(bin) > 0 { diff --git a/pkg/primitives/vm-light/vm.go b/pkg/primitives/vm-light/vm.go index a0d13160..0c41ad60 100644 --- a/pkg/primitives/vm-light/vm.go +++ b/pkg/primitives/vm-light/vm.go @@ -22,7 +22,7 @@ import ( ) const ( - cloudContainerName = "cloud-container" + cloudContainerName = "cloud-container" ) // ZMachine type @@ -217,7 +217,7 @@ func (p *Manager) virtualMachineProvisionImpl(ctx context.Context, wl *gridtypes // mount cloud-container flist (or reuse) which has kernel, initrd and also firmware env := environment.MustGet() - cloudContainerFlist, err := url.JoinPath(env.FlistURL, "tf-autobuilder", "cloud-container-9dba60e.flist") + cloudContainerFlist, err := url.JoinPath(env.HubURL, "tf-autobuilder", "cloud-container-9dba60e.flist") if err != nil { return zos.ZMachineLightResult{}, errors.Wrap(err, "failed to construct cloud-container flist url") } diff --git a/pkg/primitives/vm/vm.go b/pkg/primitives/vm/vm.go index ab0d2b30..8dc20e07 100644 --- a/pkg/primitives/vm/vm.go +++ b/pkg/primitives/vm/vm.go @@ -256,7 +256,7 @@ func (p *Manager) virtualMachineProvisionImpl(ctx context.Context, wl *gridtypes // mount cloud-container flist (or reuse) which has kernel, initrd and also firmware env := environment.MustGet() - cloudContainerFlist, err := url.JoinPath(env.FlistURL, "tf-autobuilder", "cloud-container-9dba60e.flist") + cloudContainerFlist, err := url.JoinPath(env.HubURL, "tf-autobuilder", "cloud-container-9dba60e.flist") if err != nil { return zos.ZMachineResult{}, errors.Wrap(err, "failed to construct cloud-container flist url") } diff --git a/pkg/primitives/zdb/zdb.go b/pkg/primitives/zdb/zdb.go index 0bd02910..dd4c70a9 100644 --- a/pkg/primitives/zdb/zdb.go +++ b/pkg/primitives/zdb/zdb.go @@ -257,7 +257,7 @@ func (p *Manager) zdbRootFS(ctx context.Context) (string, error) { var rootFS string env := environment.MustGet() - zdbFlistURL, err := url.JoinPath(env.FlistURL, flistRepo, flistName) + zdbFlistURL, err := url.JoinPath(env.HubURL, flistRepo, flistName) if err != nil { return "", errors.Wrap(err, "failed to construct zdb flist url") } From f493ae2e1662b4f9afce13e3038734880f42680d Mon Sep 17 00:00:00 2001 From: Eslam-Nawara Date: Wed, 18 Jun 2025 14:17:56 +0300 Subject: [PATCH 08/19] add hub storage and geoip to config and env --- pkg/environment/config.go | 7 ++- pkg/environment/environment.go | 96 ++++++++++++++++++++++------------ pkg/geoip/geoip.go | 10 ++-- pkg/geoip/geoip_test.go | 10 ++-- pkg/upgrade/hub/hub.go | 39 +++++++------- pkg/upgrade/upgrade.go | 16 +++--- pkg/upgrade/upgrade_test.go | 5 +- 7 files changed, 109 insertions(+), 74 deletions(-) diff --git a/pkg/environment/config.go b/pkg/environment/config.go index 468023d9..098bb0cd 100644 --- a/pkg/environment/config.go +++ b/pkg/environment/config.go @@ -30,15 +30,20 @@ type Config struct { RolloutUpgrade struct { TestFarms []uint32 `json:"test_farms"` } `json:"rollout_upgrade"` - RelaysURLs []string `json:"relays_urls"` SubstrateURL []string `json:"substrate_urls"` + RelaysURLs []string `json:"relays_urls"` ActivationURL []string `json:"activation_urls"` GraphQL []string `json:"graphql_urls"` KycURL string `json:"kyc_url"` RegistrarURL string `json:"registrar_url"` FlistURL string `json:"flist_url"` + V4FlistURL string `json:"v4_flist_url"` HubURL string `json:"hub_url"` + V4HubURL string `json:"v4_hub_url"` + HubStorage string `json:"hub_storage"` + V4HubStorage string `json:"v4_hub_storage"` BinRepo string `json:"bin_repo"` + GeoipURLs []string `json:"geoip_urls"` } // Merge, updates current config with cfg merging and override config diff --git a/pkg/environment/environment.go b/pkg/environment/environment.go index be2ae748..4ba68616 100644 --- a/pkg/environment/environment.go +++ b/pkg/environment/environment.go @@ -17,12 +17,24 @@ import ( const ( baseExtendedURL = "https://raw.githubusercontent.com/threefoldtech/zos-config/main/" - hubURL = "https://hub.threefold.me" - v4HubURL = "https://v4.hub.threefold.me" - flistURL = "redis://hub.threefold.me:9900" - v4FlistURL = "redis://v4.hub.threefold.me:9940" + + hubURL = "https://hub.threefold.me" + v4HubURL = "https://v4.hub.threefold.me" + + flistURL = "redis://hub.threefold.me:9900" + v4FlistURL = "redis://v4.hub.threefold.me:9940" + + defaultHubStorage = "zdb://hub.threefold.me:9900" + defaultV4HubStorage = "zdb://v4.hub.threefold.me:9940" ) +var defaultGeoipURLs = []string{ + "https://geoip.threefold.me/", + "https://geoip.grid.tf/", + "https://02.geoip.grid.tf/", + "https://03.geoip.grid.tf/", +} + // PubMac specify how the mac address of the public nic // (in case of public-config) is calculated type PubMac string @@ -42,8 +54,10 @@ const ( type Environment struct { RunningMode RunMode - FlistURL string - BinRepo string + FlistURL string + HubURL string + HubStorage string + BinRepo string FarmID pkg.FarmID Orphan bool @@ -56,9 +70,9 @@ type Environment struct { relaysURLs []string ActivationURL []string GraphQL []string + GeoipURLs []string KycURL string RegistrarURL string - HubURL string // private vlan to join // if set, zos will use this as its priv vlan @@ -127,15 +141,17 @@ var ( "https://activation.dev.grid.tf/activation/activate", "https://activation.02.dev.grid.tf/activation/activate", }, - FlistURL: flistURL, - HubURL: hubURL, - BinRepo: "tf-zos-v3-bins.dev", + FlistURL: flistURL, + HubURL: hubURL, + HubStorage: defaultHubStorage, + BinRepo: "tf-zos-v3-bins.dev", GraphQL: []string{ "https://graphql.dev.grid.tf/graphql", "https://graphql.02.dev.grid.tf/graphql", }, KycURL: "https://kyc.dev.grid.tf", RegistrarURL: "http://registrar.dev4.grid.tf", + GeoipURLs: defaultGeoipURLs, } envTest = Environment{ @@ -152,15 +168,17 @@ var ( "https://activation.test.grid.tf/activation/activate", "https://activation.02.test.grid.tf/activation/activate", }, - FlistURL: flistURL, - HubURL: hubURL, - BinRepo: "tf-zos-v3-bins.test", + FlistURL: flistURL, + HubURL: hubURL, + HubStorage: defaultHubStorage, + BinRepo: "tf-zos-v3-bins.test", GraphQL: []string{ "https://graphql.test.grid.tf/graphql", "https://graphql.02.test.grid.tf/graphql", }, KycURL: "https://kyc.test.grid.tf", RegistrarURL: "http://registrar.test4.grid.tf", + GeoipURLs: defaultGeoipURLs, } envQA = Environment{ @@ -177,15 +195,17 @@ var ( "https://activation.qa.grid.tf/activation/activate", "https://activation.02.qa.grid.tf/activation/activate", }, - FlistURL: flistURL, - HubURL: hubURL, - BinRepo: "tf-zos-v3-bins.qanet", + FlistURL: flistURL, + HubURL: hubURL, + HubStorage: defaultHubStorage, + BinRepo: "tf-zos-v3-bins.qanet", GraphQL: []string{ "https://graphql.qa.grid.tf/graphql", "https://graphql.02.qa.grid.tf/graphql", }, KycURL: "https://kyc.qa.grid.tf", RegistrarURL: "https://registrar.qa4.grid.tf", + GeoipURLs: defaultGeoipURLs, } envProd = Environment{ @@ -206,9 +226,10 @@ var ( "https://activation.grid.tf/activation/activate", "https://activation.02.grid.tf/activation/activate", }, - HubURL: hubURL, - FlistURL: flistURL, - BinRepo: "tf-zos-v3-bins", + FlistURL: flistURL, + HubURL: hubURL, + HubStorage: defaultHubStorage, + BinRepo: "tf-zos-v3-bins", GraphQL: []string{ "https://graphql.grid.threefold.me/graphql", "https://graphql.grid.tf/graphql", @@ -216,6 +237,7 @@ var ( }, KycURL: "https://kyc.threefold.me", RegistrarURL: "https://registrar.prod4.threefold.me", + GeoipURLs: defaultGeoipURLs, } ) @@ -330,14 +352,6 @@ func getEnvironmentFromParams(params kernel.Params) (Environment, error) { env.GraphQL = graphql } - if flist := config.FlistURL; len(flist) > 0 { - env.FlistURL = flist - } - - if hub := config.HubURL; len(hub) > 0 { - env.HubURL = hub - } - if bin := config.BinRepo; len(bin) > 0 { env.BinRepo = bin } @@ -350,6 +364,28 @@ func getEnvironmentFromParams(params kernel.Params) (Environment, error) { env.RegistrarURL = registrar } + if geoip := config.GeoipURLs; len(geoip) > 0 { + env.GeoipURLs = geoip + } + + // if the node running v4 chage urls to use v4 hub + if params.IsV4() { + env.FlistURL = v4FlistURL + if flist := config.V4FlistURL; len(flist) > 0 { + env.FlistURL = flist + } + + env.HubURL = v4HubURL + if hub := config.V4HubURL; len(hub) > 0 { + env.HubURL = hub + } + + env.HubStorage = defaultV4HubStorage + if storage := config.V4HubStorage; len(storage) > 0 { + env.HubStorage = storage + } + } + if farmSecret, ok := params.Get("secret"); ok { if len(farmSecret) > 0 { env.FarmSecret = farmSecret[len(farmSecret)-1] @@ -427,11 +463,5 @@ func getEnvironmentFromParams(params kernel.Params) (Environment, error) { env.BinRepo = e } - // if the node running v4 chage flisturl to use v4.hub.threefold.me - if params.IsV4() { - env.FlistURL = v4FlistURL - env.HubURL = v4HubURL - } - return env, nil } diff --git a/pkg/geoip/geoip.go b/pkg/geoip/geoip.go index 72ca179d..ed668023 100644 --- a/pkg/geoip/geoip.go +++ b/pkg/geoip/geoip.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/go-retryablehttp" "github.com/rs/zerolog/log" + "github.com/threefoldtech/zosbase/pkg/environment" ) // Location holds the result of a geoip request @@ -19,15 +20,12 @@ type Location struct { City string `json:"city_name"` } -var ( - geoipURLs = []string{"https://geoip.threefold.me/", "https://geoip.grid.tf/", "https://02.geoip.grid.tf/", "https://03.geoip.grid.tf/"} - - defaultHTTPClient = retryablehttp.NewClient() -) +var defaultHTTPClient = retryablehttp.NewClient() // Fetch retrieves the location of the system calling this function func Fetch() (Location, error) { - for _, url := range geoipURLs { + env := environment.MustGet() + for _, url := range env.GeoipURLs { l, err := getLocation(url) if err != nil { log.Err(err).Str("url", url).Msg("failed to fetch location from geoip service") diff --git a/pkg/geoip/geoip_test.go b/pkg/geoip/geoip_test.go index 351f041d..eef9a91e 100644 --- a/pkg/geoip/geoip_test.go +++ b/pkg/geoip/geoip_test.go @@ -6,6 +6,7 @@ import ( "github.com/jarcoal/httpmock" "github.com/stretchr/testify/require" + "github.com/threefoldtech/zosbase/pkg/environment" ) func TestGetLocation(t *testing.T) { @@ -21,7 +22,8 @@ func TestGetLocation(t *testing.T) { City: "Cairo", } - for _, url := range geoipURLs { + env := environment.MustGet() + for _, url := range env.GeoipURLs { httpmock.RegisterResponder("GET", url, func(req *http.Request) (*http.Response, error) { return httpmock.NewJsonResponse(200, l) @@ -41,7 +43,8 @@ func TestGetLocation(t *testing.T) { } t.Run("test 404 status code", func(t *testing.T) { - for _, url := range geoipURLs { + env := environment.MustGet() + for _, url := range env.GeoipURLs { httpmock.RegisterResponder("GET", url, func(req *http.Request) (*http.Response, error) { return httpmock.NewJsonResponse(404, l) @@ -55,7 +58,8 @@ func TestGetLocation(t *testing.T) { }) t.Run("test invalid response data", func(t *testing.T) { - for _, url := range geoipURLs { + env := environment.MustGet() + for _, url := range env.GeoipURLs { httpmock.RegisterResponder("GET", url, func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(200, "Cairo") diff --git a/pkg/upgrade/hub/hub.go b/pkg/upgrade/hub/hub.go index d3f22988..800a7ffa 100644 --- a/pkg/upgrade/hub/hub.go +++ b/pkg/upgrade/hub/hub.go @@ -15,18 +15,10 @@ import ( "github.com/pkg/errors" "github.com/rs/zerolog/log" "github.com/threefoldtech/0-fs/meta" - "github.com/threefoldtech/zosbase/pkg/kernel" + "github.com/threefoldtech/zosbase/pkg/environment" ) const ( - // hubBaseURL base hub url - hubBaseURL = "https://hub.threefold.me/" - hubv4BaseURL = "https://v4.hub.threefold.me" - - // hubStorage default hub db - hubStorage = "zdb://hub.threefold.me:9900" - hubv4Storage = "zdb://hub.threefold.me:9940" - defaultHubCallTimeout = 20 * time.Second ) @@ -94,18 +86,22 @@ func (h *HubClient) MountURL(flist string) string { // StorageURL return hub storage url func (h *HubClient) StorageURL() string { - if kernel.GetParams().IsV4() { - return hubv4Storage - } - return hubStorage + env := environment.MustGet() + return env.HubStorage + // if kernel.GetParams().IsV4() { + // return hubv4Storage + // } + // return hubStorage } // StorageURL return hub storage url func (h *HubClient) HubBaseURL() string { - if kernel.GetParams().IsV4() { - return hubv4BaseURL - } - return hubBaseURL + env := environment.MustGet() + return env.HubURL + // if kernel.GetParams().IsV4() { + // return hubv4BaseURL + // } + // return hubBaseURL } // Info gets flist info from hub @@ -304,10 +300,11 @@ func (b *Regular) Files(repo string) ([]FileInfo, error) { var content struct { Content []FileInfo `json:"content"` } - baseURL := hubBaseURL - if kernel.GetParams().IsV4() { - baseURL = hubv4BaseURL - } + env := environment.MustGet() + baseURL := env.HubURL + // if kernel.GetParams().IsV4() { + // baseURL = hubv4BaseURL + // } u, err := url.Parse(baseURL) if err != nil { panic("invalid base url") diff --git a/pkg/upgrade/upgrade.go b/pkg/upgrade/upgrade.go index 7a7a8211..30cc59d4 100644 --- a/pkg/upgrade/upgrade.go +++ b/pkg/upgrade/upgrade.go @@ -42,9 +42,7 @@ var ( const ( service = "upgrader" - defaultHubStorage = "zdb://hub.threefold.me:9900" - defaultHubv4Storage = "zdb://v4.hub.threefold.me:9940" - defaultZinitSocket = "/var/run/zinit.sock" + defaultZinitSocket = "/var/run/zinit.sock" checkForUpdateEvery = 60 * time.Minute checkJitter = 10 // minutes @@ -161,13 +159,14 @@ func NewUpgrader(root string, opts ...UpgraderOption) (*Upgrader, error) { return nil, err } } - hub_storage := defaultHubStorage - if kernel.GetParams().IsV4() { - hub_storage = defaultHubv4Storage - } + env := environment.MustGet() + hubStorage := env.HubStorage + // if kernel.GetParams().IsV4() { + // hub_storage = defaultHubv4Storage + // } if u.storage == nil { // no storage option was set. use default - if err := Storage(hub_storage)(u); err != nil { + if err := Storage(hubStorage)(u); err != nil { return nil, err } } @@ -303,7 +302,6 @@ func (u *Upgrader) update(ctx context.Context) error { return nil } } else { - if env.RunningMode != environment.RunningDev && (remoteVer != chainVer.Version) { // nothing to do! hub version is not the same as the chain return nil diff --git a/pkg/upgrade/upgrade_test.go b/pkg/upgrade/upgrade_test.go index 1f245900..c31d711d 100644 --- a/pkg/upgrade/upgrade_test.go +++ b/pkg/upgrade/upgrade_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" "github.com/threefoldtech/0-fs/meta" + "github.com/threefoldtech/zosbase/pkg/environment" "github.com/threefoldtech/zosbase/pkg/upgrade/hub" ) @@ -19,7 +20,9 @@ func TestUpgraderDownload(t *testing.T) { hub: hubClient, } - err := Storage(defaultHubStorage)(up) + env := environment.MustGet() + hubStorage := env.HubStorage + err := Storage(hubStorage)(up) require.NoError(err) const repo = "azmy.3bot" From 88c17d236471a63af9bd6745e02034bd6779ee88 Mon Sep 17 00:00:00 2001 From: Eslam-Nawara Date: Wed, 18 Jun 2025 15:52:14 +0300 Subject: [PATCH 09/19] add v4hub url to env --- pkg/environment/environment.go | 28 +++++++++++++++++++++++----- pkg/primitives/zdb/zdb.go | 9 ++++----- pkg/upgrade/hub/hub.go | 18 ++++++++++-------- 3 files changed, 37 insertions(+), 18 deletions(-) diff --git a/pkg/environment/environment.go b/pkg/environment/environment.go index 4ba68616..51967e70 100644 --- a/pkg/environment/environment.go +++ b/pkg/environment/environment.go @@ -56,6 +56,7 @@ type Environment struct { FlistURL string HubURL string + V4HubURL string HubStorage string BinRepo string @@ -143,6 +144,7 @@ var ( }, FlistURL: flistURL, HubURL: hubURL, + V4HubURL: v4HubURL, HubStorage: defaultHubStorage, BinRepo: "tf-zos-v3-bins.dev", GraphQL: []string{ @@ -170,6 +172,7 @@ var ( }, FlistURL: flistURL, HubURL: hubURL, + V4HubURL: v4HubURL, HubStorage: defaultHubStorage, BinRepo: "tf-zos-v3-bins.test", GraphQL: []string{ @@ -197,6 +200,7 @@ var ( }, FlistURL: flistURL, HubURL: hubURL, + V4HubURL: v4HubURL, HubStorage: defaultHubStorage, BinRepo: "tf-zos-v3-bins.qanet", GraphQL: []string{ @@ -228,6 +232,7 @@ var ( }, FlistURL: flistURL, HubURL: hubURL, + V4HubURL: v4HubURL, HubStorage: defaultHubStorage, BinRepo: "tf-zos-v3-bins", GraphQL: []string{ @@ -368,6 +373,23 @@ func getEnvironmentFromParams(params kernel.Params) (Environment, error) { env.GeoipURLs = geoip } + if flist := config.FlistURL; len(flist) > 0 { + env.FlistURL = flist + } + + if storage := config.HubStorage; len(storage) > 0 { + env.HubStorage = storage + } + + if hub := config.HubURL; len(hub) > 0 { + env.HubURL = hub + } + + // some modules needs v3 hub url even if the node is of v4 + if hub := config.V4HubURL; len(hub) > 0 { + env.V4HubURL = hub + } + // if the node running v4 chage urls to use v4 hub if params.IsV4() { env.FlistURL = v4FlistURL @@ -375,15 +397,11 @@ func getEnvironmentFromParams(params kernel.Params) (Environment, error) { env.FlistURL = flist } - env.HubURL = v4HubURL - if hub := config.V4HubURL; len(hub) > 0 { - env.HubURL = hub - } - env.HubStorage = defaultV4HubStorage if storage := config.V4HubStorage; len(storage) > 0 { env.HubStorage = storage } + } if farmSecret, ok := params.Get("secret"); ok { diff --git a/pkg/primitives/zdb/zdb.go b/pkg/primitives/zdb/zdb.go index dd4c70a9..0fe6929a 100644 --- a/pkg/primitives/zdb/zdb.go +++ b/pkg/primitives/zdb/zdb.go @@ -29,7 +29,6 @@ import ( ) const ( - // https://hub.grid.tf/api/flist/tf-autobuilder/threefoldtech-0-db-development.flist/light // To get the latest symlink pointer flistRepo = "tf-autobuilder" flistName = "threefoldtech-0-db-release-v2.0.8-55737c9202.flist" @@ -290,7 +289,7 @@ func (p *Manager) createZdbContainer(ctx context.Context, device pkg.Device) err ) env := environment.MustGet() - zdbFlistURL, err := url.JoinPath(env.FlistURL, flistRepo, flistName) + zdbFlistURL, err := url.JoinPath(env.HubURL, flistRepo, flistName) if err != nil { return errors.Wrap(err, "failed to construct zdb flist url") } @@ -394,7 +393,7 @@ func (p *Manager) createZdbContainerLight(ctx context.Context, device pkg.Device ) env := environment.MustGet() - zdbFlistURL, err := url.JoinPath(env.FlistURL, flistRepo, flistName) + zdbFlistURL, err := url.JoinPath(env.HubURL, flistRepo, flistName) if err != nil { return errors.Wrap(err, "failed to construct zdb flist url") } @@ -952,7 +951,7 @@ func (p *Manager) initialize(ctx context.Context) error { ) // fetching extected hash env := environment.MustGet() - zdbFlistURL, err := url.JoinPath(env.FlistURL, flistRepo, flistName) + zdbFlistURL, err := url.JoinPath(env.HubURL, flistRepo, flistName) if err != nil { return errors.Wrap(err, "failed to construct zdb flist url") } @@ -1019,7 +1018,7 @@ func (p *Manager) initializeLight(ctx context.Context) error { ) // fetching extected hash env := environment.MustGet() - zdbFlistURL, err := url.JoinPath(env.FlistURL, flistRepo, flistName) + zdbFlistURL, err := url.JoinPath(env.HubURL, flistRepo, flistName) if err != nil { return errors.Wrap(err, "failed to construct zdb flist url") } diff --git a/pkg/upgrade/hub/hub.go b/pkg/upgrade/hub/hub.go index 800a7ffa..72f6d36e 100644 --- a/pkg/upgrade/hub/hub.go +++ b/pkg/upgrade/hub/hub.go @@ -16,6 +16,7 @@ import ( "github.com/rs/zerolog/log" "github.com/threefoldtech/0-fs/meta" "github.com/threefoldtech/zosbase/pkg/environment" + "github.com/threefoldtech/zosbase/pkg/kernel" ) const ( @@ -97,11 +98,11 @@ func (h *HubClient) StorageURL() string { // StorageURL return hub storage url func (h *HubClient) HubBaseURL() string { env := environment.MustGet() - return env.HubURL - // if kernel.GetParams().IsV4() { - // return hubv4BaseURL - // } - // return hubBaseURL + hubBaseURL := env.HubURL + if kernel.GetParams().IsV4() { + return env.V4HubURL + } + return hubBaseURL } // Info gets flist info from hub @@ -302,9 +303,10 @@ func (b *Regular) Files(repo string) ([]FileInfo, error) { } env := environment.MustGet() baseURL := env.HubURL - // if kernel.GetParams().IsV4() { - // baseURL = hubv4BaseURL - // } + if kernel.GetParams().IsV4() { + baseURL = env.V4HubURL + } + u, err := url.Parse(baseURL) if err != nil { panic("invalid base url") From 056f9b82ec5590419a1bf4c1a397e4abde87f2c6 Mon Sep 17 00:00:00 2001 From: Eslam-Nawara Date: Wed, 18 Jun 2025 18:26:28 +0300 Subject: [PATCH 10/19] update registrar to load env every time it trys to register --- pkg/registrar/registrar.go | 8 +++++--- pkg/registrar_light/registrar.go | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pkg/registrar/registrar.go b/pkg/registrar/registrar.go index 5f2f312c..d34ad044 100644 --- a/pkg/registrar/registrar.go +++ b/pkg/registrar/registrar.go @@ -71,7 +71,7 @@ type Registrar struct { mutex sync.RWMutex } -func NewRegistrar(ctx context.Context, cl zbus.Client, env environment.Environment, info RegistrationInfo) *Registrar { +func NewRegistrar(ctx context.Context, cl zbus.Client, info RegistrationInfo) *Registrar { r := Registrar{ State{ 0, @@ -82,7 +82,7 @@ func NewRegistrar(ctx context.Context, cl zbus.Client, env environment.Environme sync.RWMutex{}, } - go r.register(ctx, cl, env, info) + go r.register(ctx, cl, info) return &r } @@ -100,7 +100,7 @@ func (r *Registrar) getState() State { // register a node and then blocks forever watching the node account. It tries to re-activate the // account if needed -func (r *Registrar) register(ctx context.Context, cl zbus.Client, env environment.Environment, info RegistrationInfo) { +func (r *Registrar) register(ctx context.Context, cl zbus.Client, info RegistrationInfo) { if app.CheckFlag(app.LimitedCache) { r.setState(FailedState(errors.New("no disks"))) return @@ -116,6 +116,7 @@ func (r *Registrar) register(ctx context.Context, cl zbus.Client, env environmen bo := backoff.WithContext(exp, ctx) register := func() { err := backoff.RetryNotify(func() error { + env := environment.MustGet() nodeID, twinID, err := r.registration(ctx, cl, env, info) if err != nil { r.setState(FailedState(err)) @@ -145,6 +146,7 @@ func (r *Registrar) register(ctx context.Context, cl zbus.Client, env environmen select { case <-ctx.Done(): case <-time.After(monitorAccountEvery): + env := environment.MustGet() if err := r.reActivate(ctx, cl, env); err != nil { log.Error().Err(err).Msg("failed to reactivate account") } diff --git a/pkg/registrar_light/registrar.go b/pkg/registrar_light/registrar.go index 15a0fe5f..84d6b0ce 100644 --- a/pkg/registrar_light/registrar.go +++ b/pkg/registrar_light/registrar.go @@ -71,7 +71,7 @@ type Registrar struct { mutex sync.RWMutex } -func NewRegistrar(ctx context.Context, cl zbus.Client, env environment.Environment, info RegistrationInfo) *Registrar { +func NewRegistrar(ctx context.Context, cl zbus.Client, info RegistrationInfo) *Registrar { r := Registrar{ State{ 0, @@ -81,7 +81,7 @@ func NewRegistrar(ctx context.Context, cl zbus.Client, env environment.Environme }, sync.RWMutex{}, } - go r.register(ctx, cl, env, info) + go r.register(ctx, cl, info) return &r } @@ -99,7 +99,7 @@ func (r *Registrar) getState() State { // register a node and then blocks forever watching the node account. It tries to re-activate the // account if needed -func (r *Registrar) register(ctx context.Context, cl zbus.Client, env environment.Environment, info RegistrationInfo) { +func (r *Registrar) register(ctx context.Context, cl zbus.Client, info RegistrationInfo) { if app.CheckFlag(app.LimitedCache) { r.setState(FailedState(errors.New("no disks"))) return @@ -115,6 +115,7 @@ func (r *Registrar) register(ctx context.Context, cl zbus.Client, env environmen bo := backoff.WithContext(exp, ctx) register := func() { err := backoff.RetryNotify(func() error { + env := environment.MustGet() nodeID, twinID, err := r.registration(ctx, cl, env, info) if err != nil { r.setState(FailedState(err)) @@ -144,6 +145,7 @@ func (r *Registrar) register(ctx context.Context, cl zbus.Client, env environmen select { case <-ctx.Done(): case <-time.After(monitorAccountEvery): + env := environment.MustGet() if err := r.reActivate(ctx, cl, env); err != nil { log.Error().Err(err).Msg("failed to reactivate account") } From 82870dfdb82cd4140dd98387bb576bafeb686232 Mon Sep 17 00:00:00 2001 From: Eslam-Nawara Date: Sun, 22 Jun 2025 17:24:49 +0300 Subject: [PATCH 11/19] update hub to hub.grid.tf again --- bootstrap/bootstrap/README.md | 6 ++-- bootstrap/bootstrap/src/hub.rs | 6 ++-- pkg/container/README.md | 54 +++++++++++++++++----------------- pkg/upgrade/README.md | 2 +- scripts/debug_image.md | 4 +-- scripts/debug_image.sh | 2 +- 6 files changed, 37 insertions(+), 37 deletions(-) diff --git a/bootstrap/bootstrap/README.md b/bootstrap/bootstrap/README.md index a71c1723..e36b4bfd 100644 --- a/bootstrap/bootstrap/README.md +++ b/bootstrap/bootstrap/README.md @@ -19,8 +19,8 @@ will do a multiple stage bootstrap. Currently this is only two stages: - 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 - After internet service is fully started, bootstrap will start to download flists needed for zos node to work properly - As described above bootstrap run in two stages: - - 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 - - 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 + - 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 + - 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 ## Testing in Developer setup @@ -40,6 +40,6 @@ after: - internet ``` -- remove overlay link under `qemu/overlay` +- remove overlay link under `qemu/overlay ` - create a new link pointing to overlay.custom under zos/qemu `ln -s overlay.custom overlay` - boot your vm as normal diff --git a/bootstrap/bootstrap/src/hub.rs b/bootstrap/bootstrap/src/hub.rs index 21217e32..e1de1490 100644 --- a/bootstrap/bootstrap/src/hub.rs +++ b/bootstrap/bootstrap/src/hub.rs @@ -6,7 +6,7 @@ use std::fs::{write, OpenOptions}; use std::io::copy; use std::path::Path; -const HUB: &str = "https://hub.threefold.me"; +const HUB: &str = "https://hub.grid.tf"; pub struct Repo { name: String, @@ -172,7 +172,7 @@ mod tests { let flist = repo.get("test.flist")?; assert_eq!(flist.name, "test.flist"); assert_eq!(flist.kind, Kind::Regular); - assert_eq!(flist.url, "https://hub.threefold.me/azmy/test.flist"); + assert_eq!(flist.url, "https://hub.grid.tf/azmy/test.flist"); Ok(()) } @@ -227,7 +227,7 @@ mod tests { let found = found.unwrap(); assert_eq!(found.name, "test.flist"); - assert_eq!(found.url, "https://hub.threefold.me/azmy/test.flist"); + assert_eq!(found.url, "https://hub.grid.tf/azmy/test.flist"); Ok(()) } diff --git a/pkg/container/README.md b/pkg/container/README.md index b06ca64d..781e4d59 100644 --- a/pkg/container/README.md +++ b/pkg/container/README.md @@ -14,43 +14,43 @@ the container rootfs package main import ( - "github.com/threefoldtech/zbus" - "github.com/threefoldtech/zosbase/pkg" - "github.com/threefoldtech/zosbase/pkg/stubs" + "github.com/threefoldtech/zbus" + "github.com/threefoldtech/zosbase/pkg" + "github.com/threefoldtech/zosbase/pkg/stubs" ) func main() { - client, err := zbus.NewRedisClient("tcp://localhost:6379") - if err != nil { - panic(client) - } + client, err := zbus.NewRedisClient("tcp://localhost:6379") + if err != nil { + panic(client) + } - containerd := stubs.NewContainerModuleStub(client) - namespace := "example" + containerd := stubs.NewContainerModuleStub(client) + namespace := "example" - // make sure u have a network namespace ready using ip - // sudo ip netns add mynetns + // make sure u have a network namespace ready using ip + // sudo ip netns add mynetns - info := pkg.Container{ - Name: "test", - FList: "https://hub.threefold.me/thabet/redis.flist", - Env: []string{}, - Network: pkg.NetworkInfo{Namespace: "mynetns"}, - Mounts: nil, - Entrypoint: "redis-server", - } + info := pkg.Container{ + Name: "test", + FList: "https://hub.grid.tf/thabet/redis.flist", + Env: []string{}, + Network: pkg.NetworkInfo{Namespace: "mynetns"}, + Mounts: nil, + Entrypoint: "redis-server", + } - id, err := containerd.Run(namespace, info) + id, err := containerd.Run(namespace, info) - if err != nil { - panic(err) - } + if err != nil { + panic(err) + } - // DO WORK WITH CONTAINER ... + // DO WORK WITH CONTAINER ... - if err = containerd.Delete(namespace, id); err != nil { - panic(err) - } + if err = containerd.Delete(namespace, id); err != nil { + panic(err) + } } ``` diff --git a/pkg/upgrade/README.md b/pkg/upgrade/README.md index 6ac17006..607906c0 100644 --- a/pkg/upgrade/README.md +++ b/pkg/upgrade/README.md @@ -15,7 +15,7 @@ To run the upgrade module you first need to create a new upgrader instance with | Option | Description | Default | | :------------: | :------------------------------------------: | :-------------------: | | `NoZosUpgrade` | enable or disable the update of zos binaries | enabled by default | -| `Storage` | overrides the default hub storage url | `hub.threefold.me` | +| `Storage` | overrides the default hub storage url | `hub.grid.tf` | | `Zinit` | overrides the default zinit socket | "/var/run/zinit.sock" | ```go diff --git a/scripts/debug_image.md b/scripts/debug_image.md index 518476bd..19f070b6 100644 --- a/scripts/debug_image.md +++ b/scripts/debug_image.md @@ -19,7 +19,7 @@ sudo -i ./install_deps # run image from a directory -./debug_image.sh -d --image https://hub.threefold.me/omarabdulaziz.3bot/ubuntu-jammy.flist +./debug_image.sh -d --image https://hub.grid.tf/omarabdulaziz.3bot/ubuntu-jammy.flist ``` ## Image Types @@ -28,7 +28,7 @@ sudo -i the creation tutorial [here](../docs/manual/zmachine/zmachine.md) - Container: Contains only the rootfs. - in this case wil use kernel and initramfs from cloud container [flist](https://hub.threefold.me/tf-autobuilder/cloud-container-9dba60e.flist.md) + in this case wil use kernel and initramfs from cloud container [flist](https://hub.grid.tf/tf-autobuilder/cloud-container-9dba60e.flist.md) ## Flags diff --git a/scripts/debug_image.sh b/scripts/debug_image.sh index fd8beb2d..fbe9b01f 100755 --- a/scripts/debug_image.sh +++ b/scripts/debug_image.sh @@ -4,7 +4,7 @@ readonly SOCKET="/tmp/virtiofs.sock" readonly CH_API_SOCKET="/tmp/ch-api.sock" readonly OVERLAYFS="/tmp/overlay" -readonly CCFLIST="https://hub.threefold.me/tf-autobuilder/cloud-container-9dba60e.flist" +readonly CCFLIST="https://hub.grid.tf/tf-autobuilder/cloud-container-9dba60e.flist" readonly MACHINE_TYPE="machine" readonly CONTAINER_TYPE="container" From 87e059f0d69a4c4053aa3830fd4e999fb67b0816 Mon Sep 17 00:00:00 2001 From: Eslam-Nawara Date: Sun, 22 Jun 2025 18:06:56 +0300 Subject: [PATCH 12/19] rename default urls --- pkg/environment/config.go | 15 ++++---- pkg/environment/environment.go | 62 ++++++++++++++++------------------ pkg/upgrade/hub/hub.go | 3 +- pkg/upgrade/upgrade_test.go | 3 +- 4 files changed, 40 insertions(+), 43 deletions(-) diff --git a/pkg/environment/config.go b/pkg/environment/config.go index 098bb0cd..7ac5281b 100644 --- a/pkg/environment/config.go +++ b/pkg/environment/config.go @@ -36,14 +36,17 @@ type Config struct { GraphQL []string `json:"graphql_urls"` KycURL string `json:"kyc_url"` RegistrarURL string `json:"registrar_url"` - FlistURL string `json:"flist_url"` - V4FlistURL string `json:"v4_flist_url"` - HubURL string `json:"hub_url"` - V4HubURL string `json:"v4_hub_url"` - HubStorage string `json:"hub_storage"` - V4HubStorage string `json:"v4_hub_storage"` BinRepo string `json:"bin_repo"` GeoipURLs []string `json:"geoip_urls"` + + FlistURL string `json:"flist_url"` + V4FlistURL string `json:"v4_flist_url"` + + HubURL string `json:"hub_url"` + V4HubURL string `json:"v4_hub_url"` + + HubStorage string `json:"hub_storage"` + V4HubStorage string `json:"v4_hub_storage"` } // Merge, updates current config with cfg merging and override config diff --git a/pkg/environment/environment.go b/pkg/environment/environment.go index 51967e70..e2dff0c5 100644 --- a/pkg/environment/environment.go +++ b/pkg/environment/environment.go @@ -18,11 +18,11 @@ import ( const ( baseExtendedURL = "https://raw.githubusercontent.com/threefoldtech/zos-config/main/" - hubURL = "https://hub.threefold.me" - v4HubURL = "https://v4.hub.threefold.me" + defaultHubURL = "https://hub.threefold.me" + defaultV4HubURL = "https://v4.hub.threefold.me" - flistURL = "redis://hub.threefold.me:9900" - v4FlistURL = "redis://v4.hub.threefold.me:9940" + defaultFlistURL = "redis://hub.threefold.me:9900" + defaultV4FlistURL = "redis://v4.hub.threefold.me:9940" defaultHubStorage = "zdb://hub.threefold.me:9900" defaultV4HubStorage = "zdb://v4.hub.threefold.me:9940" @@ -55,11 +55,12 @@ type Environment struct { RunningMode RunMode FlistURL string - HubURL string - V4HubURL string HubStorage string BinRepo string + HubURL string + V4HubURL string + FarmID pkg.FarmID Orphan bool @@ -142,9 +143,9 @@ var ( "https://activation.dev.grid.tf/activation/activate", "https://activation.02.dev.grid.tf/activation/activate", }, - FlistURL: flistURL, - HubURL: hubURL, - V4HubURL: v4HubURL, + FlistURL: defaultFlistURL, + HubURL: defaultHubURL, + V4HubURL: defaultV4HubURL, HubStorage: defaultHubStorage, BinRepo: "tf-zos-v3-bins.dev", GraphQL: []string{ @@ -170,9 +171,9 @@ var ( "https://activation.test.grid.tf/activation/activate", "https://activation.02.test.grid.tf/activation/activate", }, - FlistURL: flistURL, - HubURL: hubURL, - V4HubURL: v4HubURL, + FlistURL: defaultFlistURL, + HubURL: defaultHubURL, + V4HubURL: defaultV4HubURL, HubStorage: defaultHubStorage, BinRepo: "tf-zos-v3-bins.test", GraphQL: []string{ @@ -198,9 +199,9 @@ var ( "https://activation.qa.grid.tf/activation/activate", "https://activation.02.qa.grid.tf/activation/activate", }, - FlistURL: flistURL, - HubURL: hubURL, - V4HubURL: v4HubURL, + FlistURL: defaultFlistURL, + HubURL: defaultHubURL, + V4HubURL: defaultV4HubURL, HubStorage: defaultHubStorage, BinRepo: "tf-zos-v3-bins.qanet", GraphQL: []string{ @@ -226,19 +227,19 @@ var ( // "wss://relay.02.grid.tf", }, ActivationURL: []string{ - "https://activation.grid.threefold.me/activation/activate", "https://activation.grid.tf/activation/activate", "https://activation.02.grid.tf/activation/activate", + "https://activation.grid.threefold.me/activation/activate", }, - FlistURL: flistURL, - HubURL: hubURL, - V4HubURL: v4HubURL, + FlistURL: defaultFlistURL, + HubURL: defaultHubURL, + V4HubURL: defaultV4HubURL, HubStorage: defaultHubStorage, BinRepo: "tf-zos-v3-bins", GraphQL: []string{ - "https://graphql.grid.threefold.me/graphql", "https://graphql.grid.tf/graphql", "https://graphql.02.grid.tf/graphql", + "https://graphql.grid.threefold.me/graphql", }, KycURL: "https://kyc.threefold.me", RegistrarURL: "https://registrar.prod4.threefold.me", @@ -326,29 +327,24 @@ func getEnvironmentFromParams(params kernel.Params) (Environment, error) { if err != nil { // maybe the node can't reach the internet right now // this will enforce node to skip config + // or we can keep retrying untill it can fetch config config = Config{} } - if substrate, ok := params.Get("substrate"); ok { - if len(substrate) > 0 { - env.SubstrateURL = substrate - } + if substrate, ok := params.Get("substrate"); ok && len(substrate) > 0 { + env.SubstrateURL = substrate } else if substrate := config.SubstrateURL; len(substrate) > 0 { env.SubstrateURL = substrate } - if relay, ok := params.Get("relay"); ok { - if len(relay) > 0 { - env.relaysURLs = relay - } + if relay, ok := params.Get("relay"); ok && len(relay) > 0 { + env.relaysURLs = relay } else if relay := config.RelaysURLs; len(relay) > 0 { env.relaysURLs = relay } - if activation, ok := params.Get("activation"); ok { - if len(activation) > 0 { - env.ActivationURL = activation - } + if activation, ok := params.Get("activation"); ok && len(activation) > 0 { + env.ActivationURL = activation } else if activation := config.ActivationURL; len(activation) > 0 { env.ActivationURL = activation } @@ -392,7 +388,7 @@ func getEnvironmentFromParams(params kernel.Params) (Environment, error) { // if the node running v4 chage urls to use v4 hub if params.IsV4() { - env.FlistURL = v4FlistURL + env.FlistURL = defaultV4FlistURL if flist := config.V4FlistURL; len(flist) > 0 { env.FlistURL = flist } diff --git a/pkg/upgrade/hub/hub.go b/pkg/upgrade/hub/hub.go index 72f6d36e..4ba242a8 100644 --- a/pkg/upgrade/hub/hub.go +++ b/pkg/upgrade/hub/hub.go @@ -98,11 +98,10 @@ func (h *HubClient) StorageURL() string { // StorageURL return hub storage url func (h *HubClient) HubBaseURL() string { env := environment.MustGet() - hubBaseURL := env.HubURL if kernel.GetParams().IsV4() { return env.V4HubURL } - return hubBaseURL + return env.HubURL } // Info gets flist info from hub diff --git a/pkg/upgrade/upgrade_test.go b/pkg/upgrade/upgrade_test.go index c31d711d..4fca868c 100644 --- a/pkg/upgrade/upgrade_test.go +++ b/pkg/upgrade/upgrade_test.go @@ -21,8 +21,7 @@ func TestUpgraderDownload(t *testing.T) { } env := environment.MustGet() - hubStorage := env.HubStorage - err := Storage(hubStorage)(up) + err := Storage(env.HubStorage)(up) require.NoError(err) const repo = "azmy.3bot" From 67517d36352fc014e254ff2f1d4c644e4e4401d9 Mon Sep 17 00:00:00 2001 From: Eslam-Nawara Date: Mon, 7 Jul 2025 13:06:21 +0300 Subject: [PATCH 13/19] stop listening changes in storage and flist Changes --- pkg/environment/config.go | 8 ++++---- pkg/environment/environment.go | 37 +++++++++++++++++----------------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/pkg/environment/config.go b/pkg/environment/config.go index 7ac5281b..c26c7a4f 100644 --- a/pkg/environment/config.go +++ b/pkg/environment/config.go @@ -39,14 +39,14 @@ type Config struct { BinRepo string `json:"bin_repo"` GeoipURLs []string `json:"geoip_urls"` - FlistURL string `json:"flist_url"` - V4FlistURL string `json:"v4_flist_url"` + // FlistURL string `json:"flist_url"` + // V4FlistURL string `json:"v4_flist_url"` HubURL string `json:"hub_url"` V4HubURL string `json:"v4_hub_url"` - HubStorage string `json:"hub_storage"` - V4HubStorage string `json:"v4_hub_storage"` + // HubStorage string `json:"hub_storage"` + // V4HubStorage string `json:"v4_hub_storage"` } // Merge, updates current config with cfg merging and override config diff --git a/pkg/environment/environment.go b/pkg/environment/environment.go index e2dff0c5..b3d941be 100644 --- a/pkg/environment/environment.go +++ b/pkg/environment/environment.go @@ -143,9 +143,9 @@ var ( "https://activation.dev.grid.tf/activation/activate", "https://activation.02.dev.grid.tf/activation/activate", }, - FlistURL: defaultFlistURL, HubURL: defaultHubURL, V4HubURL: defaultV4HubURL, + FlistURL: defaultFlistURL, HubStorage: defaultHubStorage, BinRepo: "tf-zos-v3-bins.dev", GraphQL: []string{ @@ -171,9 +171,9 @@ var ( "https://activation.test.grid.tf/activation/activate", "https://activation.02.test.grid.tf/activation/activate", }, - FlistURL: defaultFlistURL, HubURL: defaultHubURL, V4HubURL: defaultV4HubURL, + FlistURL: defaultFlistURL, HubStorage: defaultHubStorage, BinRepo: "tf-zos-v3-bins.test", GraphQL: []string{ @@ -199,9 +199,9 @@ var ( "https://activation.qa.grid.tf/activation/activate", "https://activation.02.qa.grid.tf/activation/activate", }, - FlistURL: defaultFlistURL, HubURL: defaultHubURL, V4HubURL: defaultV4HubURL, + FlistURL: defaultFlistURL, HubStorage: defaultHubStorage, BinRepo: "tf-zos-v3-bins.qanet", GraphQL: []string{ @@ -231,9 +231,9 @@ var ( "https://activation.02.grid.tf/activation/activate", "https://activation.grid.threefold.me/activation/activate", }, - FlistURL: defaultFlistURL, HubURL: defaultHubURL, V4HubURL: defaultV4HubURL, + FlistURL: defaultFlistURL, HubStorage: defaultHubStorage, BinRepo: "tf-zos-v3-bins", GraphQL: []string{ @@ -368,14 +368,15 @@ func getEnvironmentFromParams(params kernel.Params) (Environment, error) { if geoip := config.GeoipURLs; len(geoip) > 0 { env.GeoipURLs = geoip } - - if flist := config.FlistURL; len(flist) > 0 { - env.FlistURL = flist - } - - if storage := config.HubStorage; len(storage) > 0 { - env.HubStorage = storage - } + // flist url and hub urls shouldn't listen to changes in config as long as we can't change it at run time. + // it would cause breakage in vmd that needs a reboot to be recovered. + // if flist := config.FlistURL; len(flist) > 0 { + // env.FlistURL = flist + // } + // + // if storage := config.HubStorage; len(storage) > 0 { + // env.HubStorage = storage + // } if hub := config.HubURL; len(hub) > 0 { env.HubURL = hub @@ -389,14 +390,14 @@ func getEnvironmentFromParams(params kernel.Params) (Environment, error) { // if the node running v4 chage urls to use v4 hub if params.IsV4() { env.FlistURL = defaultV4FlistURL - if flist := config.V4FlistURL; len(flist) > 0 { - env.FlistURL = flist - } + // if flist := config.V4FlistURL; len(flist) > 0 { + // env.FlistURL = flist + // } env.HubStorage = defaultV4HubStorage - if storage := config.V4HubStorage; len(storage) > 0 { - env.HubStorage = storage - } + // if storage := config.V4HubStorage; len(storage) > 0 { + // env.HubStorage = storage + // } } From 4c225071179b6d58c1e87514eed591cb3c37e427 Mon Sep 17 00:00:00 2001 From: Eslam-Nawara Date: Wed, 23 Jul 2025 14:09:36 +0300 Subject: [PATCH 14/19] use []hub urls instead of one url --- pkg/environment/config.go | 2 +- pkg/environment/environment.go | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/environment/config.go b/pkg/environment/config.go index 5b71447f..f72a4255 100644 --- a/pkg/environment/config.go +++ b/pkg/environment/config.go @@ -40,7 +40,7 @@ type Config struct { GeoipURLs []string `json:"geoip_urls"` HubURL []string `json:"hub_url"` - V4HubURL string `json:"v4_hub_url"` + V4HubURL []string `json:"v4_hub_url"` // we should not be supporting flist url or hub storage from zos-config until we can update them on runtime // FlistURL string `json:"flist_url"` diff --git a/pkg/environment/environment.go b/pkg/environment/environment.go index 0419183d..650f132c 100644 --- a/pkg/environment/environment.go +++ b/pkg/environment/environment.go @@ -75,7 +75,6 @@ type Environment struct { GeoipURLs []string KycURL string RegistrarURL string - HubURL string // private vlan to join // if set, zos will use this as its priv vlan @@ -368,7 +367,7 @@ func getEnvironmentFromParams(params kernel.Params) (Environment, error) { env.GeoipURLs = geoip } - // flist url and hub urls shouldn't listen to changes in config as long as we can't change it at run time. + // flist url and hub storage urls shouldn't listen to changes in config as long as we can't change it at run time. // it would cause breakage in vmd that needs a reboot to be recovered. // if flist := config.FlistURL; len(flist) > 0 { // env.FlistURL = flist[0] From 69773c0de9c2e3d338eeee0a191cad30500eb21e Mon Sep 17 00:00:00 2001 From: Eslam-Nawara Date: Wed, 23 Jul 2025 16:23:14 +0300 Subject: [PATCH 15/19] log retry error in perf tests with Debug level --- pkg/perf/cache_test.go | 17 +++++++++-------- pkg/perf/publicip/publicip_task.go | 3 +-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/perf/cache_test.go b/pkg/perf/cache_test.go index 035fa9c8..f2f273a6 100644 --- a/pkg/perf/cache_test.go +++ b/pkg/perf/cache_test.go @@ -63,7 +63,7 @@ func TestPerformanceMonitor_SetCache_Mock(t *testing.T) { ctx := context.Background() taskResult := createTestTaskResult("test-task", uint64(time.Now().Unix())) s.Close() - + err := pm.setCache(ctx, taskResult) assert.Error(t, err) }) @@ -79,7 +79,7 @@ func TestPerformanceMonitor_Get_Mock(t *testing.T) { t.Run("successful Get", func(t *testing.T) { taskResult := createTestTaskResult("test-task", uint64(time.Now().Unix())) - + ctx := context.Background() err := pm.setCache(ctx, taskResult) require.NoError(t, err) @@ -109,7 +109,7 @@ func TestPerformanceMonitor_Get_Mock(t *testing.T) { t.Run("Get with invalid JSON", func(t *testing.T) { s2 := miniredis.RunT(t) pm2, err := newTestPerformanceMonitorWithMockRedis(s2.Addr()) - require.NoError(t, err) + require.NoError(t, err) s2.Set(generateKey("test-task"), "{invalid json") result, err := pm2.Get("test-task") assert.Error(t, err) @@ -164,7 +164,7 @@ func TestPerformanceMonitor_GetAll_Mock(t *testing.T) { ctx := context.Background() task1 := createTestTaskResult("task1", uint64(time.Now().Unix())) task2 := createTestTaskResult("task2", uint64(time.Now().Unix()-100)) - + err := pm.setCache(ctx, task1) require.NoError(t, err) err = pm.setCache(ctx, task2) @@ -173,7 +173,7 @@ func TestPerformanceMonitor_GetAll_Mock(t *testing.T) { results, err := pm.GetAll() assert.NoError(t, err) assert.Len(t, results, 2) - + taskNames := []string{results[0].Name, results[1].Name} assert.Contains(t, taskNames, "task1") assert.Contains(t, taskNames, "task2") @@ -201,12 +201,12 @@ func TestPerformanceMonitor_GetAll_Mock(t *testing.T) { s3 := miniredis.RunT(t) pm3, err := newTestPerformanceMonitorWithMockRedis(s3.Addr()) require.NoError(t, err) - + ctx := context.Background() validTask := createTestTaskResult("valid-task", uint64(time.Now().Unix())) err = pm3.setCache(ctx, validTask) require.NoError(t, err) - + s3.Set(generateKey("corrupted-task"), "{invalid json") results, err := pm3.GetAll() @@ -235,4 +235,5 @@ func TestGenerateKey(t *testing.T) { assert.Equal(t, tc.expected, result) }) } -} \ No newline at end of file +} + diff --git a/pkg/perf/publicip/publicip_task.go b/pkg/perf/publicip/publicip_task.go index feb61a16..e7a41e66 100644 --- a/pkg/perf/publicip/publicip_task.go +++ b/pkg/perf/publicip/publicip_task.go @@ -246,7 +246,7 @@ func isLeastValidNode(ctx context.Context, farmID uint32, substrateGateway *stub // stop at three and quiet output err = exec.CommandContext(ctx, "ping", "-c", "3", "-q", ip).Run() if err != nil { - log.Err(err).Msgf("failed to ping node %d", node.NodeID) + log.Debug().Err(err).Msgf("failed to ping node %d", node.NodeID) continue } return false, nil @@ -336,7 +336,6 @@ func getPublicIPFromSTUN(stunServer string) (net.IP, error) { return } }) - if err != nil { return nil, fmt.Errorf("STUN request failed: %w", err) } From 0168ec553e4366f4612c872a3ef165360009170f Mon Sep 17 00:00:00 2001 From: Eslam-Nawara Date: Wed, 23 Jul 2025 17:09:53 +0300 Subject: [PATCH 16/19] fix lint --- pkg/perf/cache_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/perf/cache_test.go b/pkg/perf/cache_test.go index f2f273a6..46e99b96 100644 --- a/pkg/perf/cache_test.go +++ b/pkg/perf/cache_test.go @@ -110,7 +110,8 @@ func TestPerformanceMonitor_Get_Mock(t *testing.T) { s2 := miniredis.RunT(t) pm2, err := newTestPerformanceMonitorWithMockRedis(s2.Addr()) require.NoError(t, err) - s2.Set(generateKey("test-task"), "{invalid json") + err = s2.Set(generateKey("test-task"), "{invalid json") + require.NoError(t, err) result, err := pm2.Get("test-task") assert.Error(t, err) assert.Contains(t, err.Error(), "failed to unmarshal data from json") @@ -207,7 +208,8 @@ func TestPerformanceMonitor_GetAll_Mock(t *testing.T) { err = pm3.setCache(ctx, validTask) require.NoError(t, err) - s3.Set(generateKey("corrupted-task"), "{invalid json") + err = s3.Set(generateKey("corrupted-task"), "{invalid json") + require.NoError(t, err) results, err := pm3.GetAll() assert.NoError(t, err) @@ -236,4 +238,3 @@ func TestGenerateKey(t *testing.T) { }) } } - From 40a932c89f76ce33480047eb5a5d45e22b1757da Mon Sep 17 00:00:00 2001 From: Eslam-Nawara Date: Sun, 27 Jul 2025 13:55:38 +0300 Subject: [PATCH 17/19] fix typo --- pkg/environment/environment.go | 2 +- pkg/primitives/zdb/zdb.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/environment/environment.go b/pkg/environment/environment.go index 650f132c..fec6a9d7 100644 --- a/pkg/environment/environment.go +++ b/pkg/environment/environment.go @@ -377,7 +377,7 @@ func getEnvironmentFromParams(params kernel.Params) (Environment, error) { // env.HubStorage = storage // } - // maybe we should verify that we're usein a working hub url + // maybe we should verify that we're using a working hub url if hub := config.HubURL; len(hub) > 0 { env.HubURL = hub[0] } diff --git a/pkg/primitives/zdb/zdb.go b/pkg/primitives/zdb/zdb.go index 0fe6929a..19ff4cf5 100644 --- a/pkg/primitives/zdb/zdb.go +++ b/pkg/primitives/zdb/zdb.go @@ -29,6 +29,7 @@ import ( ) const ( + // https://hub.grid.tf/api/flist/tf-autobuilder/threefoldtech-0-db-development.flist/light // To get the latest symlink pointer flistRepo = "tf-autobuilder" flistName = "threefoldtech-0-db-release-v2.0.8-55737c9202.flist" From 222da99f1f95aa3c90b800d63cd42faefc0cb790 Mon Sep 17 00:00:00 2001 From: Eslam-Nawara Date: Wed, 30 Jul 2025 16:05:49 +0300 Subject: [PATCH 18/19] update failed to ping node to warn log level --- pkg/perf/publicip/publicip_task.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/perf/publicip/publicip_task.go b/pkg/perf/publicip/publicip_task.go index e7a41e66..aeb58ecd 100644 --- a/pkg/perf/publicip/publicip_task.go +++ b/pkg/perf/publicip/publicip_task.go @@ -246,7 +246,7 @@ func isLeastValidNode(ctx context.Context, farmID uint32, substrateGateway *stub // stop at three and quiet output err = exec.CommandContext(ctx, "ping", "-c", "3", "-q", ip).Run() if err != nil { - log.Debug().Err(err).Msgf("failed to ping node %d", node.NodeID) + log.Warn().Err(err).Msgf("failed to ping node %d", node.NodeID) continue } return false, nil From 609137ee2517377401e8eb0f27f127b8daff28f6 Mon Sep 17 00:00:00 2001 From: Eslam-Nawara Date: Wed, 30 Jul 2025 17:08:46 +0300 Subject: [PATCH 19/19] support configuring flist/storage urls from zos-config --- pkg/environment/config.go | 8 ++++---- pkg/environment/environment.go | 26 +++++++++++++------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/pkg/environment/config.go b/pkg/environment/config.go index f72a4255..5090bc62 100644 --- a/pkg/environment/config.go +++ b/pkg/environment/config.go @@ -43,10 +43,10 @@ type Config struct { V4HubURL []string `json:"v4_hub_url"` // we should not be supporting flist url or hub storage from zos-config until we can update them on runtime - // FlistURL string `json:"flist_url"` - // V4FlistURL string `json:"v4_flist_url"` - // HubStorage string `json:"hub_storage"` - // V4HubStorage string `json:"v4_hub_storage"` + FlistURL string `json:"flist_url"` + V4FlistURL string `json:"v4_flist_url"` + HubStorage string `json:"hub_storage"` + V4HubStorage string `json:"v4_hub_storage"` } // Merge, updates current config with cfg merging and override config diff --git a/pkg/environment/environment.go b/pkg/environment/environment.go index fec6a9d7..cde63644 100644 --- a/pkg/environment/environment.go +++ b/pkg/environment/environment.go @@ -369,13 +369,13 @@ func getEnvironmentFromParams(params kernel.Params) (Environment, error) { // flist url and hub storage urls shouldn't listen to changes in config as long as we can't change it at run time. // it would cause breakage in vmd that needs a reboot to be recovered. - // if flist := config.FlistURL; len(flist) > 0 { - // env.FlistURL = flist[0] - // } - // - // if storage := config.HubStorage; len(storage) > 0 { - // env.HubStorage = storage - // } + if flist := config.FlistURL; len(flist) > 0 { + env.FlistURL = flist + } + + if storage := config.HubStorage; len(storage) > 0 { + env.HubStorage = storage + } // maybe we should verify that we're using a working hub url if hub := config.HubURL; len(hub) > 0 { @@ -390,14 +390,14 @@ func getEnvironmentFromParams(params kernel.Params) (Environment, error) { // if the node running v4 chage urls to use v4 hub if params.IsV4() { env.FlistURL = defaultV4FlistURL - // if flist := config.V4FlistURL; len(flist) > 0 { - // env.FlistURL = flist - // } + if flist := config.V4FlistURL; len(flist) > 0 { + env.FlistURL = flist + } env.HubStorage = defaultV4HubStorage - // if storage := config.V4HubStorage; len(storage) > 0 { - // env.HubStorage = storage - // } + if storage := config.V4HubStorage; len(storage) > 0 { + env.HubStorage = storage + } } if farmSecret, ok := params.Get("secret"); ok {