mirror of
https://github.com/portainer/portainer.git
synced 2025-07-21 22:39:41 +02:00
fix(edge-stack): parse docker compose multi lines json output EE-6317 (#10627)
This commit is contained in:
parent
ad5a17ac34
commit
57ed6ae6a6
1 changed files with 20 additions and 7 deletions
|
@ -1,8 +1,10 @@
|
||||||
package composeplugin
|
package composeplugin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/portainer/portainer/pkg/libstack"
|
"github.com/portainer/portainer/pkg/libstack"
|
||||||
|
@ -107,6 +109,7 @@ func (wrapper *PluginWrapper) WaitForStatus(ctx context.Context, name string, st
|
||||||
errorMessageCh := make(chan string)
|
errorMessageCh := make(chan string)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
OUTER:
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
|
@ -135,13 +138,23 @@ func (wrapper *PluginWrapper) WaitForStatus(ctx context.Context, name string, st
|
||||||
}
|
}
|
||||||
|
|
||||||
var services []service
|
var services []service
|
||||||
err = json.Unmarshal(output, &services)
|
dec := json.NewDecoder(bytes.NewReader(output))
|
||||||
|
for {
|
||||||
|
var svc service
|
||||||
|
|
||||||
|
err := dec.Decode(&svc)
|
||||||
|
if err == io.EOF {
|
||||||
|
break
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debug().
|
log.Debug().
|
||||||
Str("project_name", name).
|
Str("project_name", name).
|
||||||
Err(err).
|
Err(err).
|
||||||
Msg("failed to parse docker compose output")
|
Msg("failed to parse docker compose output")
|
||||||
continue
|
continue OUTER
|
||||||
|
}
|
||||||
|
|
||||||
|
services = append(services, svc)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(services) == 0 && status == libstack.StatusRemoved {
|
if len(services) == 0 && status == libstack.StatusRemoved {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue