Skip to content

Commit

Permalink
Merge pull request #38 from valentin-carl/mpga-development-36
Browse files Browse the repository at this point in the history
feat: Integrate function container start stop system (#36)
  • Loading branch information
KonsumGandalf authored Jan 25, 2024
2 parents 398021b + 94180ed commit a27c4d6
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 17 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/docker-profaastinate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build and push dashboard image

on:
workflow_dispatch:
pull_request:
branches: [ mpga-development ]

env:
REGISTRY: ghcr.io
IMAGE_NAME: quay.io/nuclio/dashboard
SET_IMAGE_NAME: nuclio-dashboard-profaastintate

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build dashboard image
run: make dashboard

- name: Tag and push dashboard image
run: |
docker tag ${{ env.IMAGE_NAME }}:latest-amd64 ${{ env.REGISTRY }}/${{ github.repository }}/${{ env.SET_IMAGE_NAME }}:latest-amd64
docker push ${{ env.REGISTRY }}/${{ github.repository }}/${{ env.SET_IMAGE_NAME }}:latest-amd64
15 changes: 9 additions & 6 deletions .github/workflows/profaastinate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,21 @@ jobs:
go-version: [ 1.21.x ] # Add other versions if needed

steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Install dependencies
run: go mod tidy

Lint:
lint:
runs-on: ubuntu-latest
needs: install-deps
steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v4
with:
Expand All @@ -37,14 +39,15 @@ jobs:
- name: Run Profaastinate Lint
run: golangci-lint run ./pkg/nexus/...

Test:
test:
runs-on: ubuntu-latest
needs: install-deps
steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Run Profaastinate Tests
run: go test -cover ./pkg/nexus/...
run: go test -cover ./pkg/nexus/...
3 changes: 1 addition & 2 deletions pkg/dashboard/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ func NewServer(parentLogger logger.Logger,
// create server
newServer.AbstractServer, err = restful.NewAbstractServer(parentLogger,
DashboardResourceRegistrySingleton,
newServer,
newDockerClient)
newServer)
if err != nil {
return nil, errors.Wrap(err, "Failed to create restful server")
}
Expand Down
13 changes: 4 additions & 9 deletions pkg/nexus/elastic-deploy/docker/docker-deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ import (
"time"
)

const (
running = "running"
paused = "paused"
)

type DockerDeployer struct {
*deployer_models.ProElasticDeployerConfig
*docker.Client
Expand Down Expand Up @@ -73,7 +68,7 @@ func (ds *DockerDeployer) Unpause(functionName string) error {
}

fmt.Println("Container state: ", container.State)
if container.State == paused {
if container.State == deployer_models.Paused {
err := ds.UnpauseContainer(container.ID)
if err != nil {
return err
Expand All @@ -90,12 +85,12 @@ func (ds *DockerDeployer) Unpause(functionName string) error {

func (ds *DockerDeployer) Pause(functionName string) error {
container := ds.getFunctionContainer(functionName)
if container.State == paused {
if container.State == deployer_models.Paused {
fmt.Printf("Container %s has been paused already\n", ds.getContainerName(functionName))
return nil
}

if container.State == running {
if container.State == deployer_models.Running {
err := ds.PauseContainer(container.ID)
if err != nil {
return err
Expand All @@ -110,7 +105,7 @@ func (ds *DockerDeployer) Pause(functionName string) error {

func (ds *DockerDeployer) IsRunning(functionName string) bool {
container := ds.getFunctionContainer(functionName)
return container.State == running
return container.State == deployer_models.Running
}

func (ds *DockerDeployer) getFunctionContainer(functionName string) *docker.APIContainers {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import (
"time"
)

const (
Running = "Running"
Paused = "Paused"
)

type ElasticDeployer interface {
Unpause(functionName string) error
Pause(functionName string) error
Expand Down

0 comments on commit a27c4d6

Please sign in to comment.