Skip to content

Commit 5b494c1

Browse files
authored
Merge pull request #1262 from threefoldtech/development-fix-grid-cli-deploy-with-node-id
fix grid cli deployments conflict when deploying with node id
2 parents 2f8fbe5 + 13a29a2 commit 5b494c1

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

grid-cli/cmd/deploy_vm.go

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"context"
66
"fmt"
77
"os"
8+
"slices"
89

910
"github.com/pkg/errors"
1011
"github.com/rs/zerolog/log"
@@ -13,6 +14,8 @@ import (
1314
"github.com/threefoldtech/tfgrid-sdk-go/grid-cli/internal/config"
1415
"github.com/threefoldtech/tfgrid-sdk-go/grid-cli/internal/filters"
1516
"github.com/threefoldtech/tfgrid-sdk-go/grid-client/deployer"
17+
client "github.com/threefoldtech/tfgrid-sdk-go/grid-client/node"
18+
"github.com/threefoldtech/tfgrid-sdk-go/grid-client/subi"
1619
"github.com/threefoldtech/tfgrid-sdk-go/grid-client/workloads"
1720
"github.com/threefoldtech/tfgrid-sdk-go/grid-client/zos"
1821
)
@@ -130,7 +133,16 @@ var deployVMCmd = &cobra.Command{
130133
}
131134

132135
// if no public ips or yggdrasil then we should go for the light deployment
133-
if !ipv4 && !ipv6 && !ygg {
136+
isLight := !ipv4 && !ipv6 && !ygg
137+
138+
if node != 0 {
139+
isLight, err = isZos4Node(cmd.Context(), t.NcPool, t.SubstrateConn, node)
140+
if err != nil {
141+
log.Fatal().Err(err).Send()
142+
}
143+
}
144+
145+
if isLight {
134146
vm := workloads.VMLight{
135147
Name: name,
136148
EnvVars: env,
@@ -321,3 +333,16 @@ func executeVMLight(
321333

322334
return nil
323335
}
336+
337+
func isZos4Node(ctx context.Context, client client.NodeClientGetter, sub subi.SubstrateExt, node uint32) (isLight bool, err error) {
338+
cli, err := client.GetNodeClient(sub, node)
339+
if err != nil {
340+
return
341+
}
342+
feat, err := cli.SystemGetNodeFeatures(ctx)
343+
if err != nil {
344+
return
345+
}
346+
347+
return slices.Contains(feat, zos.NetworkLightType), nil
348+
}

0 commit comments

Comments
 (0)