fixing things a little bit
This commit is contained in:
@@ -1500,7 +1500,7 @@ func main() {
|
|||||||
initializeImages()
|
initializeImages()
|
||||||
|
|
||||||
if isTenzir == "true" {
|
if isTenzir == "true" {
|
||||||
func() {
|
go func() {
|
||||||
if err := deployTenzirNode(); err != nil {
|
if err := deployTenzirNode(); err != nil {
|
||||||
log.Printf("[ERROR] Failed to deploy the tenzir node, reason: %v", err)
|
log.Printf("[ERROR] Failed to deploy the tenzir node, reason: %v", err)
|
||||||
} else {
|
} else {
|
||||||
@@ -1681,15 +1681,15 @@ func main() {
|
|||||||
newrequests := []shuffle.ExecutionRequest{}
|
newrequests := []shuffle.ExecutionRequest{}
|
||||||
for _, incRequest := range executionRequests.Data {
|
for _, incRequest := range executionRequests.Data {
|
||||||
// Looking for specific jobs
|
// Looking for specific jobs
|
||||||
if isTenzir == "true" && incRequest.Type == "PIPELINE_CREATE" || incRequest.Type == "PIPELINE_STOP" || incRequest.Type == "PIPELINE_DELETE" {
|
if incRequest.Type == "PIPELINE_CREATE" || incRequest.Type == "PIPELINE_STOP" || incRequest.Type == "PIPELINE_DELETE" {
|
||||||
if isTenzirReady {
|
if isTenzir == "true" && isTenzirReady {
|
||||||
err := handlePipeline(incRequest)
|
err := handlePipeline(incRequest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[ERROR] Failed handling pipeline: %s", err)
|
log.Printf("[ERROR] Failed handling pipeline: %s", err)
|
||||||
//update it to db ??
|
//update it to db ??
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Printf("[WARNING] Couldnt Handle pipeline request as tenzir node is not ready")
|
log.Printf("[WARNING] Unable to Handle pipeline request as tenzir node is not ready")
|
||||||
}
|
}
|
||||||
toBeRemoved.Data = append(toBeRemoved.Data, incRequest)
|
toBeRemoved.Data = append(toBeRemoved.Data, incRequest)
|
||||||
|
|
||||||
@@ -2120,7 +2120,7 @@ func deployTenzirNode() error {
|
|||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
imageName := "tenzir/tenzir"
|
imageName := "tenzir/tenzir"
|
||||||
containerName := "tenzir-node"
|
containerName := "tenzir-node"
|
||||||
|
|
||||||
healthconfig := &container.HealthConfig{
|
healthconfig := &container.HealthConfig{
|
||||||
@@ -2131,7 +2131,7 @@ func deployTenzirNode() error {
|
|||||||
|
|
||||||
config := &container.Config{
|
config := &container.Config{
|
||||||
Cmd: []string{"--commands=web server --mode=dev --bind=0.0.0.0"},
|
Cmd: []string{"--commands=web server --mode=dev --bind=0.0.0.0"},
|
||||||
Image: imageName,
|
Image: imageName,
|
||||||
Healthcheck: healthconfig,
|
Healthcheck: healthconfig,
|
||||||
ExposedPorts: nat.PortSet{"5160/tcp": struct{}{}},
|
ExposedPorts: nat.PortSet{"5160/tcp": struct{}{}},
|
||||||
Entrypoint: []string{containerName},
|
Entrypoint: []string{containerName},
|
||||||
@@ -2155,7 +2155,7 @@ func deployTenzirNode() error {
|
|||||||
pullOptions := types.ImagePullOptions{}
|
pullOptions := types.ImagePullOptions{}
|
||||||
out, err := dockercli.ImagePull(ctx, imageName, pullOptions)
|
out, err := dockercli.ImagePull(ctx, imageName, pullOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[ERROR] Failed to pull the tenzir image %s",err)
|
log.Printf("[ERROR] Failed to pull the tenzir image %s", err)
|
||||||
}
|
}
|
||||||
defer out.Close()
|
defer out.Close()
|
||||||
|
|
||||||
@@ -2164,32 +2164,22 @@ func deployTenzirNode() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
if strings.Contains(fmt.Sprintf("%s", err), "Conflict. The container name ") {
|
if strings.Contains(fmt.Sprintf("%s", err), "Conflict. The container name ") {
|
||||||
log.Printf("[DEBUG] Tenzir Node Container already exists, starting it")
|
log.Printf("[DEBUG] Tenzir Node Container already exists, starting it")
|
||||||
|
} else {
|
||||||
err = dockercli.ContainerStart(ctx, containerName, containerStartOptions)
|
log.Printf("[ERROR] Failed to create Tenzir container: %s", err)
|
||||||
if err != nil {
|
return err
|
||||||
log.Printf("[ERROR] Failed to start existing Tenzir Node container: %v", err)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Printf("[INFO] Existing Tenzir Node container started successfully")
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("[INFO] New Tenzir Node container created successfully")
|
|
||||||
|
|
||||||
err = dockercli.ContainerStart(ctx, containerName, containerStartOptions)
|
err = dockercli.ContainerStart(ctx, containerName, containerStartOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[ERROR] Failed to start new Tenzir Node container: %v", err)
|
log.Printf("[ERROR] Failed to start Tenzir Node container: %v", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
log.Printf("[INFO] Tenzir Node container started successfully")
|
||||||
log.Printf("[INFO] New Tenzir Node container started successfully")
|
|
||||||
|
|
||||||
log.Printf("[INFO] Waiting for tenzir to become available ...")
|
log.Printf("[INFO] Waiting for tenzir to become available ...")
|
||||||
err = checkTenzirNode()
|
err = checkTenzirNode()
|
||||||
if err != nil{
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2199,7 +2189,7 @@ func deployTenzirNode() error {
|
|||||||
func checkTenzirNode() error {
|
func checkTenzirNode() error {
|
||||||
retries := 20
|
retries := 20
|
||||||
retryInterval := 3 * time.Second
|
retryInterval := 3 * time.Second
|
||||||
url := fmt.Sprintf("%s/ping",tenzirUrl)
|
url := fmt.Sprintf("%s/api/v0/ping",tenzirUrl)
|
||||||
forwardMethod := "POST"
|
forwardMethod := "POST"
|
||||||
|
|
||||||
client := http.Client{}
|
client := http.Client{}
|
||||||
|
|||||||
Reference in New Issue
Block a user