Skip to content

Commit 1474fe3

Browse files
committed
sdl: lookup pricing by compute profile name
* add `akash deployment validate <deployment.yml>` * use micro akash instead of milli akash fixes #339
1 parent 16ad5d5 commit 1474fe3

File tree

11 files changed

+87
-21
lines changed

11 files changed

+87
-21
lines changed

_docs/deployment.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,16 @@ profiles:
7474
attributes:
7575
region: us-west
7676
pricing:
77-
web: .001
78-
db-master: 0.05
79-
db-slave: 0.05
80-
db-pool: 0.03
77+
web: 0.000010
78+
db: 0.000050
79+
db-pool: 0.000030
8180
eastcoast:
8281
attributes:
8382
region: us-east
8483
pricing:
85-
web: .003
86-
db-slave: 0.06
87-
db-pool: 0.04
84+
web: 0.000030
85+
db: 0.000060
86+
db-pool: 0.000040
8887

8988
deployment:
9089

_integration/cmp/account.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package cmp
22

33
import (
4-
"strconv"
4+
"fmt"
55

66
"github.com/ovrclk/gestalt"
77
g "github.com/ovrclk/gestalt/builder"
@@ -18,8 +18,9 @@ func accountBalance(key key, amount int64) gestalt.Component {
1818
}
1919

2020
func accountSendTo(from key, to key, amount int64) gestalt.Component {
21+
value := fmt.Sprintf("%0.06f", float64(amount)/float64(1000000))
2122
return akash("send-to",
22-
"send", strconv.FormatInt(amount, 10), to.addr.Var(), "-k", from.name.Name()).
23+
"send", value, to.addr.Var(), "-k", from.name.Name()).
2324
WithMeta(g.Require(to.addr.Name()))
2425
}
2526

@@ -32,6 +33,6 @@ func groupAccountSend(key key) gestalt.Component {
3233
Run(accountBalance(key, start)).
3334
Run(accountSendTo(key, other, amount)).
3435
Run(g.Retry(5).
35-
Run(accountBalance(key, start-1000*amount))).
36-
Run(accountBalance(other, 1000*amount))
36+
Run(accountBalance(key, start-amount))).
37+
Run(accountBalance(other, amount))
3738
}

_run/kube/deployment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ profiles:
2424
attributes:
2525
region: us-west
2626
pricing:
27-
web: .101
27+
web: .002000
2828

2929
deployment:
3030
web:

_run/multi/deployment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ profiles:
2424
attributes:
2525
region: us-west
2626
pricing:
27-
web: .1
27+
web: .000100
2828

2929
deployment:
3030
web:

cmd/akash/deployment.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ func deploymentCommand() *cobra.Command {
3232
cmd.AddCommand(closeDeploymentCommand())
3333
cmd.AddCommand(statusDeploymentCommand())
3434
cmd.AddCommand(sendManifestCommand())
35+
cmd.AddCommand(validateDeploymentCommand())
3536

3637
return cmd
3738
}
@@ -371,6 +372,26 @@ func sendManifest(session session.Session, cmd *cobra.Command, args []string) er
371372
return doSendManifest(session, signer, depAddr.ID(), mani)
372373
}
373374

375+
func validateDeploymentCommand() *cobra.Command {
376+
cmd := &cobra.Command{
377+
Use: "validate <deployment-file>",
378+
Short: "validate deployment file",
379+
Args: cobra.ExactArgs(1),
380+
RunE: session.WithSession(doValidateDeploymentCommand),
381+
}
382+
383+
return cmd
384+
}
385+
386+
func doValidateDeploymentCommand(session session.Session, cmd *cobra.Command, args []string) error {
387+
_, err := sdl.ReadFile(args[0])
388+
if err != nil {
389+
return err
390+
}
391+
fmt.Println("ok")
392+
return nil
393+
}
394+
374395
func manifestValidateResources(session session.Session, mani *types.Manifest, daddr []byte) error {
375396
dgroups, err := session.QueryClient().DeploymentGroupsForDeployment(session.Ctx(), daddr)
376397
if err != nil {

denom/denom.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
)
66

77
const (
8-
miliAkashPerAkash = 1000
8+
microAkashPerAkash = 1000000
99
)
1010

1111
// ToBase converts a unit of currency to its equivalent value in base denomination
@@ -14,6 +14,6 @@ func ToBase(sval string) (uint64, error) {
1414
if err != nil {
1515
return 0, err
1616
}
17-
amount := akash * miliAkashPerAkash
17+
amount := akash * microAkashPerAkash
1818
return uint64(amount), nil
1919
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
version: "1.0"
3+
4+
services:
5+
webapp:
6+
image: quay.io/ovrclk/demo-app
7+
expose:
8+
- port: 80
9+
as: 80
10+
to:
11+
- global: true
12+
13+
profiles:
14+
compute:
15+
web:
16+
cpu: "100m"
17+
memory: "512Mi"
18+
disk: "512Mi"
19+
placement:
20+
san-jose:
21+
attributes:
22+
region: sjc
23+
pricing:
24+
web: 0.000025
25+
26+
deployment:
27+
webapp:
28+
san-jose:
29+
profile: web
30+
count: 1

sdl/_testdata/simple.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ profiles:
2222
attributes:
2323
region: us-west
2424
pricing:
25-
web: .8
25+
web: 0.005000
2626

2727
deployment:
2828
web:

sdl/v1.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ func (sdl *v1) DeploymentGroups() ([]*types.GroupSpec, error) {
119119
return nil, fmt.Errorf("%v.%v: no placement profile named %v", svcName, placementName, placementName)
120120
}
121121

122-
price, ok := infra.Pricing[svcName]
122+
price, ok := infra.Pricing[svcdepl.Profile]
123123
if !ok {
124-
return nil, fmt.Errorf("%v.%v: no pricing for service %v", svcName, placementName, svcName)
124+
return nil, fmt.Errorf("%v.%v: no pricing for profile %v", svcName, placementName, svcdepl.Profile)
125125
}
126126

127127
group := groups[placementName]

sdl/v1_test.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func Test_v1_Parse_simple(t *testing.T) {
4040

4141
assert.Equal(t, types.ResourceGroup{
4242
Count: 2,
43-
Price: 800,
43+
Price: 0x1388,
4444
Unit: types.ResourceUnit{
4545
CPU: 100,
4646
Memory: 128 * unit.Mi,
@@ -73,3 +73,16 @@ func Test_v1_Parse_simple(t *testing.T) {
7373
}, mani.GetGroups()[0])
7474

7575
}
76+
77+
func Test_v1_Parse_ProfileNameNotServiceName(t *testing.T) {
78+
sdl, err := sdl.ReadFile("./_testdata/profile-svc-name-mismatch.yml")
79+
require.NoError(t, err)
80+
81+
dgroups, err := sdl.DeploymentGroups()
82+
require.NoError(t, err)
83+
assert.Len(t, dgroups, 1)
84+
85+
mani, err := sdl.Manifest()
86+
require.NoError(t, err)
87+
assert.Len(t, mani.Groups, 1)
88+
}

0 commit comments

Comments
 (0)