Skip to content

Commit

Permalink
feat: act
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferenc Sárai committed Jul 31, 2024
1 parent 8a3d6dd commit 32895eb
Show file tree
Hide file tree
Showing 61 changed files with 1,653 additions and 2,175 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup Go
if: matrix.os == 'ubuntu-latest'
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
cache: false
go-version-file: go.mod
- name: Setup Go
if: matrix.os == 'macos-latest' || matrix.os == 'windows-latest'
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
cache: true
go-version-file: go.mod
Expand All @@ -32,9 +32,9 @@ jobs:
run: git config --global core.autocrlf false
- name: Lint
if: matrix.os == 'ubuntu-latest'
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v4
with:
version: v1.54.2
version: v1.56.2
args: --timeout 10m
skip-cache: false
- name: Vet
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Run GoReleaser
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21 AS build
FROM golang:1.22 AS build

WORKDIR /src
# enable modules caching in separate layer
Expand All @@ -8,7 +8,7 @@ COPY . ./

RUN make binary

FROM debian:12.1-slim
FROM debian:12.5-slim

ENV DEBIAN_FRONTEND noninteractive

Expand Down
6 changes: 5 additions & 1 deletion cmd/beekeeper/cmd/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ func (c *command) initCheckCmd() (err error) {
}

// setup cluster
cluster, err := c.setupCluster(ctx, c.globalConfig.GetString(optionNameClusterName), c.config, c.globalConfig.GetBool(optionNameCreateCluster))
cluster, err := c.setupCluster(ctx,
c.globalConfig.GetString(optionNameClusterName),
c.config,
c.globalConfig.GetBool(optionNameCreateCluster),
)
if err != nil {
return fmt.Errorf("cluster setup: %w", err)
}
Expand Down
27 changes: 20 additions & 7 deletions cmd/beekeeper/cmd/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ func (c *command) setupCluster(ctx context.Context, clusterName string, cfg *con
var fundOpts orchestration.FundingOptions

if startCluster {
if clusterConfig.IsUsingStaticEndpoints() {
return nil, errors.New("static endpoints are not supported for starting the cluster")
}
if chainNodeEndpoint = c.globalConfig.GetString(optionNameChainNodeEndpoint); chainNodeEndpoint == "" {
return nil, errors.New("chain node endpoint (geth-url) not provided")
}
Expand Down Expand Up @@ -182,13 +185,14 @@ func ensureFundingDefaults(fundOpts orchestration.FundingOptions, log logging.Lo

func configureCluster(clusterConfig config.Cluster, c *command) orchestration.Cluster {
clusterOpts := clusterConfig.Export()
clusterOpts.K8SClient = c.k8sClient
clusterOpts.SwapClient = c.swapClient
clusterOpts.K8SClient = c.k8sClient
return orchestrationK8S.NewCluster(clusterConfig.GetName(), clusterOpts, c.log)
}

func setupNodes(ctx context.Context, clusterConfig config.Cluster, cfg *config.Config, bootnode bool, cluster orchestration.Cluster, startCluster bool, bootnodesIn string, nodeResultCh chan nodeResult) (fundAddresses []string, bootnodesOut string, err error) {
var nodeCount uint32

for ngName, v := range clusterConfig.GetNodeGroups() {

if (v.Mode != bootnodeMode && bootnode) || (v.Mode == bootnodeMode && !bootnode) {
Expand Down Expand Up @@ -220,6 +224,17 @@ func setupNodes(ctx context.Context, clusterConfig config.Cluster, cfg *config.C
return nil, "", fmt.Errorf("get node group: %w", err)
}

if clusterConfig.IsUsingStaticEndpoints() {
for nodeName, endpoint := range v.GetEndpoints() {
beeOpt := orchestration.WithURL(endpoint.APIURL)
nodeCount++
go setupOrAddNode(ctx, false, ng, nodeName, orchestration.NodeOptions{
Config: &bConfig,
}, nodeResultCh, beeOpt)
}
continue
}

for i, node := range v.Nodes {
// set node name
nodeName := fmt.Sprintf("%s-%d", ngName, i)
Expand All @@ -228,7 +243,6 @@ func setupNodes(ctx context.Context, clusterConfig config.Cluster, cfg *config.C
}

var nodeOpts orchestration.NodeOptions

if bootnode {
// set bootnodes
bConfig.Bootnodes = fmt.Sprintf(node.Bootnodes, clusterConfig.GetNamespace()) // TODO: improve bootnode management, support more than 2 bootnodes
Expand All @@ -237,17 +251,16 @@ func setupNodes(ctx context.Context, clusterConfig config.Cluster, cfg *config.C
} else {
nodeOpts = setupNodeOptions(node, nil)
}

nodeCount++
go setupOrAddNode(ctx, startCluster, ng, nodeName, nodeOpts, nodeResultCh)
go setupOrAddNode(ctx, startCluster, ng, nodeName, nodeOpts, nodeResultCh, orchestration.WithNoOptions())
}

if len(v.Nodes) == 0 && !bootnode {
for i := 0; i < v.Count; i++ {
// set node name
nodeName := fmt.Sprintf("%s-%d", ngName, i)
nodeCount++
go setupOrAddNode(ctx, startCluster, ng, nodeName, orchestration.NodeOptions{}, nodeResultCh)
go setupOrAddNode(ctx, startCluster, ng, nodeName, orchestration.NodeOptions{}, nodeResultCh, orchestration.WithNoOptions())
}
}
}
Expand All @@ -267,12 +280,12 @@ func setupNodes(ctx context.Context, clusterConfig config.Cluster, cfg *config.C
return fundAddresses, bootnodesOut, nil
}

func setupOrAddNode(ctx context.Context, startCluster bool, ng orchestration.NodeGroup, nName string, nodeOpts orchestration.NodeOptions, ch chan<- nodeResult) {
func setupOrAddNode(ctx context.Context, startCluster bool, ng orchestration.NodeGroup, nName string, nodeOpts orchestration.NodeOptions, ch chan<- nodeResult, beeOpt orchestration.BeeClientOption) {
if startCluster {
ethAddress, err := ng.SetupNode(ctx, nName, nodeOpts)
ch <- nodeResult{ethAddress: ethAddress, err: err}
} else {
err := ng.AddNode(ctx, nName, nodeOpts)
err := ng.AddNode(ctx, nName, nodeOpts, beeOpt)
ch <- nodeResult{err: err}
}
}
Expand Down
10 changes: 6 additions & 4 deletions cmd/beekeeper/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ const (
optionNameTracingHost = "tracing-host"
optionNameTracingPort = "tracing-port"
optionNameTracingServiceName = "tracing-service-name"
optionNameEnableK8S = "enable-k8s"
optionNameInCluster = "in-cluster"
optionNameKubeconfig = "kubeconfig"
)

func init() {
Expand Down Expand Up @@ -309,10 +312,9 @@ func (c *command) preRunE(cmd *cobra.Command, args []string) (err error) {
}

func (c *command) setK8S() (err error) {
if c.globalConfig.GetBool("enable-k8s") {

inCluster := c.globalConfig.GetBool("in-cluster")
kubeconfigPath := c.globalConfig.GetString("kubeconfig")
if c.globalConfig.GetBool(optionNameEnableK8S) {
inCluster := c.globalConfig.GetBool(optionNameInCluster)
kubeconfigPath := c.globalConfig.GetString(optionNameKubeconfig)

options := []k8s.ClientOption{
k8s.WithLogger(c.log),
Expand Down
2 changes: 1 addition & 1 deletion cmd/beekeeper/cmd/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
// newMetricsPusher returns a new metrics pusher and a cleanup function.
func newMetricsPusher(pusherAddress, job string, logger logging.Logger) (*push.Pusher, func()) {
metricsPusher := push.New(pusherAddress, job)
metricsPusher.Format(expfmt.FmtText)
metricsPusher.Format(expfmt.NewFormat(expfmt.TypeTextPlain))

killC := make(chan struct{})
var wg sync.WaitGroup
Expand Down
8 changes: 4 additions & 4 deletions cmd/beekeeper/cmd/node_funder.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,14 @@ func (nf *nodeLister) List(ctx context.Context, namespace string) (nodes []funde
return nil, fmt.Errorf("namespace not provided")
}

ingressHosts, err := nf.k8sClient.Ingress.ListDebugNodesHosts(ctx, namespace)
ingressHosts, err := nf.k8sClient.Ingress.ListAPINodesHosts(ctx, namespace)
if err != nil {
return nil, fmt.Errorf("list ingress debug nodes hosts: %s", err.Error())
return nil, fmt.Errorf("list ingress api nodes hosts: %s", err.Error())
}

ingressRouteHosts, err := nf.k8sClient.IngressRoute.ListDebugNodesHosts(ctx, namespace)
ingressRouteHosts, err := nf.k8sClient.IngressRoute.ListAPINodesHosts(ctx, namespace)
if err != nil {
return nil, fmt.Errorf("list ingress route debug nodes hosts: %s", err.Error())
return nil, fmt.Errorf("list ingress route api nodes hosts: %s", err.Error())
}

ingressHosts = append(ingressHosts, ingressRouteHosts...)
Expand Down
6 changes: 5 additions & 1 deletion cmd/beekeeper/cmd/simulate.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ func (c *command) initSimulateCmd() (err error) {
}

// setup cluster
cluster, err := c.setupCluster(ctx, c.globalConfig.GetString(optionNameClusterName), c.config, c.globalConfig.GetBool(optionNameCreateCluster))
cluster, err := c.setupCluster(ctx,
c.globalConfig.GetString(optionNameClusterName),
c.config,
c.globalConfig.GetBool(optionNameCreateCluster),
)
if err != nil {
return fmt.Errorf("cluster setup: %w", err)
}
Expand Down
57 changes: 41 additions & 16 deletions config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@ clusters:
name: bee
namespace: beekeeper
disable-namespace: false
use-static-endpoints: false
api-domain: staging.internal
api-insecure-tls: true
api-scheme: https
debug-api-domain: staging.internal
debug-api-insecure-tls: true
debug-api-scheme: https
admin-password: test
funding:
eth: 0.1
bzz: 100.0
node-groups:
bootnode:
mode: bootnode
endpoints:
- name: bootnode-0
api-url: https://bootnode-0.beekeeper.testnet.internal
debug-api-url: https://bootnode-0-debug.beekeeper.testnet.internal
bee-config: bootnode
config: default
nodes:
Expand All @@ -41,6 +43,16 @@ clusters:
bee-config: default
config: default
count: 3
endpoints:
- name: bee-0
api-url: https://bee-0.beekeeper.testnet.internal
debug-api-url: https://bee-0-debug.beekeeper.testnet.internal
- name: bee-1
api-url: https://bee-1.beekeeper.testnet.internal
debug-api-url: https://bee-1-debug.beekeeper.testnet.internal
- name: bee-2
api-url: https://bee-2.beekeeper.testnet.internal
debug-api-url: https://bee-2-debug.beekeeper.testnet.internal
# nodes:
# - clef:
# key: '{"address":"4558ab6d518bf60b813eeba3077eed986027c5da","crypto":{"cipher":"aes-128-ctr","ciphertext":"1bbeffa438a8b8fd592a46323fe0168d8d8e2625085ca8550023b5c0bd48a126","cipherparams":{"iv":"3f369a742a465aaf5e3025864639421a"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":64,"p":1,"r":8,"salt":"4c2c1fde6491213ea3c6021c82a70327bc0a056569a6e7c2a3fda9e486c0f090"},"mac":"f733b77f675acf0539e7d3d60735408c6efd43893dc0d5b0f94124b0197f89dd"},"id":"1e526dc4-60bd-4c4d-897d-f284806abf2b","version":3}'
Expand All @@ -56,6 +68,16 @@ clusters:
bee-config: light-node
config: light-node
count: 3
endpoints:
- name: light-0
api-url: https://light-0.beekeeper.testnet.internal
debug-api-url: https://light-0-debug.beekeeper.testnet.internal
- name: light-1
api-url: https://light-1.beekeeper.testnet.internal
debug-api-url: https://light-1-debug.beekeeper.testnet.internal
- name: light-2
api-url: https://light-2.beekeeper.testnet.internal
debug-api-url: https://light-2-debug.beekeeper.testnet.internal

# node-groups defines node groups that can be registered in the cluster
# node-groups may inherit it's configuration from already defined node-group and override specific fields from it
Expand All @@ -78,7 +100,6 @@ node-groups:
nginx.ingress.kubernetes.io/session-cookie-path: "default"
nginx.ingress.kubernetes.io/ssl-redirect: "true"
ingress-class: "nginx-internal"
ingress-debug-class: "nginx-internal"
labels:
app.kubernetes.io/component: "node"
app.kubernetes.io/name: "bee"
Expand Down Expand Up @@ -115,8 +136,6 @@ bee-configs:
db-block-cache-capacity: 33554432
db-write-buffer-size: 33554432
db-disable-seeks-compaction: false
debug-api-addr: ":1635"
debug-api-enable: true
full-node: true
nat-addr: ""
mainnet: false
Expand Down Expand Up @@ -145,6 +164,7 @@ bee-configs:
verbosity: 5
welcome-message: "Welcome to the Swarm, you are Bee-ing connected!"
allow-private-cidrs: true
withdrawal-addresses-whitelist: "0xec44cb15b1b033e74d55ac5d0e24d861bde54532"
bootnode:
_inherit: "default"
bootnode-mode: true
Expand Down Expand Up @@ -215,6 +235,16 @@ checks:
options:
timeout: 5m
type: pingpong
act:
options:
file-name: act
file-size: 1024
postage-depth: 20
postage-amount: 420000000
postage-label: act-label
seed: 0
timeout: 5m
type: act
withdraw:
options:
target-address: 0xec44cb15b1b033e74d55ac5d0e24d861bde54532
Expand Down Expand Up @@ -315,9 +345,12 @@ checks:
nodes-sync-wait: 1m
duration: 12h
downloader-count: 3
upload-group:
uploader-count: 3
max-storage-radius: 2
storage-radius-check-wait: 5m
upload-groups:
- gateway
download-group:
download-groups:
- bee
- light
timeout: 12h
Expand All @@ -337,13 +370,6 @@ checks:
postage-depth: 17
postage-topup-amount: 100
postage-new-depth: 18
authenticate:
type: authenticate
timeout: 5m
options:
role: consumer
admin-password: test
restricted-group-name: restricted
stake:
type: stake
timeout: 5m
Expand All @@ -369,7 +395,6 @@ checks:
data-size:
type: redundancy


# simulations defines simulations Beekeeper can execute against the cluster
# type filed allows defining same simulation with different names and options
simulations:
Expand Down
3 changes: 0 additions & 3 deletions config/helm-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ clusters:
api-domain: staging.internal
api-insecure-tls: true
api-scheme: https
debug-api-domain: staging.internal
debug-api-insecure-tls: true
debug-api-scheme: https
node-groups:
bee:
bee-config: default
Expand Down
Loading

0 comments on commit 32895eb

Please sign in to comment.