More pipeline debugging info

This commit is contained in:
Frikky
2024-11-08 16:22:47 +01:00
parent 02b263ebd9
commit f0757416e9
+15 -15
View File
@@ -325,7 +325,12 @@ func cleanupExistingNodes(ctx context.Context) error {
func deployServiceWorkers(image string) {
log.Printf("[DEBUG] Validating deployment of workers as services IF swarmConfig = run (value: %#v)", swarmConfig)
if swarmConfig == "run" || swarmConfig == "swarm" {
if swarmConfig != "run" && swarmConfig != "swarm" {
log.Printf("[DEBUG] Skipping deployment of workers as services as swarmConfig is not set to run or swarm. Value: %#v", swarmConfig)
return
}
ctx := context.Background()
// Looks for and cleans up all existing items in swarm we can't re-use (Shuffle only)
@@ -712,8 +717,6 @@ func deployServiceWorkers(image string) {
}
}
}
}
}
// Deploys the worker with the current available environments
@@ -1910,7 +1913,7 @@ func main() {
pipelineUrl = "http://localhost:5160"
// Find the IP in baseUrl. Base format is http://<ip>:<port>
if baseUrl != "" {
if baseUrl != "" && !strings.Contains(baseUrl, "shuffle") && !strings.Contains(baseUrl, "localhost") && !strings.Contains(baseUrl, "run.app") {
urlSplit := strings.Split(baseUrl, "://")
if len(urlSplit) > 1 {
// Find the IP
@@ -1921,6 +1924,10 @@ func main() {
}
}
if len(containerId) > 0 {
pipelineUrl = "http://tenzir-node:5160"
}
log.Printf("[WARNING] SHUFFLE_PIPELINE_URL not set, falling back to default URL: %s. If BASE_URL is set, we use the external IP for that", pipelineUrl)
os.Setenv("SHUFFLE_PIPELINE_URL", pipelineUrl)
}
@@ -2605,7 +2612,7 @@ func deployTenzirNode() error {
// Check if image exists
_, _, err := dockercli.ImageInspectWithRaw(ctx, imageName)
if dockerclient.IsErrNotFound(err) {
log.Printf("[DEBUG] Pulling image %s", imageName)
log.Printf("[DEBUG] Pulling image %s. This may take a while.", imageName)
pullOptions := image.PullOptions{}
out, err := dockercli.ImagePull(ctx, imageName, pullOptions)
if err != nil {
@@ -2671,6 +2678,7 @@ func createAndStartTenzirNode(ctx context.Context, containerName, imageName stri
// Ensure restart policy is there
config := &container.Config{
Hostname: containerName,
Cmd: []string{"--commands=web server --mode=dev --bind=0.0.0.0"},
Image: imageName,
Healthcheck: healthconfig,
@@ -2768,9 +2776,6 @@ func createAndStartTenzirNode(ctx context.Context, containerName, imageName stri
if isKubernetes != "true" {
hostConfig.NetworkMode = container.NetworkMode(fmt.Sprintf("container:%s", containerId))
if strings.ToLower(cleanupEnv) != "false" {
hostConfig.AutoRemove = true
}
}
_, err := dockercli.ContainerCreate(ctx, config, hostConfig, networkingConfig, nil, containerName)
@@ -2858,9 +2863,6 @@ func checkTenzirNode() error {
return errors.New("Pipelines are disabled by user with SHUFFLE_SKIP_PIPELINES")
}
retries := 1
//retryInterval := 3 * time.Second
url := fmt.Sprintf("%s/api/v0/ping", pipelineUrl)
forwardMethod := "POST"
@@ -2873,16 +2875,14 @@ func checkTenzirNode() error {
return err
}
for i := 0; i < retries; i++ {
resp, err := client.Do(req)
if err == nil && resp.StatusCode == http.StatusOK {
return nil
}
//time.Sleep(retryInterval)
}
log.Printf("[DEBUG] Failed to verify Tenzir node on %s: %s", url, err)
return fmt.Errorf("tenzir node is not available")
return fmt.Errorf("Tenzir node is not available")
}
func createPipeline(command, identifier string) (string, error) {