Skip to content
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
28 changes: 15 additions & 13 deletions apihandlers/post_feed_instance_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@ import (
"github.com/opensvc/oc3/cachekeys"
)

// {
// "action": "thaw",
// "argv": [
// "foo",
// "thaw",
// "--local"
// ],
// "begin": "2026-01-12 10:57:12",
// "cron": false,
// "path": "foo",
// "session_uuid": "b9d795bc-498e-4c20-aada-9feec2eaa947",
// "version": "2.1-1977"
// }
/*
{
"action": "thaw",
"argv": [
"foo",
"thaw",
"--local"
],
"begin": "2026-01-21T18:00:00.357669+01:00",
"cron": false,
"path": "foo",
"session_uuid": "b9d795bc-498e-4c20-aada-9feec2eaa947",
"version": "2.1-1977"
}
*/

// PostFeedInstanceAction handles POST /action/begin
func (a *Api) PostFeedInstanceAction(c echo.Context) error {
Expand Down
40 changes: 13 additions & 27 deletions apihandlers/put_feed_instance_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@ import (
"github.com/opensvc/oc3/cachekeys"
)

// {
// "uuid": "ea9a8373-3dda-4fe7-8c4b-08f5290c6c8b",
// "path": "foo",
// "action": "thaw",
// "begin": "2026-01-16 15:05:00",
// "end": "2026-01-16 15:06:00",
// "cron": false,
// "session_uuid": "7f2df7b2-8a4a-4bc1-9a8b-03acffaacd45",
// "actionlogfile": "/var/tmp/opensvc/foo.freezeupdfl98l",
// "status": "ok"
// }
/*
{
"uuid": "ea9a8373-3dda-4fe7-8c4b-08f5290c6c8b",
"path": "foo",
"action": "thaw",
"begin": "2026-01-21T18:00:00.357669+01:00",
"end": "2026-01-21T18:05:00.357669+01:00",
"cron": false,
"session_uuid": "7f2df7b2-8a4a-4bc1-9a8b-03acffaacd45",
"actionlogfile": "/var/tmp/opensvc/foo.freezeupdfl98l",
"status": "ok"
}
*/

// PutFeedInstanceActionEnd handles PUT /feed/action
func (a *Api) PutFeedInstanceActionEnd(c echo.Context) error {
Expand Down Expand Up @@ -56,22 +58,6 @@ func (a *Api) PutFeedInstanceActionEnd(c echo.Context) error {

idx := fmt.Sprintf("%s@%s@%s:%s", payload.Path, nodeID, ClusterID, payload.Uuid)

// if action is pending, update the stored begin action with end info to avoid begin and end processing
if n, err := a.Redis.HExists(reqCtx, keyPendingH, idx).Result(); err == nil && n {
if currentBytes, err := a.Redis.HGet(reqCtx, keyH, idx).Bytes(); err == nil {
var currentAction api.Action
if err := json.Unmarshal(currentBytes, &currentAction); err == nil {
currentAction.End = payload.End
currentAction.Status = payload.Status
currentAction.StatusLog = payload.StatusLog

if updatedBytes, err := json.Marshal(currentAction); err == nil {
b = updatedBytes
}
}
}
}

s := fmt.Sprintf("HSET %s %s", keyH, idx)
if _, err := a.Redis.HSet(reqCtx, keyH, idx, b).Result(); err != nil {
s = fmt.Sprintf("%s: %s", s, err)
Expand Down
Loading