Skip to content

Commit

Permalink
feat: parse gpu attributes (#120)
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian authored Jun 9, 2023
1 parent 846c36a commit ab942ee
Show file tree
Hide file tree
Showing 94 changed files with 2,945 additions and 2,247 deletions.
40 changes: 0 additions & 40 deletions .github/workflows/release-dry-run.yaml

This file was deleted.

18 changes: 0 additions & 18 deletions .github/workflows/shellcheck.yaml

This file was deleted.

15 changes: 0 additions & 15 deletions .github/workflows/standardize-yaml.yaml

This file was deleted.

3 changes: 3 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ run:
skip-dirs:
- pkg/client
- ".*/mocks"
- ".*/kubernetes_mock"

# Skip vendor/ etc
skip-dirs-use-default: true

linters-settings:
64 changes: 64 additions & 0 deletions _docs/kustomize/akash-operator-discovery/cluster_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: inventory-operator
labels:
akash.network: "true"
app.kubernetes.io/name: akash
app.kubernetes.io/instance: inventory
app.kubernetes.io/component: operator
rules:
- apiGroups:
- ''
resources:
- namespaces
- nodes
- pods
- events
- persistentvolumes
- persistentvolumeclaims
verbs:
- get
- list
- watch
- apiGroups:
- ''
resources:
- pods/exec
verbs:
- create
- apiGroups:
- storage.k8s.io
resources:
- storageclasses
verbs:
- get
- list
- watch
- apiGroups:
- ceph.rook.io
resources:
- cephclusters
- cephblockpools
verbs:
- get
- list
- watch
- apiGroups:
- akash.network
resources:
- inventoryrequests
verbs:
- get
- list
- watch
- apiGroups:
- akash.network
resources:
- inventories
verbs:
- create
- patch
- get
- list
- watch
46 changes: 46 additions & 0 deletions _docs/kustomize/akash-operator-discovery/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: operator-discovery
namespace: akash-services
labels:
akash.network: "true"
app.kubernetes.io/name: akash
app.kubernetes.io/instance: discovery
app.kubernetes.io/component: operator
spec:
selector:
matchLabels:
app.kubernetes.io/name: akash
app.kubernetes.io/instance: discovery
app.kubernetes.io/component: operator
replicas: 1
revisionHistoryLimit: 1
template:
metadata:
labels:
app: inventory-operator
app.kubernetes.io/name: akash
app.kubernetes.io/instance: discovery
app.kubernetes.io/component: operator
spec:
serviceAccountName: operator-discovery
containers:
- name: operator-discovery
image: ghcr.io/akash-network/provider
args:
- "provider-services"
- "operator"
- "inventory"
imagePullPolicy: IfNotPresent
resources:
limits:
cpu: 500m
memory: 512Mi
requests:
cpu: 100m
memory: 128Mi
ports:
- containerPort: 8080
name: api
protocol: TCP
10 changes: 10 additions & 0 deletions _docs/kustomize/akash-operator-discovery/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: akash-services
resources:
- deployment.yaml
- service.yaml
- rbac.yaml
- service_account.yaml
- cluster_role.yaml
- role-binding.yaml
12 changes: 12 additions & 0 deletions _docs/kustomize/akash-operator-discovery/rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#apiVersion: rbac.authorization.k8s.io/v1
#kind: ClusterRoleBinding
#metadata:
# name: akash-ip-operator-manage-service
#subjects:
# - kind: ServiceAccount
# name: akash-ip-operator
# namespace: akash-services
#roleRef:
# kind: ClusterRole
# name: akash-ip-op-manage-service
# apiGroup: rbac.authorization.k8s.io
17 changes: 17 additions & 0 deletions _docs/kustomize/akash-operator-discovery/role-binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: operator-discovery
labels:
akash.network: "true"
app.kubernetes.io/name: akash
app.kubernetes.io/instance: discovery
app.kubernetes.io/component: operator
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: operator-discovery
subjects:
- kind: ServiceAccount
name: operator-discovery
namespace: akash-services
11 changes: 11 additions & 0 deletions _docs/kustomize/akash-operator-discovery/service_account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: operator-discovery
namespace: akash-services
labels:
akash.network: "true"
app.kubernetes.io/name: akash
app.kubernetes.io/instance: discovery
app.kubernetes.io/component: operator
automountServiceAccountToken: true
2 changes: 1 addition & 1 deletion _docs/kustomize/templates/akash-node/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ secretGenerator:
- cache/config/priv_validator_key.json
- cache/data/priv_validator_state.json

patchesJson6902:
patches:

##
# Configure gateway host in `gateway-host.yaml`. This
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: Kustomization
namespace: akash-services
resources:
- ../../../../../_docs/kustomize/akash-operator-hostname
patchesJson6902:
patches:
- path: docker-image.yaml
target:
kind: Deployment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace: akash-services
resources:
- ../../../../../_docs/kustomize/akash-operator-inventory

patchesJson6902:
patches:
- path: docker-image.yaml
target:
kind: Deployment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: Kustomization
namespace: akash-services
resources:
- ../../../../../_docs/kustomize/akash-operator-ip
patchesJson6902:
patches:
- path: docker-image.yaml
target:
kind: Deployment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ configMapGenerator:
- deployment-runtime-class=none
# - ingress-static-hosts=false

patchesJson6902:
patches:

##
# Configure gateway host in `gateway-host.yaml`. Its value
Expand Down
1 change: 1 addition & 0 deletions _run/common-kube.mk
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ kube-cluster-setup-e2e: $(KUBE_CREATE) kube-cluster-setup-e2e-ci
.PHONY: kube-cluster-setup-e2e-ci
kube-cluster-setup-e2e-ci: \
kube-setup-ingress \
kube-prepare-images \
kube-upload-images \
kustomize-init \
kustomize-deploy-services \
Expand Down
1 change: 1 addition & 0 deletions _run/kube/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ KUBE_SETUP_PREREQUISITES ?= \

KUBE_CLUSTER_CREATE_TARGET := kind
KUBE_SSH_NODE_NAME ?= kind
KUBE_DOCKER_IMAGE_ARCH := $(shell uname -m | sed "s/x86_64/amd64/g")

KUSTOMIZE_INSTALLS ?= \
akash-operator-hostname \
Expand Down
6 changes: 5 additions & 1 deletion bidengine/order.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,11 @@ loop:
}
pricech = runner.Do(metricsutils.ObserveRunner(func() runner.Result {
// Calculate price & bid
return runner.NewResult(o.cfg.PricingStrategy.CalculatePrice(ctx, group.GroupID.Owner, &group.GroupSpec))
priceReq := Request{
Owner: group.GroupID.Owner,
GSpec: &group.GroupSpec,
}
return runner.NewResult(o.cfg.PricingStrategy.CalculatePrice(ctx, priceReq))
}, pricingDuration))
case result := <-pricech:
pricech = nil
Expand Down
19 changes: 11 additions & 8 deletions bidengine/order_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ type orderTestScaffold struct {
reserveCallNotify chan int
}

type testBidPricingStrategy int64

type alwaysFailsBidPricingStrategy struct {
failure error
}

var _ BidPricingStrategy = (*testBidPricingStrategy)(nil)
var _ BidPricingStrategy = (*alwaysFailsBidPricingStrategy)(nil)

func makeMocks(s *orderTestScaffold) {
groupResult := &dtypes.QueryGroupResponse{}
groupResult.Group.GroupSpec.Name = "testGroupName"
Expand Down Expand Up @@ -610,9 +619,7 @@ func Test_ShouldRecognizeLeaseCreatedIfBiddingIsSkipped(t *testing.T) {
require.Nil(t, broadcast)
}

type testBidPricingStrategy int64

func (tbps testBidPricingStrategy) CalculatePrice(_ context.Context, _ string, gspec *dtypes.GroupSpec) (sdk.DecCoin, error) {
func (tbps testBidPricingStrategy) CalculatePrice(_ context.Context, _ Request) (sdk.DecCoin, error) {
return sdk.NewInt64DecCoin(testutil.CoinDenom, int64(tbps)), nil
}

Expand Down Expand Up @@ -642,11 +649,7 @@ func Test_BidOrderUsesBidPricingStrategy(t *testing.T) {
scaffold.cluster.AssertCalled(t, "Unreserve", scaffold.orderID, mock.Anything)
}

type alwaysFailsBidPricingStrategy struct {
failure error
}

func (afbps alwaysFailsBidPricingStrategy) CalculatePrice(_ context.Context, _ string, gspec *dtypes.GroupSpec) (sdk.DecCoin, error) {
func (afbps alwaysFailsBidPricingStrategy) CalculatePrice(_ context.Context, _ Request) (sdk.DecCoin, error) {
return sdk.DecCoin{}, afbps.failure
}

Expand Down
Loading

0 comments on commit ab942ee

Please sign in to comment.