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

Integrate EL monitoring stack #406

Merged
merged 57 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
c749101
feat: Merge DockerManager and ServiceManager interfaces
khalifaa55 Aug 30, 2024
2e3a1ee
feat: integrate dependencies from eigenlayer
khalifaa55 Aug 30, 2024
750b507
feat: Integrate code from Eigenlayer
khalifaa55 Aug 30, 2024
cafde9c
feat: Adjust dependencies
khalifaa55 Sep 2, 2024
a5ce745
test: Merged interfaces
khalifaa55 Sep 2, 2024
82f793a
feat: Include monitoring stack
khalifaa55 Sep 3, 2024
6ae7944
feat: Adjust monitoring stack dependencies
khalifaa55 Sep 5, 2024
34dde68
feat: Update changelog
khalifaa55 Sep 5, 2024
c79094d
refactor: Update mocks
khalifaa55 Sep 5, 2024
56e3d84
tests: Adjust tests file handling for Windows OS
khalifaa55 Sep 5, 2024
74c7c31
feat: Update PathMatcher adjustments
khalifaa55 Sep 5, 2024
4292b97
tests: Adjust file handling
khalifaa55 Sep 5, 2024
844344d
feat: Add monitoring command
khalifaa55 Sep 9, 2024
ffb9eac
tests: e2e tests for monitoringStack
khalifaa55 Sep 9, 2024
be27a22
feat: Install latest Docker in CI/CD pipeline
khalifaa55 Sep 9, 2024
2e1c416
feat: Install latest Docker in CI/CD pipeline for e2e
khalifaa55 Sep 9, 2024
fd5e67b
fix: Adjust Docker client version
khalifaa55 Sep 9, 2024
06ad6fe
feat: Adjust docker client API version
khalifaa55 Sep 9, 2024
e830628
fix: Adjust platfrom issue for Windows
khalifaa55 Sep 9, 2024
7dbf8ab
feat: Update services images
khalifaa55 Sep 10, 2024
ac46984
feat: Update docker-compose script
khalifaa55 Sep 10, 2024
3061128
fix: Windows error
khalifaa55 Sep 10, 2024
1770675
fix: File handling for Windows
khalifaa55 Sep 10, 2024
1cbe695
feat: Update service versions
khalifaa55 Sep 10, 2024
df56472
feat: Adjust monitoring clean command
khalifaa55 Sep 10, 2024
ca25d6a
feat: Update pipeline for Windows docker
khalifaa55 Sep 10, 2024
0e65d8e
feat: Remove unnecessary files
khalifaa55 Sep 11, 2024
473e452
fix: Windows error
khalifaa55 Sep 11, 2024
60bdc4e
feat: Update gomod
khalifaa55 Sep 11, 2024
c6f88ab
feat: Adjust pipeline for Docker Windows
khalifaa55 Sep 11, 2024
3df9d37
feat: Exclude e2e tests from unit-tests workflow
khalifaa55 Sep 11, 2024
4a7fcaf
feat: Update e2e workflow
khalifaa55 Sep 11, 2024
a8330ff
feat: Update daemon configuration for workflow
khalifaa55 Sep 11, 2024
104128a
fix: Pipeline daemon for Windows
khalifaa55 Sep 11, 2024
de9af17
feat: e2e pipeline for Windows
khalifaa55 Sep 11, 2024
29b762a
feat: Install make for WSL in pipeline
khalifaa55 Sep 12, 2024
3a7660c
feat: Update workflow
khalifaa55 Sep 12, 2024
ff62f0a
feat: Increase timeout for make codecov-test
khalifaa55 Sep 12, 2024
1c698c1
feat: Ignore e2e tests in unit-tests workflow
khalifaa55 Sep 12, 2024
416753e
feat: Install deps for WSL in pipeline
khalifaa55 Sep 12, 2024
c55f673
feat: Skip e2e tests for unit-tests workflow
khalifaa55 Sep 12, 2024
5435761
feat: Update makefile
khalifaa55 Sep 12, 2024
600b6b7
feat: Run e2e tests for unit-tests ubuntu
khalifaa55 Sep 12, 2024
7ecb2e1
feat: Update go version for WSL pipeline
khalifaa55 Sep 12, 2024
b943d72
feat: Update e2e workflow
khalifaa55 Sep 12, 2024
9ee7130
fix: Skip e2e in ubuntu unit-tests workflow
khalifaa55 Sep 12, 2024
a3941d1
feat: Handle go installation for WSL
khalifaa55 Sep 12, 2024
200474c
feat: Use actions for WSL in workflow
khalifaa55 Sep 13, 2024
ccc6e6f
feat: Skip e2e monitoringStack test for Windows
khalifaa55 Sep 13, 2024
c2c6829
feat: Update Go version
khalifaa55 Sep 16, 2024
4bf6821
test: Refactor tests
khalifaa55 Sep 16, 2024
f147b8b
refac: ComposeManager and Locker interfaces
khalifaa55 Sep 16, 2024
b597eb8
test: Update mocks
khalifaa55 Sep 16, 2024
c03d51c
refac: Remove unnecessary files
khalifaa55 Sep 17, 2024
ba8f2b6
refac: Update services versions
khalifaa55 Sep 17, 2024
0d4eb8d
style: Adjust formatting
khalifaa55 Sep 17, 2024
178116a
tests: Fix errors
khalifaa55 Sep 17, 2024
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
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
matrix:
include:
- os: ubuntu-latest
go: '1.21'
go: '1.22'
- os: macos-latest
go: '1.21'
go: '1.22'
- os: windows-latest
go: '1.21'
go: '1.22'
runs-on: ${{ matrix.os }}

steps:
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/e2e_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
matrix:
include:
- os: ubuntu-latest
go: '1.21'
go: '1.22'
- os: windows-latest
go: '1.21'
go: '1.22'
runs-on: ${{ matrix.os }}

steps:
Expand All @@ -29,6 +29,11 @@ jobs:

- name: Install deps
run: make install-deps

- name: Run e2e tests

- name: Run e2e tests Windows
if: runner.os == 'Windows'
run: make e2e-test-windows

- name: Run e2e tests other
if: runner.os != 'Windows'
run: make e2e-test
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

- uses: actions/setup-go@v5
with:
go-version: "1.21.0"
go-version: "1.22.0"

- run: chmod +x ./scripts/build-go-darwin-binaries.sh && ./scripts/build-go-darwin-binaries.sh

Expand Down Expand Up @@ -52,7 +52,7 @@ jobs:

- uses: actions/setup-go@v5
with:
go-version: "1.21.0"
go-version: "1.22.0"

- run: scripts\build-go-windows-binaries.ps1

Expand All @@ -74,7 +74,7 @@ jobs:

- uses: actions/setup-go@v5
with:
go-version: "1.21.0"
go-version: "1.22.0"

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -189,7 +189,7 @@ jobs:
path: sedge
- uses: actions/setup-go@v5
with:
go-version: "1.21.0"
go-version: "1.22.0"
- name: Run publish PPA script
env:
GOPATH: /home/runner/go
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
matrix:
include:
- os: ubuntu-latest
go: '1.21'
go: '1.22'
- os: windows-latest
go: '1.21'
go: '1.22'
runs-on: ${{ matrix.os }}

steps:
Expand All @@ -36,7 +36,7 @@ jobs:

- name: Run tests other
if: matrix.os != 'ubuntu-latest'
run: make generate && go test ./...
run: make generate && make test-no-e2e

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added
- New command `lido-status` to display data of Lido Node Operator.
- Monitoring stack setup with Grafana, Prometheus, and Node Exporter.

### Changed
- Update Go version from 1.21 to 1.22.

### Fixed
- Teku and Lighthouse import keys container error on Windows.
Expand Down
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,16 @@ test: generate ## run tests
e2e-test: generate ## Run e2e tests
@go test -timeout 20m -count=1 ./e2e/...

e2e-test-windows: generate ## Run e2e tests on Windows
@go test -timeout 20m -count=1 -skip TestE2E_MonitoringStack ./e2e/...

test-no-e2e: generate ## run tests excluding e2e
@mkdir -p coverage
@go test -coverprofile=coverage/coverage.out -covermode=count ./... -skip TestE2E

codecov-test: generate ## unit tests with coverage using the courtney tool
@mkdir -p coverage
@courtney/courtney -v -o coverage/coverage.out ./...
@courtney/courtney -v -o coverage/coverage.out -t="-skip=TestE2E" ./...
@go tool cover -html=coverage/coverage.out -o coverage/coverage.html

install-gofumpt: ## install gofumpt
Expand Down
19 changes: 9 additions & 10 deletions cli/actions/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package actions
import (
"github.com/NethermindEth/sedge/internal/pkg/commands"
"github.com/NethermindEth/sedge/internal/pkg/generate"
"github.com/NethermindEth/sedge/internal/pkg/services"
"github.com/docker/docker/client"
)

Expand All @@ -37,22 +36,22 @@ type SedgeActions interface {
}

type sedgeActions struct {
dockerClient client.APIClient
serviceManager services.ServiceManager
commandRunner commands.CommandRunner
dockerClient client.APIClient
dockerServiceManager DockerServiceManager
commandRunner commands.CommandRunner
}

type SedgeActionsOptions struct {
DockerClient client.APIClient
ServiceManager services.ServiceManager
CommandRunner commands.CommandRunner
DockerClient client.APIClient
DockerServiceManager DockerServiceManager
CommandRunner commands.CommandRunner
}

func NewSedgeActions(options SedgeActionsOptions) SedgeActions {
return &sedgeActions{
dockerClient: options.DockerClient,
serviceManager: options.ServiceManager,
commandRunner: options.CommandRunner,
dockerClient: options.DockerClient,
dockerServiceManager: options.DockerServiceManager,
commandRunner: options.CommandRunner,
}
}

Expand Down
14 changes: 14 additions & 0 deletions cli/actions/docker.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package actions

import "github.com/docker/docker/api/types/container"

// DockerServiceManager is an interface for managing Docker containers.
type DockerServiceManager interface {
Image(service string) (string, error)
Stop(service string) error
Start(service string) error
IsRunning(service string) (bool, error)
Wait(service string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error)
ContainerID(service string) (string, error)
ContainerLogs(ctID, service string) (string, error)
}
6 changes: 3 additions & 3 deletions cli/actions/generation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ import (
func newAction(t *testing.T, ctrl *gomock.Controller) actions.SedgeActions {
t.Helper()
dockerClient := sedge_mocks.NewMockAPIClient(ctrl)
serviceManager := services.NewServiceManager(dockerClient)
dockerServiceManager := services.NewDockerServiceManager(dockerClient)
return actions.NewSedgeActions(actions.SedgeActionsOptions{
DockerClient: dockerClient,
ServiceManager: serviceManager,
DockerClient: dockerClient,
DockerServiceManager: dockerServiceManager,
})
}

Expand Down
6 changes: 3 additions & 3 deletions cli/actions/getContainers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ func getMockActions(

return actions.NewSedgeActions(
actions.SedgeActionsOptions{
DockerClient: dockerClient,
ServiceManager: nil,
CommandRunner: nil,
DockerClient: dockerClient,
DockerServiceManager: nil,
CommandRunner: nil,
},
)
}
Expand Down
31 changes: 15 additions & 16 deletions cli/actions/importKeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/NethermindEth/sedge/internal/images/validator-import/teku"
"github.com/NethermindEth/sedge/internal/pkg/commands"
"github.com/NethermindEth/sedge/internal/pkg/services"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/mount"
"github.com/docker/docker/api/types/network"
Expand Down Expand Up @@ -70,18 +69,18 @@ func (s *sedgeActions) ImportValidatorKeys(options ImportValidatorKeysOptions) e
}
validatorCtName := services.ContainerNameWithTag(services.DefaultSedgeValidatorClient, options.ContainerTag)
// Check validator container exists
_, err := s.serviceManager.ContainerId(validatorCtName)
_, err := s.dockerServiceManager.ContainerID(validatorCtName)
if err != nil {
return err
}
previouslyRunning, err := s.serviceManager.IsRunning(validatorCtName)
previouslyRunning, err := s.dockerServiceManager.IsRunning(validatorCtName)
if err != nil {
return err
}
// Stop validator
if previouslyRunning {
log.Info("Stopping validator client")
if err := s.serviceManager.Stop(validatorCtName); err != nil {
if err := s.dockerServiceManager.Stop(validatorCtName); err != nil {
return err
}
}
Expand All @@ -106,13 +105,13 @@ func (s *sedgeActions) ImportValidatorKeys(options ImportValidatorKeysOptions) e
var ctID string
switch options.ValidatorClient {
case "prysm":
prysmCtID, err := setupPrysmValidatorImportContainer(s.dockerClient, s.serviceManager, options)
prysmCtID, err := setupPrysmValidatorImportContainer(s.dockerClient, s.dockerServiceManager, options)
if err != nil {
return err
}
ctID = prysmCtID
case "lodestar":
lodestarCtID, err := setupLodestarValidatorImport(s.dockerClient, s.serviceManager, options)
lodestarCtID, err := setupLodestarValidatorImport(s.dockerClient, s.dockerServiceManager, options)
if err != nil {
return err
}
Expand All @@ -133,11 +132,11 @@ func (s *sedgeActions) ImportValidatorKeys(options ImportValidatorKeysOptions) e
return fmt.Errorf("%w: %s", ErrUnsupportedValidatorClient, options.ValidatorClient)
}
log.Info("Importing validator keys")
runErr := runAndWaitImportKeys(s.dockerClient, s.serviceManager, ctID)
runErr := runAndWaitImportKeys(s.dockerClient, s.dockerServiceManager, ctID)
// Run validator again
if (previouslyRunning && !options.StopValidator) || options.StartValidator {
log.Info("The validator container is being restarted")
if err := s.serviceManager.Start(validatorCtName); err != nil {
if err := s.dockerServiceManager.Start(validatorCtName); err != nil {
return err
}
}
Expand All @@ -151,12 +150,12 @@ func isDefaultKeysPath(generationPath, from string) bool {
return from == filepath.Join(generationPath, "keystore")
}

func setupPrysmValidatorImportContainer(dockerClient client.APIClient, serviceManager services.ServiceManager, options ImportValidatorKeysOptions) (string, error) {
func setupPrysmValidatorImportContainer(dockerClient client.APIClient, dockerServiceManager DockerServiceManager, options ImportValidatorKeysOptions) (string, error) {
var (
validatorCtName = services.ContainerNameWithTag(services.DefaultSedgeValidatorClient, options.ContainerTag)
validatorImportCtName = services.ContainerNameWithTag(services.ServiceCtValidatorImport, options.ContainerTag)
)
validatorImage, err := serviceManager.Image(validatorCtName)
validatorImage, err := dockerServiceManager.Image(validatorCtName)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -209,12 +208,12 @@ func setupPrysmValidatorImportContainer(dockerClient client.APIClient, serviceMa
return ct.ID, nil
}

func setupLodestarValidatorImport(dockerClient client.APIClient, serviceManager services.ServiceManager, options ImportValidatorKeysOptions) (string, error) {
func setupLodestarValidatorImport(dockerClient client.APIClient, dockerServiceManager DockerServiceManager, options ImportValidatorKeysOptions) (string, error) {
var (
validatorCtName = services.ContainerNameWithTag(services.DefaultSedgeValidatorClient, options.ContainerTag)
validatorImportCtName = services.ContainerNameWithTag(services.ServiceCtValidatorImport, options.ContainerTag)
)
validatorImage, err := serviceManager.Image(validatorCtName)
validatorImage, err := dockerServiceManager.Image(validatorCtName)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -402,19 +401,19 @@ func setupTekuValidatorImport(dockerClient client.APIClient, commandRunner comma
return ct.ID, nil
}

func runAndWaitImportKeys(dockerClient client.APIClient, serviceManager services.ServiceManager, ctID string) error {
func runAndWaitImportKeys(dockerClient client.APIClient, dockerServiceManager DockerServiceManager, ctID string) error {
log.Debugf("import keys container id: %s", ctID)
ctExit, errChan := serviceManager.Wait(ctID, container.WaitConditionNextExit)
ctExit, errChan := dockerServiceManager.Wait(ctID, container.WaitConditionNextExit)
log.Info("The keys import container is starting")
if err := dockerClient.ContainerStart(context.Background(), ctID, types.ContainerStartOptions{}); err != nil {
if err := dockerClient.ContainerStart(context.Background(), ctID, container.StartOptions{}); err != nil {
return err
}
osSignals := make(chan os.Signal, 1)
signal.Notify(osSignals, os.Interrupt)
for {
select {
case exitResult := <-ctExit:
logs, err := serviceManager.ContainerLogs(ctID, "Import keys")
logs, err := dockerServiceManager.ContainerLogs(ctID, "Import keys")
if err != nil {
return err
}
Expand Down
Loading
Loading