API: introduce ability to watch a VM (#351)

* API: introduce ability to watch a VM

* Document ?watch=true for GET /vms/{name} in the OpenAPI specification

* WatchVM: ensure that goroutine is terminated on early return with error

* WatchVM: close channels on goroutine exit

* WatchVM: ensure that we wait for the goroutine after additional barriers

* WatchVM: ignore unexpected keys instead of throwing an error

* WatchVM: perform context-aware writes to a bounded channel

* WatchVM: don't forget to close errCh on goroutine exit too

* WatchVM: don't close readyCh in goroutine to avoid ambiguity

* WatchVM: filter out spurious KVs that signify VM deletion
This commit is contained in:
Nikolay Edigaryev
2025-10-03 21:34:53 +04:00
committed by GitHub
parent cdece3149b
commit c5e0d68a3d
9 changed files with 458 additions and 6 deletions
+3 -2
View File
@@ -4,6 +4,9 @@ import (
"context"
"crypto/subtle"
"errors"
"net/http"
"strings"
"github.com/cirruslabs/orchard/api"
storepkg "github.com/cirruslabs/orchard/internal/controller/store"
"github.com/cirruslabs/orchard/internal/responder"
@@ -16,8 +19,6 @@ import (
"github.com/penglongli/gin-metrics/ginmetrics"
"go.uber.org/zap"
"google.golang.org/grpc/metadata"
"net/http"
"strings"
)
const ctxServiceAccountKey = "service-account"