Skip to content

Commit

Permalink
fix(edge/stacks): send correct 2.19 payload [EE-5912]
Browse files Browse the repository at this point in the history
fix [EE-5912]
  • Loading branch information
Chaim Lev-Ari committed Aug 13, 2023
1 parent eebca84 commit f255287
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions edge/client/portainer_edge_async_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ type snapshot struct {
KubernetesHash *uint32 `json:"kubernetesHash,omitempty"`

StackLogs []EdgeStackLog `json:"stackLogs,omitempty"`
StackStatus map[portainer.EdgeStackID][]portainer.EdgeStackDeploymentStatus `json:"stackStatus,omitempty"`
StackStatusArray map[portainer.EdgeStackID][]portainer.EdgeStackDeploymentStatus `json:"stackStatusArray,omitempty"`
JobsStatus map[portainer.EdgeJobID]agent.EdgeJobStatus `json:"jobsStatus,omitempty"`
EdgeConfigStates map[EdgeConfigID]EdgeConfigStateType `json:"edgeConfigStates,omitempty"`
}
Expand Down Expand Up @@ -282,7 +282,7 @@ func (client *PortainerAsyncClient) GetEnvironmentStatus(flags ...string) (*Poll
}

client.nextSnapshotMutex.Lock()
payload.Snapshot.StackStatus = client.nextSnapshot.StackStatus
payload.Snapshot.StackStatusArray = client.nextSnapshot.StackStatusArray
payload.Snapshot.JobsStatus = client.nextSnapshot.JobsStatus
payload.Snapshot.EdgeConfigStates = client.nextSnapshot.EdgeConfigStates
client.nextSnapshotMutex.Unlock()
Expand Down Expand Up @@ -319,15 +319,15 @@ func (client *PortainerAsyncClient) GetEnvironmentStatus(flags ...string) (*Poll
client.lastSnapshot.Docker = currentSnapshot.Docker
client.lastSnapshot.Kubernetes = currentSnapshot.Kubernetes

if client.lastSnapshot.StackStatus == nil {
client.lastSnapshot.StackStatus = make(map[portainer.EdgeStackID][]portainer.EdgeStackDeploymentStatus)
if client.lastSnapshot.StackStatusArray == nil {
client.lastSnapshot.StackStatusArray = make(map[portainer.EdgeStackID][]portainer.EdgeStackDeploymentStatus)
}

for k, v := range client.nextSnapshot.StackStatus {
client.lastSnapshot.StackStatus[k] = v
for k, v := range client.nextSnapshot.StackStatusArray {
client.lastSnapshot.StackStatusArray[k] = v
}

client.nextSnapshot.StackStatus = nil
client.nextSnapshot.StackStatusArray = nil
client.nextSnapshot.JobsStatus = nil
client.nextSnapshot.EdgeConfigStates = nil
client.stackLogCollectionQueue = nil
Expand Down Expand Up @@ -438,13 +438,13 @@ func (client *PortainerAsyncClient) SetEdgeStackStatus(edgeStackID int, edgeStac
client.nextSnapshotMutex.Lock()
defer client.nextSnapshotMutex.Unlock()

if client.nextSnapshot.StackStatus == nil {
client.nextSnapshot.StackStatus = make(map[portainer.EdgeStackID][]portainer.EdgeStackDeploymentStatus)
if client.nextSnapshot.StackStatusArray == nil {
client.nextSnapshot.StackStatusArray = make(map[portainer.EdgeStackID][]portainer.EdgeStackDeploymentStatus)
}

status, ok := client.nextSnapshot.StackStatus[portainer.EdgeStackID(edgeStackID)]
status, ok := client.nextSnapshot.StackStatusArray[portainer.EdgeStackID(edgeStackID)]
if !ok {
status = client.lastSnapshot.StackStatus[portainer.EdgeStackID(edgeStackID)]
status = client.lastSnapshot.StackStatusArray[portainer.EdgeStackID(edgeStackID)]
}

if edgeStackStatus == portainer.EdgeStackStatusRemoved {
Expand All @@ -458,7 +458,7 @@ func (client *PortainerAsyncClient) SetEdgeStackStatus(edgeStackID int, edgeStac
})
}

client.nextSnapshot.StackStatus[portainer.EdgeStackID(edgeStackID)] = status
client.nextSnapshot.StackStatusArray[portainer.EdgeStackID(edgeStackID)] = status

return nil
}
Expand Down

0 comments on commit f255287

Please sign in to comment.