Skip to content

Commit dbae7a5

Browse files
authored
Merge pull request #2415 from threefoldtech/add-all-available-endpoints-to-zos-env
add all available endpoints to zos environment
2 parents afaec4c + 1247394 commit dbae7a5

File tree

5 files changed

+47
-23
lines changed

5 files changed

+47
-23
lines changed

pkg/api_gateway.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
type SubstrateGateway interface {
1111
CreateNode(node substrate.Node) (uint32, error)
1212
CreateTwin(relay string, pk []byte) (uint32, error)
13-
EnsureAccount(activationURL string, termsAndConditionsLink string, termsAndConditionsHash string) (info substrate.AccountInfo, err error)
13+
EnsureAccount(activationURL []string, termsAndConditionsLink string, termsAndConditionsHash string) (info substrate.AccountInfo, err error)
1414
GetContract(id uint64) (substrate.Contract, SubstrateError)
1515
GetContractIDByNameRegistration(name string) (uint64, SubstrateError)
1616
GetFarm(id uint32) (substrate.Farm, error)

pkg/environment/environment.go

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ type Environment struct {
4848
// SINCE RELAYS FOR A NODE IS STORED ON THE CHAIN IN A LIMITED SPACE
4949
// PLEASE MAKE SURE THAT ANY ENV HAS NO MORE THAN FOUR RELAYS CONFIGURED
5050
RelayURL []string
51-
ActivationURL string
51+
ActivationURL []string
5252
GraphQL []string
5353

5454
// private vlan to join
@@ -108,14 +108,18 @@ var (
108108
RunningMode: RunningDev,
109109
SubstrateURL: []string{
110110
"wss://tfchain.dev.grid.tf/",
111+
"wss://tfchain.02.dev.grid.tf",
111112
},
112113
RelayURL: []string{
113114
"wss://relay.dev.grid.tf",
114115
"wss://relay.02.dev.grid.tf",
115116
},
116-
ActivationURL: "https://activation.dev.grid.tf/activation/activate",
117-
FlistURL: "redis://hub.grid.tf:9900",
118-
BinRepo: "tf-zos-v3-bins.dev",
117+
ActivationURL: []string{
118+
"https://activation.dev.grid.tf/activation/activate",
119+
"https://activation.02.dev.grid.tf/activation/activate",
120+
},
121+
FlistURL: "redis://hub.grid.tf:9900",
122+
BinRepo: "tf-zos-v3-bins.dev",
119123
GraphQL: []string{
120124
"https://graphql.dev.grid.tf/graphql",
121125
"https://graphql.02.dev.grid.tf/graphql",
@@ -126,14 +130,18 @@ var (
126130
RunningMode: RunningTest,
127131
SubstrateURL: []string{
128132
"wss://tfchain.test.grid.tf/",
133+
"wss://tfchain.02.test.grid.tf",
129134
},
130135
RelayURL: []string{
131136
"wss://relay.test.grid.tf",
132137
"wss://relay.02.test.grid.tf",
133138
},
134-
ActivationURL: "https://activation.test.grid.tf/activation/activate",
135-
FlistURL: "redis://hub.grid.tf:9900",
136-
BinRepo: "tf-zos-v3-bins.test",
139+
ActivationURL: []string{
140+
"https://activation.test.grid.tf/activation/activate",
141+
"https://activation.02.test.grid.tf/activation/activate",
142+
},
143+
FlistURL: "redis://hub.grid.tf:9900",
144+
BinRepo: "tf-zos-v3-bins.test",
137145
GraphQL: []string{
138146
"https://graphql.test.grid.tf/graphql",
139147
"https://graphql.02.test.grid.tf/graphql",
@@ -148,10 +156,14 @@ var (
148156
},
149157
RelayURL: []string{
150158
"wss://relay.qa.grid.tf",
159+
"wss://relay.02.qa.grid.tf",
151160
},
152-
ActivationURL: "https://activation.qa.grid.tf/activation/activate",
153-
FlistURL: "redis://hub.grid.tf:9900",
154-
BinRepo: "tf-zos-v3-bins.qanet",
161+
ActivationURL: []string{
162+
"https://activation.qa.grid.tf/activation/activate",
163+
"https://activation.02.qa.grid.tf/activation/activate",
164+
},
165+
FlistURL: "redis://hub.grid.tf:9900",
166+
BinRepo: "tf-zos-v3-bins.qanet",
155167
GraphQL: []string{
156168
"https://graphql.qa.grid.tf/graphql",
157169
"https://graphql.02.qa.grid.tf/graphql",
@@ -162,6 +174,7 @@ var (
162174
RunningMode: RunningMain,
163175
SubstrateURL: []string{
164176
"wss://tfchain.grid.tf/",
177+
"wss://tfchain.02.grid.tf",
165178
"wss://02.tfchain.grid.tf/",
166179
"wss://03.tfchain.grid.tf/",
167180
"wss://04.tfchain.grid.tf/",
@@ -170,9 +183,12 @@ var (
170183
"wss://relay.grid.tf",
171184
"wss://relay.02.grid.tf",
172185
},
173-
ActivationURL: "https://activation.grid.tf/activation/activate",
174-
FlistURL: "redis://hub.grid.tf:9900",
175-
BinRepo: "tf-zos-v3-bins",
186+
ActivationURL: []string{
187+
"https://activation.grid.tf/activation/activate",
188+
"https://activation.02.grid.tf/activation/activate",
189+
},
190+
FlistURL: "redis://hub.grid.tf:9900",
191+
BinRepo: "tf-zos-v3-bins",
176192
GraphQL: []string{
177193
"https://graphql.grid.tf/graphql",
178194
"https://graphql.02.grid.tf/graphql",
@@ -253,7 +269,7 @@ func getEnvironmentFromParams(params kernel.Params) (Environment, error) {
253269

254270
if activation, ok := params.Get("activation"); ok {
255271
if len(activation) > 0 {
256-
env.ActivationURL = activation[len(activation)-1]
272+
env.ActivationURL = activation
257273
}
258274
}
259275

pkg/perf/healthcheck/network.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@ const defaultRequestTimeout = 5 * time.Second
1717

1818
func networkCheck(ctx context.Context) []error {
1919
env := environment.MustGet()
20-
servicesUrl := []string{
21-
env.ActivationURL, env.FlistURL,
22-
}
20+
servicesUrl := []string{env.FlistURL}
21+
2322
servicesUrl = append(append(servicesUrl, env.SubstrateURL...), env.RelayURL...)
24-
servicesUrl = append(servicesUrl, env.GraphQL...)
23+
servicesUrl = append(append(servicesUrl, env.ActivationURL...), env.GraphQL...)
2524

2625
var errors []error
2726

pkg/stubs/api_gateway_stub.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (s *SubstrateGatewayStub) CreateTwin(ctx context.Context, arg0 string, arg1
6363
return
6464
}
6565

66-
func (s *SubstrateGatewayStub) EnsureAccount(ctx context.Context, arg0 string, arg1 string, arg2 string) (ret0 tfchainclientgo.AccountInfo, ret1 error) {
66+
func (s *SubstrateGatewayStub) EnsureAccount(ctx context.Context, arg0 []string, arg1 string, arg2 string) (ret0 tfchainclientgo.AccountInfo, ret1 error) {
6767
args := []interface{}{arg0, arg1, arg2}
6868
result, err := s.client.RequestContext(ctx, s.module, s.object, "EnsureAccount", args...)
6969
if err != nil {

pkg/substrate_gateway/substrate_gateway.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,25 @@ func (g *substrateGateway) CreateTwin(relay string, pk []byte) (uint32, error) {
4848
return g.sub.CreateTwin(g.identity, relay, pk)
4949
}
5050

51-
func (g *substrateGateway) EnsureAccount(activationURL string, termsAndConditionsLink string, termsAndConditionsHash string) (info substrate.AccountInfo, err error) {
51+
func (g *substrateGateway) EnsureAccount(activationURL []string, termsAndConditionsLink string, termsAndConditionsHash string) (info substrate.AccountInfo, err error) {
5252
log.Debug().
5353
Str("method", "EnsureAccount").
54-
Str("activation url", activationURL).
54+
Strs("activation url", activationURL).
5555
Str("terms and conditions link", termsAndConditionsLink).
5656
Str("terms and conditions hash", termsAndConditionsHash).
5757
Msg("method called")
5858
g.mu.Lock()
5959
defer g.mu.Unlock()
60-
return g.sub.EnsureAccount(g.identity, activationURL, termsAndConditionsLink, termsAndConditionsHash)
60+
61+
for _, url := range activationURL {
62+
info, err = g.sub.EnsureAccount(g.identity, url, termsAndConditionsLink, termsAndConditionsHash)
63+
// check other activationURL only if EnsureAccount failed with ActivationServiceError
64+
if err == nil || !errors.As(err, &substrate.ActivationServiceError{}) {
65+
return
66+
}
67+
log.Debug().Str("activation url", url).Err(err).Msg("failed to EnsureAccount with ActivationServiceError")
68+
}
69+
return
6170
}
6271

6372
func (g *substrateGateway) GetContract(id uint64) (result substrate.Contract, serr pkg.SubstrateError) {

0 commit comments

Comments
 (0)