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

Improve debug mode #29

Merged
merged 7 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion HadesCloneContainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ COPY --from=builder /app/hades-clone .
RUN chmod +x /app/hades-clone

# Run your Go application and then sleep indefinitely
ENTRYPOINT ["/app/hades-clone"]
ENTRYPOINT ["/app/hades-clone"]
7 changes: 5 additions & 2 deletions HadesScheduler/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@ import (

var cli *client.Client
var global_envs []string = []string{}
var container_autoremove bool

type Scheduler struct{}

type DockerConfig struct {
DockerHost string `env:"DOCKER_HOST" envDefault:"unix:///var/run/docker.sock"`
DockerHost string `env:"DOCKER_HOST" envDefault:"unix:///var/run/docker.sock"`
ContainerAutoremove bool `env:"CONTAINER_AUTOREMOVE" envDefault:"true`
}

func init() {
var DockerCfg DockerConfig
utils.LoadConfig(&DockerCfg)
container_autoremove = DockerCfg.ContainerAutoremove

var err error
// Create a new Docker client
Expand Down Expand Up @@ -99,7 +102,7 @@ func executeStep(ctx context.Context, client *client.Client, step payload.Step,
Target: "/shared",
},
},
AutoRemove: true,
AutoRemove: container_autoremove, // Remove the container after it is done only if the config is set to true
}

// Create the bash script if there is one
Expand Down
3 changes: 2 additions & 1 deletion HadesScheduler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func main() {

var executorCfg utils.ExecutorConfig
utils.LoadConfig(&executorCfg)
log.Debug("Executor config: ", executorCfg)

var err error
rabbitmqURL := fmt.Sprintf("amqp://%s:%s@%s/", cfg.User, cfg.Password, cfg.Url)
Expand All @@ -52,7 +53,7 @@ func main() {
log.Info("Started HadesScheduler in Docker mode")
scheduler = docker.Scheduler{}
default:
log.Fatal("Invalid executor specified")
log.Fatalf("Invalid executor specified: %s", executorCfg.Executor)
}

BuildQueue.Dequeue(scheduler.ScheduleJob)
Expand Down
1 change: 1 addition & 0 deletions docker-comose.k8s.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ services:
- KUBECONFIG=/root/.kube/config
- RABBITMQ_DEFAULT_USER
- RABBITMQ_DEFAULT_PASS
- HADES_EXECUTOR=k8s
volumes:
- ./.kube/config:/root/.kube/config
20 changes: 20 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# docker compose file for the project with three services

version: '3.7'
services:
hadesAPI:
environment:
- RABBITMQ_URL=rabbitmq:5672
- RABBITMQ_DEFAULT_USER
- RABBITMQ_DEFAULT_PASS
- DEBUG=true
hadesScheduler:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to pass the Docker daemon here

volumes:
      - /var/run/docker.sock:/var/run/docker.sock

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True - I used this as an overwrite file so it wasn't an issue for me - Will add though

environment:
- RABBITMQ_URL=rabbitmq:5672
- RABBITMQ_DEFAULT_USER
- RABBITMQ_DEFAULT_PASS
- HADES_EXECUTOR=docker
- CONTAINER_AUTOREMOVE=false
- DEBUG=true
volumes:
- /var/run/docker.sock:/var/run/docker.sock
10 changes: 9 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ services:
context: .
dockerfile: ./HadesAPI/Dockerfile
ports:
- "8080:8080"
# Set the Port to 8081 to avoid conflicts with the artemis server
- "8081:8080"
networks:
- hades
depends_on:
Expand All @@ -24,13 +25,20 @@ services:
build:
context: .
dockerfile: ./HadesScheduler/Dockerfile
volumes:
- type: bind
source: /var/run/docker.sock
target: /var/run/docker.sock
networks:
- hades
depends_on:
rabbitmq:
condition: service_healthy
environment:
- RABBITMQ_URL=rabbitmq:5672
- RABBITMQ_DEFAULT_USER
- RABBITMQ_DEFAULT_PASS
- HADES_EXECUTOR=docker

rabbitmq:
container_name: rabbitmq
Expand Down
2 changes: 1 addition & 1 deletion shared/utils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type K8sConfig struct {
}

type ExecutorConfig struct {
Executor string `env:"EXECUTOR,notEmpty" envDefault:"k8s"`
Executor string `env:"HADES_EXECUTOR,notEmpty" envDefault:"docker"`
}

func LoadConfig(cfg interface{}) {
Expand Down