Compare commits

...

11 Commits
v3 ... main

Author SHA1 Message Date
cx 9e82bfc2b5 Chagne node-x ip
Unittests / unittests (push) Successful in 1m23s Details
Unittests / deploy-dev (push) Successful in 1m15s Details
2024-04-15 10:30:05 +00:00
Adam Štrauch e0b5832e75
Fix deps and crashing when deleting nonexistant app
Unittests / unittests (push) Successful in 9s Details
Unittests / deploy-dev (push) Successful in 59s Details
2024-03-03 02:55:05 +01:00
Adam Štrauch 863d857283
Restart container when tech changes
Unittests / unittests (push) Successful in 10s Details
Unittests / deploy-dev (push) Successful in 47s Details
2024-02-01 22:02:22 +01:00
Adam Štrauch 1c5b8d8f50
Add better debug message to SetTechnology
Unittests / unittests (push) Successful in 9s Details
Unittests / deploy-dev (push) Successful in 46s Details
2024-02-01 21:57:34 +01:00
Adam Štrauch bc4b6c7bff
Possibility to set tech during update
Unittests / unittests (push) Successful in 9s Details
Unittests / deploy-dev (push) Successful in 53s Details
2024-02-01 20:57:13 +01:00
Adam Štrauch 45899f3b0c
Set owner of metadata
Unittests / unittests (push) Successful in 9s Details
Unittests / deploy-dev (push) Successful in 45s Details
2024-01-31 00:16:40 +01:00
Adam Štrauch 5513da35b3
Fix endpoint name for metadata
Unittests / unittests (push) Successful in 9s Details
Unittests / deploy-dev (push) Successful in 44s Details
2024-01-30 23:52:33 +01:00
Adam Štrauch 31ba1ce5a3
Save metadata endpoint
Unittests / unittests (push) Successful in 9s Details
Unittests / deploy-dev (push) Successful in 46s Details
2024-01-30 23:50:03 +01:00
Adam Štrauch a3d0ee92ce
Stats errors in Sentry
Unittests / unittests (push) Successful in 9s Details
Unittests / deploy-dev (push) Successful in 52s Details
2024-01-26 21:43:45 +01:00
Adam Štrauch 7a170e56d6
Gather more errors in Sentry
Unittests / unittests (push) Successful in 9s Details
Unittests / deploy-dev (push) Successful in 54s Details
2024-01-26 21:15:14 +01:00
Adam Štrauch 4e9398512e
Removing drone pipeline 2024-01-26 21:13:58 +01:00
12 changed files with 2057 additions and 842 deletions

View File

@ -1,264 +0,0 @@
kind: pipeline
type: docker
name: testing
steps:
- name: unittests
image: golang:1.18-bullseye
environment:
SNAPSHOTS_S3_ENDPOINT: minio:9000
TEST_S3_ENDPOINT: minio:9000
volumes:
- name: dockersock
path: /var/run
commands:
- apt update && apt upgrade -y
- apt install -y tar zstd
- sleep 10
- go mod tidy
- make test
services:
- name: minio
image: minio/minio:latest
environment:
MINIO_ROOT_USER: test
MINIO_ROOT_PASSWORD: testtest
command:
- server
- /data
- --console-address
- :9001
- name: docker
image: docker:dind
privileged: true
volumes:
- name: dockersock
path: /var/run
volumes:
- name: dockersock
temp: {}
---
kind: pipeline
type: docker
name: Dev deploy
steps:
- name: build
# image: golang:1.17-buster # this one is used in production
image: golang:1.17-bullseye # this one is used in dev
commands:
- go mod tidy
- make build
- name: deploy
image: debian:buster
environment:
#NODE: node-x.rosti.cz
NODES: 192.168.1.236 192.168.1.220
SSH_KEY:
from_secret: SSH_KEY
commands:
- apt update && apt install -y ssh
- |
for NODE in $NODES; do
echo "\033[0;32mDeploying $NODE\033[0m"
mkdir -p ~/.ssh && echo "$SSH_KEY" > ~/.ssh/id_ed25519 && chmod 600 ~/.ssh/id_ed25519
echo "\033[1;33m.. scanning SSH keys\033[0m"
ssh-keyscan $NODE > ~/.ssh/known_hosts
echo "\033[1;33m.. copying the binary\033[0m"
scp node-api root@$NODE:/usr/local/bin/node-api_
echo "\033[1;33m.. replacing the binary\033[0m"
ssh root@$NODE mv /usr/local/bin/node-api_ /usr/local/bin/node-api
echo "\033[1;33m.. restarting service\033[0m"
ssh root@$NODE systemctl restart node-api
done
trigger:
branch:
- main
event:
- push
- custom
depends_on:
- testing
---
kind: pipeline
type: docker
name: Production deploy (Debian 10)
steps:
- name: build
image: golang:1.17-buster # this one is used in production
#image: golang:1.17-bullseye # this one is used in dev
commands:
- go mod tidy
- make build
- name: deploy
image: debian:buster
environment:
PROXY: saturn.rosti.cz
NODES: node-18.rosti.cz node-19.rosti.cz
SSH_KEY:
from_secret: SSH_KEY
HOST_KEYS: |
node-18.rosti.cz ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDp0KZ82dxmBJMJXuqHMiukRqVGHxyfN/nyjqPPemEz1AG2kA80od7Z9TPXYpM6Drnz0Dfcipuys7w8tbcWQGz7W+Tv1x6NWWI2r4WVfVlRkP52zdNUM/ASH88xNVmKK5FfjNyYM0khGnBcdV+ZcH/Mb7ZLLraol7B/uLahFYA5y1v+hH5ZftT8YnpOmVsx0m7PhE1zB6f5VFscSIJ5LQjhHaXkOd5zxxYJtxG6BjzqKdx5AJ2pPa6astzX4EAstpk6KzImCZ12mEEtg7bT3rLuGXg+j1DWFcHpDs0JJxF3GKGooHqbB5s26mTigqTjnytJsIzMgtfslmsLCsJGGO3B
node-18.rosti.cz ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBM4ukB6uTrCzVPjsANlkD6WYoE5bNbzr62ja/nYmEKe+zvgYAb67aXLAt+pals5Hvx5cuZstQkwuTkThBcyltsg=
node-18.rosti.cz ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBAdTePM+EllZc+ZQsxuhdfiw9cRX5lAx2c9drWARSWL
node-19.rosti.cz ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC6ASSidNCyGTyxlWhpm0wH/jW8a25GwAdgH29bC3pLniewTvFcKNFcW3gLjEzIb1v2um98d/OkjeUC2wBJfcoLIkfb7x3pSqQhGVYeD+vbzOMNHIEiyicnqc8bqBN/21kCaZ37KRpz2UEVgPcbawzR3v8toBUL9uSoPbnMrc6p05hTTd2zTiHPnZrmY21vQDqDYCM8YOd0KT60cSW+62B+B8t5nHOOfTZVAEvL5LK56vlFuiYDEumorSN++xpSV6IoZOKqO4WbwLh1OQn/0q85bMzkzTbBbLO7jZl1SepqbBdIg6VtsiWIWtbGf8XgBNgbNEHARoskznvL6whBiwW5
node-19.rosti.cz ecdsa-sha2-nistp256 AAAAE2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lZDI1NTE5AAAAIBkkSH4ZExipcArbSR0TdtdW5JhHf+oeuPRJ3VkFKUIN
saturn.rosti.cz ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC9aRaEQTSKkKnJayODbwIg4BynK0WTvHWzp9UZzvmPxDjh1NpE/3G4Yi6tdZhJ7WjFotxxav7LBotIHu0s6jlVTDtnJ1lN4XBWFzympiZr1SJ12AdUuiC+f5drFTmywWL2YskFyVRYrfguXyGsavu63EokrezoTrCPASaOVmnhvrND9MJNcAgUm/kH+713XIQXWuK27zlrU6VTFSrr1nvDGn10ZaJULQ2XVhNfoysJSDU3nDyxM02qwDQp2cZ0J5fkgvvlvACHDnGgX1e+lHPhyZFhOmTiz7e4fXTuzkzUgjdih4NNDJdm1Em/25L9flnunzHtjvKNqtIL0nFxtJzN0TFRuO1BrykIMYBYBlofJYwc4ssgm8+eSxzjF8W/0rhsoq8JmFWVAvUYrMLCAejHvhG76/BNFEbGPfjt7SdwRVcr1BcgWlDDlNogPESIM1/9SzGi/IYEPKwIemrLRNw2X8QLJ5y2cr7PHTYSVp2NRlyrwvBD64rHIfKiRp/YPNc=
saturn.rosti.cz ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBLEY5PSiOR3pklXRm0sAKc2NP2I0LZggdiRTTqrNXwUarhd7n6tdXQNf/ALh+NJ0KhcgI87Igl/jLo8YoWfeqWM=
commands:
- apt update && apt install -y ssh rsync
- |
for NODE in $NODES; do
echo "\033[0;32mDeploying $NODE\033[0m"
mkdir -p ~/.ssh && echo "$SSH_KEY" > ~/.ssh/id_ed25519 && chmod 600 ~/.ssh/id_ed25519
echo "\033[1;33m.. setting up SSH host keys\033[0m"
echo "$HOST_KEYS" > ~/.ssh/known_hosts
echo "\033[1;33m.. copying the binary\033[0m"
rsync -ave "ssh -J root@$PROXY" node-api root@$NODE:/usr/local/bin/node-api_
echo "\033[1;33m.. replacing the binary\033[0m"
ssh -J root@$PROXY root@$NODE mv /usr/local/bin/node-api_ /usr/local/bin/node-api
echo "\033[1;33m.. restarting service\033[0m"
ssh -J root@$PROXY root@$NODE systemctl restart node-api
done
depends_on:
- testing
trigger:
event:
- promote
target:
- production
---
kind: pipeline
type: docker
name: Production deploy (Debian 11)
steps:
- name: build
image: golang:1.18-bullseye # this one is used in production
#image: golang:1.17-bullseye # this one is used in dev
commands:
- go mod tidy
- make build
- name: deploy
image: debian:bullseye
environment:
PROXY: saturn.rosti.cz
NODES: node-20.rosti.cz
SSH_KEY:
from_secret: SSH_KEY
HOST_KEYS: |
node-18.rosti.cz ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDp0KZ82dxmBJMJXuqHMiukRqVGHxyfN/nyjqPPemEz1AG2kA80od7Z9TPXYpM6Drnz0Dfcipuys7w8tbcWQGz7W+Tv1x6NWWI2r4WVfVlRkP52zdNUM/ASH88xNVmKK5FfjNyYM0khGnBcdV+ZcH/Mb7ZLLraol7B/uLahFYA5y1v+hH5ZftT8YnpOmVsx0m7PhE1zB6f5VFscSIJ5LQjhHaXkOd5zxxYJtxG6BjzqKdx5AJ2pPa6astzX4EAstpk6KzImCZ12mEEtg7bT3rLuGXg+j1DWFcHpDs0JJxF3GKGooHqbB5s26mTigqTjnytJsIzMgtfslmsLCsJGGO3B
node-18.rosti.cz ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBM4ukB6uTrCzVPjsANlkD6WYoE5bNbzr62ja/nYmEKe+zvgYAb67aXLAt+pals5Hvx5cuZstQkwuTkThBcyltsg=
node-18.rosti.cz ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBAdTePM+EllZc+ZQsxuhdfiw9cRX5lAx2c9drWARSWL
node-19.rosti.cz ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC6ASSidNCyGTyxlWhpm0wH/jW8a25GwAdgH29bC3pLniewTvFcKNFcW3gLjEzI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jLo8YoWfeqWM=
commands:
- apt update && apt install -y ssh rsync
- |
for NODE in $NODES; do
echo "\033[0;32mDeploying $NODE\033[0m"
mkdir -p ~/.ssh && echo "$SSH_KEY" > ~/.ssh/id_ed25519 && chmod 600 ~/.ssh/id_ed25519
echo "\033[1;33m.. setting up SSH host keys\033[0m"
echo "$HOST_KEYS" > ~/.ssh/known_hosts
echo "\033[1;33m.. copying the binary\033[0m"
rsync -ave "ssh -J root@$PROXY" node-api root@$NODE:/usr/local/bin/node-api_
echo "\033[1;33m.. replacing the binary\033[0m"
ssh -J root@$PROXY root@$NODE mv /usr/local/bin/node-api_ /usr/local/bin/node-api
echo "\033[1;33m.. restarting service\033[0m"
ssh -J root@$PROXY root@$NODE systemctl restart node-api
done
depends_on:
- testing
trigger:
event:
- promote
target:
- production
---
kind: pipeline
type: docker
name: Production deploy (Debian 12)
steps:
- name: build
image: golang:1.20-bookworm # this one is used in production
commands:
- go mod tidy
- make build
- name: deploy
image: debian:bookworm
environment:
PROXY: saturn.rosti.cz
NODES: node-22.rosti.cz node-23.rosti.cz node-24.rosti.cz
SSH_KEY:
from_secret: SSH_KEY
HOST_KEYS: |
saturn.rosti.cz ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBkkSH4ZExipcArbSR0TdtdW5JhHf+oeuPRJ3VkFKUIN
saturn.rosti.cz ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC9aRaEQTSKkKnJayODbwIg4BynK0WTvHWzp9UZzvmPxDjh1NpE/3G4Yi6tdZhJ7WjFotxxav7LBotIHu0s6jlVTDtnJ1lN4XBWFzympiZr1SJ12AdUuiC+f5drFTmywWL2YskFyVRYrfguXyGsavu63EokrezoTrCPASaOVmnhvrND9MJNcAgUm/kH+713XIQXWuK27zlrU6VTFSrr1nvDGn10ZaJULQ2XVhNfoysJSDU3nDyxM02qwDQp2cZ0J5fkgvvlvACHDnGgX1e+lHPhyZFhOmTiz7e4fXTuzkzUgjdih4NNDJdm1Em/25L9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GazXuySr0jUFvedB6g=
node-22.rosti.cz ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOjnVrKhgmdbKf3m49xPGPEC46DsdHITIrSKcReLxwDL
node-23.rosti.cz ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDZXbjDFPvp1BiPHk09/DQW4eF+RzakpM/94JuGq+cT1O876dRnkZ4ZjZRbuu5u3r1da2yRM6Sz/hSCPvjU9c6xg82QFjXSG6WFnp59/wSOK8iGQPk5rXiZWl17GAiPaCvtYixQ6RbDozljDTcg+c6SaDwgvnDxdy3s3KyEGcpvSTtJoNlIDV6LYb261sGIMAY2Gzcwn4gZSX6xEdvwsInsoLWO3JD8lDrSd1bS2HptwXDVkEe1uMS3SNZfi4OCme7MRTw+EV11wBFodq2TE+jg8RMPDRM165AQn7WDdI0q0OKIEZ0wydmnhVjL8lUdIBGD8rOCkUQr2lqW+TBxCh9m5WzV81PLfilHJy1MHZNffiSrkKktuFvIDr848goxnPdkBkt1J4SATSEAygqcX8a4f59R3YM5iO1OqEOoP4jbw6eO675h8ON2/wXAR14a1Pp5kVKXMALqi93HuWfnkk/5/p+Zew1Xlndarq3g8PudLzzmEOINPYKPsIhMTwKQSec=
node-23.rosti.cz ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEP/VYaCRHFHNDDS870AUBTeI9rigLUB8wqoVCYtx6++bSztWqx8aHNjokVSXBwhBrWKK+UXiBMCxd/1hMnGgRw=
node-23.rosti.cz ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBRFZyIvMy1hJs7IL13VwNHoxKk35I7Y0enJ2TBAj/r2
node-24.rosti.cz ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQClN27YKYii8+Tp2Q4VO8mruA/ixeCZBZulxIZH+tT+G2MuvQrupS8gK/ieZWKUzqt70Fjwof787S7IIkokNHGdZi8ix/lhJYVS1k/bZ1kYrImUsphY7kSXEyI8M8OOANo0HnZ/yK047scEuH5yR/fPjrZffq/HzckCl6BUy8ggumb74dNMUaZw3QC3hc7YQbFdZP2dYtaDrSQrN70mfxl1pufTHHuhipxd4yO5qXh8eowwy7BpzGGFDox7u/EAXX0Owow5fo/EPcmhZnnPiY/juR5uyq6jHuxAkD9FLA7Ot55OyrtWHsH4ee8Ks+Jiu9wVZqpMDROcB/PJ1jOD/ust/Nd1A33FM4uOlePc1WUDpUvrwm+JC9OlD30YwxMbRmIfp57wSuU4bk+AFfrQZ/cwkEZmI/jYgiJwdcflNe7oFSOEn45fX/QNRK784+GHgdg+rY+Ce2YYKUCNpi9BITUnQGG61hhSrLJ8VVCEtJSaHb9r2VC/YNAxAsnd6fuW5Vk=
node-24.rosti.cz ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBGZRGv88qAG0AGRf0d77ChSU2DbDN84LZMCOWPss3RUlRvO72DJSp2706pEpbznDFSoawZ00dY0nH0p09U5ddZY=
node-24.rosti.cz ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKFw8qvLWdwOan2PHVNl8a+az2mbrzRhtFReUu84Uy3o
commands:
- apt update && apt install -y ssh rsync
- |
for NODE in $NODES; do
echo "\033[0;32mDeploying $NODE\033[0m"
mkdir -p ~/.ssh && echo "$SSH_KEY" > ~/.ssh/id_ed25519 && chmod 600 ~/.ssh/id_ed25519
echo "\033[1;33m.. setting up SSH host keys\033[0m"
echo "$HOST_KEYS" > ~/.ssh/known_hosts
echo "\033[1;33m.. copying the binary\033[0m"
rsync -ave "ssh -J root@$PROXY" node-api root@$NODE:/usr/local/bin/node-api_
echo "\033[1;33m.. replacing the binary\033[0m"
ssh -J root@$PROXY root@$NODE mv /usr/local/bin/node-api_ /usr/local/bin/node-api
echo "\033[1;33m.. restarting service\033[0m"
ssh -J root@$PROXY root@$NODE systemctl restart node-api
done
depends_on:
- testing
trigger:
event:
- promote
target:
- production

View File

@ -38,7 +38,7 @@ jobs:
deploy-dev:
runs-on: [amd64, moon]
env:
NODES: "192.168.1.236"
NODES: "192.168.1.33"
steps:
- uses: actions/checkout@v4
- name: deploy

View File

@ -202,13 +202,13 @@ func (d *Driver) Remove(name string) error {
return err
}
timeout := time.Duration(dockerTimeout * time.Second)
err = cli.ContainerStop(context.TODO(), containerID, &timeout)
timeout := dockerTimeout
err = cli.ContainerStop(context.TODO(), containerID, container.StopOptions{Timeout: &timeout})
if err != nil {
return err
}
err = cli.ContainerRemove(context.TODO(), containerID, types.ContainerRemoveOptions{})
err = cli.ContainerRemove(context.TODO(), containerID, container.RemoveOptions{})
return err
}
@ -246,8 +246,8 @@ func (d *Driver) Stop(name string) error {
return err
}
timeout := time.Duration(dockerTimeout * time.Second)
err = cli.ContainerStop(context.TODO(), containerID, &timeout)
timeout := dockerTimeout
err = cli.ContainerStop(context.TODO(), containerID, container.StopOptions{Timeout: &timeout})
return err
}

View File

@ -430,7 +430,7 @@ func (c *Container) SetTechnology(tech string, version string) error {
output, err = driver.Exec(c.App.Name, []string{"su", "app", "-c", "rosti " + tech + " " + version}, "", []string{}, false)
}
log.Printf("DEBUG: enable tech for %s output: %s", c.App.Name, string(*output))
log.Printf("DEBUG: enable tech %s/%s for %s output: %s", tech, version, c.App.Name, string(*output))
return err
}

View File

@ -422,6 +422,25 @@ func (p *Processor) Update(appTemplate apps.App) error {
return err
}
// Setup technology if it's noted in the request
if len(appTemplate.Setup.Tech) > 0 {
err := p.waitForApp()
if err != nil {
return err
}
err = p.EnableTech(appTemplate.Setup.Tech, appTemplate.Setup.TechVersion)
if err != nil {
return fmt.Errorf("failed to enable tech: %v", err)
}
// We restart the container so everything can use the new tech
err = container.Restart()
if err != nil {
return err
}
}
return nil
}
@ -431,6 +450,7 @@ func (p *Processor) Delete() error {
container, err := p.getContainer()
if err != nil {
log.Println("ERROR: delete app:", err.Error())
return err
}
status, err := container.Status()
@ -634,6 +654,42 @@ func (p *Processor) GetHostKey() (string, error) {
return hostKey, nil
}
// Save meta data about app into a file
func (p *Processor) SaveMetadata(metadata string) error {
container, err := p.getContainer()
if err != nil {
return err
}
volumePath := container.VolumeHostPath()
f, err := os.Create(path.Join(volumePath, ".metadata.json"))
if err != nil {
return err
}
defer f.Close()
_, err = f.Write([]byte(metadata))
if err != nil {
return err
}
// Set permissions
err = os.Chmod(path.Join(volumePath, ".metadata.json"), 0600)
if err != nil {
return err
}
// Set owner
err = os.Chown(path.Join(volumePath, ".metadata.json"), ownerUID, ownerGID)
if err != nil {
return err
}
return nil
}
// Processes returns list of supervisord processes
func (p *Processor) Processes() ([]docker.Process, error) {
container, err := p.getContainer()

View File

@ -3,6 +3,7 @@ package glue
import (
"log"
"github.com/getsentry/sentry-go"
"github.com/jinzhu/gorm"
"github.com/rosti-cz/node-api/apps"
docker "github.com/rosti-cz/node-api/containers"
@ -102,6 +103,7 @@ func (s *StatsProcessor) GatherStats() error {
for _, app := range appList {
err := s.UpdateUsage(app.Name)
if err != nil {
sentry.CaptureException(err)
log.Println("STATS ERROR:", err.Error())
}
}
@ -120,6 +122,7 @@ func (s *StatsProcessor) GatherStates() error {
for _, app := range appList {
err := s.UpdateState(app.Name)
if err != nil {
sentry.CaptureException(err)
log.Println("STATE ERROR:", err.Error())
}
}

View File

@ -2,6 +2,9 @@ package glue
import "github.com/rosti-cz/node-api/apps"
const ownerUID = 1000
const ownerGID = 1000
// Path where authorized keys are
const sshPubKeysLocation = "/srv/.ssh/authorized_keys"

23
go.mod
View File

@ -3,30 +3,31 @@ module github.com/rosti-cz/node-api
go 1.14
require (
github.com/Microsoft/go-winio v0.4.18 // indirect
github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46 // indirect
github.com/containerd/containerd v1.5.9 // indirect
github.com/docker/docker v20.10.12+incompatible
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/distribution/reference v0.5.0 // indirect
github.com/docker/docker v25.0.3+incompatible
github.com/docker/go-connections v0.4.0
github.com/docker/go-units v0.5.0 // indirect
github.com/getsentry/sentry-go v0.26.0
github.com/gobuffalo/packr v1.30.1
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/jinzhu/gorm v1.9.14
github.com/kelseyhightower/envconfig v1.4.0
github.com/labstack/echo/v4 v4.10.0
github.com/mattn/go-sqlite3 v1.14.17 // indirect
github.com/minio/minio-go/v7 v7.0.14
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/nats-io/nats.go v1.23.0
github.com/opencontainers/image-spec v1.0.2
github.com/pkg/errors v0.9.1
github.com/satori/go.uuid v1.2.0
github.com/shirou/gopsutil v2.20.6+incompatible
github.com/stretchr/testify v1.8.2
google.golang.org/grpc v1.44.0 // indirect
github.com/stretchr/testify v1.8.4
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 // indirect
gorm.io/driver/mysql v1.4.7
gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55
gotest.tools/v3 v3.1.0 // indirect
gotest.tools/v3 v3.5.1 // indirect
)

2481
go.sum

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,7 @@ package main
import (
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
@ -362,6 +363,33 @@ func getOrphansHander(c echo.Context) error {
return c.JSON(http.StatusOK, []string{})
}
// Save metadata for the app
func saveMetadataHandler(c echo.Context) error {
name := c.Param("name")
processor := glue.Processor{
AppName: name,
DB: common.GetDBConnection(),
SnapshotProcessor: &snapshotProcessor,
DockerSock: config.DockerSocket,
BindIPHTTP: config.AppsBindIPHTTP,
BindIPSSH: config.AppsBindIPSSH,
AppsPath: config.AppsPath,
}
body, err := io.ReadAll(c.Request().Body)
if err != nil {
return fmt.Errorf("error reading request body: %v", err)
}
err = processor.SaveMetadata(string(body))
if err != nil {
return fmt.Errorf("error while save metadata: %v", err.Error())
}
return nil
}
// Return info about the node including performance index
func getNodeInfoHandler(c echo.Context) error {
processor := glue.Processor{

View File

@ -63,6 +63,7 @@ func _messageHandler(m *nats.Msg) error {
"add_label": addLabelEventHandler,
"remove_label": removeLabelEventHandler,
"list_orphans": listOrphansEventHandler,
"save_metadata": saveMetadataEventHandler,
"node": getNodeEventHandler,
"create_snapshot": createSnapshotEventHandler,
"restore_from_snapshot": restoreFromSnapshotEventHandler,
@ -719,6 +720,26 @@ func listOrphansEventHandler(m *nats.Msg, message *RequestMessage) error {
return nil
}
// Save metadata for the app
func saveMetadataEventHandler(m *nats.Msg, message *RequestMessage) error {
processor := glue.Processor{
AppName: message.AppName,
DB: common.GetDBConnection(),
SnapshotProcessor: &snapshotProcessor,
DockerSock: config.DockerSocket,
BindIPHTTP: config.AppsBindIPHTTP,
BindIPSSH: config.AppsBindIPSSH,
AppsPath: config.AppsPath,
}
err := processor.SaveMetadata(message.Payload)
if err != nil {
return fmt.Errorf("error while save metadata: %v", err.Error())
}
return nil
}
/*
getNodeEventHandler returns info about the node including performance index
*/

View File

@ -43,6 +43,7 @@ func _init() {
// Connect to the NATS service
nc, err = nats.Connect(config.NATSURL)
if err != nil {
sentry.CaptureException(err)
log.Fatalln(err)
}
@ -103,6 +104,7 @@ func main() {
start := time.Now()
err := statsProcessor.GatherStats()
if err != nil {
sentry.CaptureException(err)
log.Println("LOOP ERROR:", err.Error())
}
elapsed := time.Since(start)
@ -117,6 +119,7 @@ func main() {
for {
err := nodeProcessor.Log()
if err != nil {
sentry.CaptureException(err)
log.Println("NODE PERFORMANCE LOG ERROR:", err.Error())
}
time.Sleep(5 * time.Minute)
@ -180,6 +183,9 @@ func main() {
// Rebuilds existing app, it keeps the data but creates the container again
e.PUT("/v1/apps/:name/rebuild", rebuildAppHandler)
// Save metadata about app
e.POST("/v1/apps/:name/metadata", saveMetadataHandler)
// Adds new label
e.POST("/v1/apps/:name/labels", addLabelHandler)