Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cluster/kube/builder): "ram" storage class #199

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions _run/kube/provider.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ attributes:
value: true
- key: capabilities/storage/2/class
value: beta2
- key: capabilities/storage/3/class
value: ram
- key: capabilities/storage/3/persistent
value: false

1 change: 1 addition & 0 deletions cluster/kube/builder/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func (b *deployment) Create() (*appsv1.Deployment, error) { // nolint:golint,unp
AutomountServiceAccountToken: &falseValue,
Containers: []corev1.Container{b.container()},
ImagePullSecrets: b.imagePullSecrets(),
Volumes: b.volumes(),
},
},
},
Expand Down
1 change: 1 addition & 0 deletions cluster/kube/builder/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func (b *statefulSet) Create() (*appsv1.StatefulSet, error) { // nolint:golint,u
AutomountServiceAccountToken: &falseValue,
Containers: []corev1.Container{b.container()},
ImagePullSecrets: b.imagePullSecrets(),
Volumes: b.volumes(),
},
},
VolumeClaimTemplates: b.persistentVolumeClaims(),
Expand Down
36 changes: 36 additions & 0 deletions cluster/kube/builder/workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,42 @@ func (b *Workload) container() corev1.Container {
return kcontainer
}

// Return RAM volumes
func (b *Workload) volumes() []corev1.Volume {
var volumes []corev1.Volume // nolint:prealloc

service := &b.deployment.ManifestGroup().Services[b.serviceIdx]

for _, storage := range service.Resources.Storage {

// Only RAM volumes
sclass, ok := storage.Attributes.Find(sdl.StorageAttributeClass).AsString()
if !ok || sclass != sdl.StorageClassRAM {
continue
}

// No persistent volumes
persistent, ok := storage.Attributes.Find(sdl.StorageAttributePersistent).AsBool()
if !ok || persistent {
continue
}

size := resource.NewQuantity(storage.Quantity.Val.Int64(), resource.DecimalSI).DeepCopy()

volumes = append(volumes, corev1.Volume{
Name: fmt.Sprintf("%s-%s", service.Name, storage.Name),
VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{
Medium: corev1.StorageMediumMemory,
SizeLimit: &size,
},
},
})
}

return volumes
}

func (b *Workload) persistentVolumeClaims() []corev1.PersistentVolumeClaim {
var pvcs []corev1.PersistentVolumeClaim // nolint:prealloc

Expand Down
18 changes: 11 additions & 7 deletions cluster/kube/operators/clients/inventory/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (inv *inventory) tryAdjust(node int, res *types.Resources) (*crd.SchedulerP
return nil, false, true
}

if !tryAdjustMemory(&nd.Resources.Memory.Quantity, res.Memory) {
if !nd.Resources.Memory.Quantity.SubNLZ(res.Memory.Quantity) {
return nil, false, true
}

Expand All @@ -66,9 +66,17 @@ func (inv *inventory) tryAdjust(node int, res *types.Resources) (*crd.SchedulerP
}

if !attrs.Persistent {
if !tryAdjustEphemeralStorage(&nd.Resources.EphemeralStorage, &res.Storage[i]) {
return nil, false, true
if attrs.Class == "ram" {
if !nd.Resources.Memory.Quantity.SubNLZ(storage.Quantity) {
return nil, false, true
}
} else {
// ephemeral storage
if !tryAdjustEphemeralStorage(&nd.Resources.EphemeralStorage, &res.Storage[i]) {
return nil, false, true
}
}

continue
}

Expand Down Expand Up @@ -197,10 +205,6 @@ func tryAdjustGPU(rp *inventoryV1.GPU, res *types.GPU, sparams *crd.SchedulerPar
return false
}

func tryAdjustMemory(rp *inventoryV1.ResourcePair, res *types.Memory) bool {
return rp.SubNLZ(res.Quantity)
}

func tryAdjustEphemeralStorage(rp *inventoryV1.ResourcePair, res *types.Storage) bool {
return rp.SubNLZ(res.Quantity)
}
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ module github.com/akash-network/provider
go 1.21

require (
github.com/akash-network/akash-api v0.0.56
github.com/akash-network/node v0.31.0-rc0
github.com/akash-network/akash-api v0.0.60
github.com/akash-network/node v0.32.2
github.com/avast/retry-go/v4 v4.5.0
github.com/blang/semver/v4 v4.0.0
github.com/boz/go-lifecycle v0.1.1
github.com/cosmos/cosmos-sdk v0.45.16
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f
github.com/fsnotify/fsnotify v1.7.0
github.com/go-andiamo/splitter v1.2.5
github.com/go-kit/kit v0.12.0
github.com/go-logr/logr v1.2.4
github.com/go-logr/zapr v1.2.4
Expand Down
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -197,16 +197,16 @@ github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia
github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM=
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw=
github.com/akash-network/akash-api v0.0.56 h1:dUiDR7DXeMXgh9xyxCik4gznTsjSJhi8Pq3iPcZoqSc=
github.com/akash-network/akash-api v0.0.56/go.mod h1:pNr61L4+0sheol7ZK0HjgK3rxpIAbYBGq1w1oH4B0+M=
github.com/akash-network/akash-api v0.0.60 h1:SIhOB8jUt3cX9thf4GTjouEqwX7sNU4Oqx+hEFdPzbA=
github.com/akash-network/akash-api v0.0.60/go.mod h1:pNr61L4+0sheol7ZK0HjgK3rxpIAbYBGq1w1oH4B0+M=
github.com/akash-network/cometbft v0.34.27-akash h1:V1dApDOr8Ee7BJzYyQ7Z9VBtrAul4+baMeA6C49dje0=
github.com/akash-network/cometbft v0.34.27-akash/go.mod h1:BcCbhKv7ieM0KEddnYXvQZR+pZykTKReJJYf7YC7qhw=
github.com/akash-network/ledger-go v0.14.3 h1:LCEFkTfgGA2xFMN2CtiKvXKE7dh0QSM77PJHCpSkaAo=
github.com/akash-network/ledger-go v0.14.3/go.mod h1:NfsjfFvno9Kaq6mfpsKz4sqjnAVVEsVsnBJfKB4ueAs=
github.com/akash-network/ledger-go/cosmos v0.14.4 h1:h3WiXmoKKs9wkj1LHcJ12cLjXXg6nG1fp+UQ5+wu/+o=
github.com/akash-network/ledger-go/cosmos v0.14.4/go.mod h1:SjAfheQTE4rWk0ir+wjbOWxwj8nc8E4AZ08NdsvYG24=
github.com/akash-network/node v0.31.0-rc0 h1:Ls54ebvbHvBGoWEj1M6VatZmBHgUl2XkZL2XE4S0XZQ=
github.com/akash-network/node v0.31.0-rc0/go.mod h1:wGWR5LewA1nq+O/Sib5kYfBCLVCAqS83oWZ/RuHGYDY=
github.com/akash-network/node v0.32.2 h1:/o/hgOYUwTmAOp2ENpx0E/L2qaSCdw3Sh6TBXEhKLTE=
github.com/akash-network/node v0.32.2/go.mod h1:Rwfi2uCMQr+3dsBMl8Mcd4p4nlG+1sVOM8TDbbeMXsE=
github.com/alecthomas/participle/v2 v2.0.0-alpha7 h1:cK4vjj0VSgb3lN1nuKA5F7dw+1s1pWBe5bx7nNCnN+c=
github.com/alecthomas/participle/v2 v2.0.0-alpha7/go.mod h1:NumScqsC42o9x+dGj8/YqsIfhrIQjFEOFovxotbBirA=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
Expand Down Expand Up @@ -628,6 +628,8 @@ github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0
github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q=
github.com/glycerine/go-unsnap-stream v0.0.0-20180323001048-9f0cb55181dd/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE=
github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24=
github.com/go-andiamo/splitter v1.2.5 h1:P3NovWMY2V14TJJSolXBvlOmGSZo3Uz+LtTl2bsV/eY=
github.com/go-andiamo/splitter v1.2.5/go.mod h1:8WHU24t9hcMKU5FXDQb1hysSEC/GPuivIp0uKY1J8gw=
github.com/go-asn1-ber/asn1-ber v1.3.1/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98=
github.com/go-chi/chi/v5 v5.0.0/go.mod h1:BBug9lr0cqtdAhsu6R4AAdvufI0/XBzAQSsUqJpoZOs=
Expand Down
3 changes: 1 addition & 2 deletions integration/container2container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ func (s *E2EContainerToContainer) TestE2EContainerToContainer() {
s.validator.ClientCtx,
s.keyTenant.GetAddress(),
deploymentPath,
cliGlobalFlags(deploymentUAktDeposit,
fmt.Sprintf("--dseq=%v", deploymentID.DSeq))...,
cliGlobalFlags(fmt.Sprintf("--dseq=%v", deploymentID.DSeq))...,
)
s.Require().NoError(err)
s.Require().NoError(s.waitForBlocksCommitted(7))
Expand Down
25 changes: 13 additions & 12 deletions integration/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,23 @@ type IntegrationTestSuite struct {
ctx context.Context
ctxCancel context.CancelFunc

deploymentMinDeposit sdk.DecCoin

appHost string
appPort string

ipMarketplace bool
}

const (
defaultGasPrice = "0.03uakt"
defaultGasAdjustment = "1.4"
uaktMinDeposit = "5000000uakt"
axlUSDCDenom = "ibc/12C6A0C374171B595A0A9E18B83FA09D295FB1F2D8C6DAA3AC28683471752D84"
axlUSCDMinDeposit = "5000000" + axlUSDCDenom
defaultGasPrice = "0.03uakt"
defaultGasAdjustment = "1.4"
axlUSDCDenom = "ibc/12C6A0C374171B595A0A9E18B83FA09D295FB1F2D8C6DAA3AC28683471752D84"
axlUSCDMinDepositAmount = 5000000
)

var (
deploymentUAktDeposit = fmt.Sprintf("--deposit=%s", uaktMinDeposit)
axlUSCDMinDeposit = fmt.Sprintf("%d%s", axlUSCDMinDepositAmount, axlUSDCDenom)
deploymentAxlUSDCDeposit = fmt.Sprintf("--deposit=%s", axlUSCDMinDeposit)
)

Expand Down Expand Up @@ -142,7 +143,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
// Send coins value
sendTokens := sdk.Coins{
sdk.NewCoin(s.cfg.BondDenom, mtypes.DefaultBidMinDeposit.Amount.MulRaw(4)),
sdk.NewCoin(axlUSDCDenom, mtypes.DefaultBidMinDeposit.Amount.MulRaw(4)),
sdk.NewCoin(axlUSDCDenom, sdk.NewInt(axlUSCDMinDepositAmount*4)),
}

// Setup a Provider key
Expand Down Expand Up @@ -259,10 +260,8 @@ func (s *IntegrationTestSuite) SetupSuite() {
context.Background(),
s.validator.ClientCtx,
s.keyTenant.GetAddress(),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
fmt.Sprintf("--gas=%d", flags.DefaultGasLimit),
cliGlobalFlags(fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock))...,
)
s.Require().NoError(err)

Expand Down Expand Up @@ -482,7 +481,8 @@ func (s *IntegrationTestSuite) closeDeployments() int {
res, err := deploycli.TxCloseDeploymentExec(
s.validator.ClientCtx,
keyTenant.GetAddress(),
cliGlobalFlags(fmt.Sprintf("--owner=%s", createdDep.Groups[0].GroupID.Owner),
cliGlobalFlags(
fmt.Sprintf("--owner=%s", createdDep.Groups[0].GroupID.Owner),
fmt.Sprintf("--dseq=%v", createdDep.Deployment.DeploymentID.DSeq))...,
)
s.Require().NoError(err)
Expand Down Expand Up @@ -579,6 +579,7 @@ func TestIntegrationTestSuite(t *testing.T) {
suite.Run(t, new(E2EPersistentStorageDefault))
suite.Run(t, new(E2EPersistentStorageBeta2))
suite.Run(t, new(E2EPersistentStorageDeploymentUpdate))
suite.Run(t, new(E2EStorageClassRam))
suite.Run(t, new(E2EMigrateHostname))
suite.Run(t, new(E2EJWTServer))
suite.Run(t, new(E2ECustomCurrency))
Expand Down
3 changes: 1 addition & 2 deletions integration/escrow_monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ func (s *E2EEscrowMonitor) TestE2EEscrowMonitor() {
s.validator.ClientCtx,
s.keyTenant.GetAddress(),
deploymentPath,
cliGlobalFlags(deploymentUAktDeposit,
fmt.Sprintf("--dseq=%v", deploymentID.DSeq))...,
cliGlobalFlags(fmt.Sprintf("--dseq=%v", deploymentID.DSeq))...,
)
s.Require().NoError(err)
s.Require().NoError(s.waitForBlocksCommitted(7))
Expand Down
4 changes: 2 additions & 2 deletions integration/persistentstorage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (s *E2EPersistentStorageDefault) TestDefaultStorageClass() {
s.validator.ClientCtx,
s.keyTenant.GetAddress(),
deploymentPath,
cliGlobalFlags(deploymentUAktDeposit, fmt.Sprintf("--dseq=%v", deploymentID.DSeq))...,
cliGlobalFlags(fmt.Sprintf("--dseq=%v", deploymentID.DSeq))...,
)
s.Require().NoError(err)
s.Require().NoError(s.waitForBlocksCommitted(7))
Expand Down Expand Up @@ -151,7 +151,7 @@ func (s *E2EPersistentStorageBeta2) TestDedicatedStorageClass() {
s.validator.ClientCtx,
s.keyTenant.GetAddress(),
deploymentPath,
cliGlobalFlags(deploymentUAktDeposit, fmt.Sprintf("--dseq=%v", deploymentID.DSeq))...,
cliGlobalFlags(fmt.Sprintf("--dseq=%v", deploymentID.DSeq))...,
)
s.Require().NoError(err)
s.Require().NoError(s.waitForBlocksCommitted(7))
Expand Down
Loading
Loading