Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
21518d1
initial commit
Feb 13, 2026
87ab92a
change folder structure
Feb 16, 2026
71a4085
add migrations action to proto and gRPC server
Feb 19, 2026
cde4d02
add service discovery to gRPC and proto
Feb 20, 2026
f249ae2
change get_service_address to take instance url instead of dirpath
Feb 23, 2026
2feb15c
add GetModels action to proto messages and adjust message naming
Feb 23, 2026
44e5576
add better proto message type use in actions scripts
Feb 23, 2026
dd8177d
add GetCollection to proto and adjust the script to use message types
Feb 23, 2026
ce38ccf
fix stats field handling
Feb 24, 2026
a86397c
add GetCollection gRPC endpoint
Feb 24, 2026
936f62c
adjust k8s health action and helpers for gRPC server integration
Feb 26, 2026
6077d17
adjust setup/config for gRPC integration and add server endpoints
Feb 26, 2026
ea48ab3
adjust scale/updateBackendmanage for gRPC integration and add server …
Feb 27, 2026
5f62707
adjust k8s start/stop for gRPC integration, add proto messages and se…
Mar 2, 2026
07d2fe4
adjust create/remove for gRPC integration, add proto messages and ser…
Mar 3, 2026
525f1cc
fix scale.go server endpoint parameter bug
Mar 3, 2026
6ed9d34
fix namespace extraction bug in scale.go ScaleService
Mar 3, 2026
c49602c
health and start/update_instance give same response, adjust update_in…
Mar 3, 2026
d1cf205
move create instance password checks into exported function
Mar 5, 2026
b29bf97
add SendManageAction to proto definitions and add gRPC server endpoin…
Mar 6, 2026
d0bcdb3
feature: add configs param to NewConfig function allowing configs sen…
Mar 11, 2026
f95c265
add migrations migrate/finalize status strings to constants.go
Mar 12, 2026
757b3e5
add stop condition to migrations migrate/finalize to account for diff…
Mar 12, 2026
01a0aa2
add stopCondition to gRPC server endpoint for migrations
Mar 12, 2026
ec41d53
Merge branch 'main' into feature/add-gRPC-server
Mar 13, 2026
c1c03ce
add --clean flag to setup/config cli and proto that wipes stack folde…
Mar 13, 2026
2ff7e53
add pruneOrphans method that removes resources from namespace not in …
Mar 13, 2026
347cd9d
adjust gRPC server implementation for flexible IP:Port assignment and…
Mar 17, 2026
722757e
update openslides-go to v0.0.0-20260317105801-e0e5c62bd3b1 and adjust…
Mar 17, 2026
7e295bd
remove backendmanage revert flag and field in proto
Mar 19, 2026
5784ff0
add namespace exists check to k8s actions and grpc
Mar 31, 2026
413c8ed
Add label based filtering of resources
Apr 15, 2026
0ec55bd
Add instance status grpc server implementation for osctl status check
Apr 30, 2026
25b1c90
Add missing proto files
Apr 30, 2026
ccbae28
Fix linter issues
Apr 30, 2026
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
4 changes: 4 additions & 0 deletions cmd/osmanage/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"

grpcServer "github.com/OpenSlides/openslides-cli/internal/grpc/server"
"github.com/OpenSlides/openslides-cli/internal/instance/config"
"github.com/OpenSlides/openslides-cli/internal/instance/create"
"github.com/OpenSlides/openslides-cli/internal/instance/remove"
Expand Down Expand Up @@ -81,6 +82,8 @@ func RootCmd() *cobra.Command {
k8sActions.UpdateInstanceCmd(),
k8sActions.ScaleCmd(),
k8sActions.GetServiceAddressCmd(),
k8sActions.GetNamespaceExistsCmd(),
k8sActions.GetInstanceStatusCmd(),
)

rootCmd.AddCommand(
Expand All @@ -96,6 +99,7 @@ func RootCmd() *cobra.Command {
action.Cmd(),
migrations.Cmd(),
k8sCmd,
grpcServer.Cmd(),
)

return rootCmd
Expand Down
17 changes: 9 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ module github.com/OpenSlides/openslides-cli
go 1.25.1

require (
github.com/OpenSlides/openslides-go v0.0.0-20251104124242-d8e4b15bb11e
github.com/OpenSlides/openslides-go v0.0.0-20260317105801-e0e5c62bd3b1
github.com/schollz/progressbar/v3 v3.19.0
github.com/shopspring/decimal v1.4.0
github.com/spf13/cobra v1.10.2
golang.org/x/text v0.35.0
google.golang.org/grpc v1.79.1
google.golang.org/protobuf v1.36.10
k8s.io/api v0.35.2
k8s.io/apimachinery v0.35.2
k8s.io/client-go v0.35.2
Expand All @@ -26,7 +28,7 @@ require (
github.com/google/uuid v1.6.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/pgx/v5 v5.7.6 // indirect
github.com/jackc/pgx/v5 v5.8.0 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
Expand All @@ -39,14 +41,13 @@ require (
github.com/x448/float16 v0.8.4 // indirect
go.yaml.in/yaml/v2 v2.4.3 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/crypto v0.44.0 // indirect
golang.org/x/net v0.47.0 // indirect
golang.org/x/oauth2 v0.30.0 // indirect
golang.org/x/net v0.48.0 // indirect
golang.org/x/oauth2 v0.34.0 // indirect
golang.org/x/sync v0.20.0 // indirect
golang.org/x/sys v0.38.0 // indirect
golang.org/x/term v0.37.0 // indirect
golang.org/x/sys v0.41.0 // indirect
golang.org/x/term v0.38.0 // indirect
golang.org/x/time v0.9.0 // indirect
google.golang.org/protobuf v1.36.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 // indirect
gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
102 changes: 66 additions & 36 deletions go.sum

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions internal/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,15 @@ const (
// MigrationStatusRunning indicates a migration is currently in progress
MigrationStatusRunning string = "migration_running"

// MigrationStatusFailed indicates a migration process has failed
MigrationStatusFailed string = "migration_failed"

// FinalizationStatusRunning indicates a migration finalization is currently in progress
FinalizationStatusRunning string = "finalization_running"

// FinalizationStatusFailed indicates a migration finalization process has failed
FinalizationStatusFailed string = "finalization_failed"

// MigrationMaxRetries is the maximum number of retry attempts for failed migration requests
MigrationMaxRetries int = 5

Expand Down Expand Up @@ -253,3 +262,10 @@ func GetKindPriority(kind string) int {
}
return 100
}

// gRPC server defaults
const (
GRPCHost string = "127.0.0.1"
GRPCPort string = "50051"
GRPCGracefulStopTimeout time.Duration = 30 * time.Second
)
30 changes: 30 additions & 0 deletions internal/grpc/server/cluster_status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package server

import (
"context"
"fmt"

"github.com/OpenSlides/openslides-cli/internal/k8s/actions"
"github.com/OpenSlides/openslides-cli/internal/k8s/client"
pb "github.com/OpenSlides/openslides-cli/proto/osmanage"
)

func (s *OsmanageServiceServer) GetClusterStatus(ctx context.Context, req *pb.GetClusterStatusRequest) (*pb.GetClusterStatusResponse, error) {
k8sClient, err := client.New(req.Kubeconfig)
if err != nil {
return nil, fmt.Errorf("creating k8s client: %w", err)
}

status, err := actions.CheckClusterStatus(ctx, k8sClient)
if err != nil {
return nil, fmt.Errorf("checking cluster status: %w", err)
}

statusMsg := fmt.Sprintf("Cluster: %d/%d nodes ready", status.ReadyNodes, status.TotalNodes)

return &pb.GetClusterStatusResponse{
Status: statusMsg,
TotalNodes: int32(status.TotalNodes),
ReadyNodes: int32(status.ReadyNodes),
}, nil
}
23 changes: 23 additions & 0 deletions internal/grpc/server/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package server

import (
"context"

instanceconfig "github.com/OpenSlides/openslides-cli/internal/instance/config"
pb "github.com/OpenSlides/openslides-cli/proto/osmanage"
)

func (s *OsmanageServiceServer) ConfigInstance(ctx context.Context, req *pb.InstanceConfigRequest) (*pb.InstanceConfigResponse, error) {
err := instanceconfig.Run(
req.InstanceDir,
req.Force,
req.Clean,
req.StackTemplatePath,
nil,
req.Configs,
)
if err != nil {
return &pb.InstanceConfigResponse{Success: false, Error: err.Error()}, nil
}
return &pb.InstanceConfigResponse{Success: true}, nil
}
15 changes: 15 additions & 0 deletions internal/grpc/server/create.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package server

import (
"context"

"github.com/OpenSlides/openslides-cli/internal/instance/create"
pb "github.com/OpenSlides/openslides-cli/proto/osmanage"
)

func (s *OsmanageServiceServer) CreateInstance(ctx context.Context, req *pb.CreateInstanceRequest) (*pb.CreateInstanceResponse, error) {
if err := create.CreateInstance(req.InstanceDir, req.DbPassword, req.SuperadminPassword); err != nil {
return &pb.CreateInstanceResponse{Success: false, Error: err.Error()}, nil
}
return &pb.CreateInstanceResponse{Success: true}, nil
}
36 changes: 36 additions & 0 deletions internal/grpc/server/get.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package server

import (
"context"

"github.com/OpenSlides/openslides-cli/internal/manage/actions/get"
pb "github.com/OpenSlides/openslides-cli/proto/osmanage"
)

func (s *OsmanageServiceServer) GetCollection(
ctx context.Context,
req *pb.GetCollectionRequest,
) (*pb.GetCollectionResponse, error) {
if req.DbConfig == nil {
return &pb.GetCollectionResponse{
Success: false,
Error: "db_config is required",
}, nil
}
if req.QueryParams == nil {
return &pb.GetCollectionResponse{
Success: false,
Error: "query_params is required",
}, nil
}

result, err := get.ExecuteGetCollection(ctx, req.DbConfig, req.QueryParams)
if err != nil {
return &pb.GetCollectionResponse{
Success: false,
Error: err.Error(),
}, nil
}

return result, nil
}
25 changes: 25 additions & 0 deletions internal/grpc/server/get_namespace_exists.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package server

import (
"context"
"strings"

"github.com/OpenSlides/openslides-cli/internal/k8s/actions"
"github.com/OpenSlides/openslides-cli/internal/k8s/client"
pb "github.com/OpenSlides/openslides-cli/proto/osmanage"
)

func (s *OsmanageServiceServer) GetNamespaceExists(ctx context.Context, req *pb.GetNamespaceExistsRequest) (*pb.GetNamespaceExistsResponse, error) {
k8sClient, err := client.New(req.Kubeconfig)
if err != nil {
return &pb.GetNamespaceExistsResponse{Error: err.Error()}, nil
}
namespace := strings.ReplaceAll(req.InstanceUrl, ".", "")

exists, err := actions.GetNamespaceExists(ctx, k8sClient.Clientset(), namespace)
if err != nil {
return &pb.GetNamespaceExistsResponse{Error: err.Error()}, nil
}

return &pb.GetNamespaceExistsResponse{Exists: exists}, nil
}
25 changes: 25 additions & 0 deletions internal/grpc/server/get_service_address.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package server

import (
"context"
"strings"

"github.com/OpenSlides/openslides-cli/internal/k8s/actions"
"github.com/OpenSlides/openslides-cli/internal/k8s/client"
pb "github.com/OpenSlides/openslides-cli/proto/osmanage"
)

func (s *OsmanageServiceServer) GetServiceAddress(ctx context.Context, req *pb.GetServiceAddressRequest) (*pb.GetServiceAddressResponse, error) {
k8sClient, err := client.New(req.Kubeconfig)
if err != nil {
return &pb.GetServiceAddressResponse{Error: err.Error()}, nil
}
namespace := strings.ReplaceAll(req.InstanceUrl, ".", "")

address, err := actions.GetServiceAddress(ctx, k8sClient.Clientset(), namespace, req.ServiceName)
if err != nil {
return &pb.GetServiceAddressResponse{Error: err.Error()}, nil
}

return &pb.GetServiceAddressResponse{Address: address}, nil
}
89 changes: 89 additions & 0 deletions internal/grpc/server/health.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package server

import (
"strings"
"time"

"github.com/OpenSlides/openslides-cli/internal/constants"
"github.com/OpenSlides/openslides-cli/internal/k8s/actions"
"github.com/OpenSlides/openslides-cli/internal/k8s/client"
pb "github.com/OpenSlides/openslides-cli/proto/osmanage"
)

func (s *OsmanageServiceServer) GetInstanceHealth(
req *pb.GetInstanceHealthRequest,
stream pb.OsmanageService_GetInstanceHealthServer,
) error {
namespace := strings.ReplaceAll(req.InstanceUrl, ".", "")

k8sClient, err := client.New(req.Kubeconfig)
if err != nil {
return stream.Send(&pb.GetInstanceHealthResponse{
Complete: true,
Error: err.Error(),
})
}

ctx := stream.Context()

if req.Wait {
timeout := time.Duration(req.TimeoutSeconds) * time.Second
if timeout == 0 {
timeout = constants.DefaultInstanceTimeout
}

streamCallback := func(status *actions.HealthStatus) error {
select {
case <-ctx.Done():
return ctx.Err()
default:
}

return stream.Send(healthStatusToHealthResponse(status, false))
}

err := actions.WaitForInstanceHealthy(ctx, k8sClient, namespace, timeout, streamCallback)

if err != nil {
return stream.Send(&pb.GetInstanceHealthResponse{
Complete: true,
Error: err.Error(),
})
}

return stream.Send(&pb.GetInstanceHealthResponse{
Complete: true,
})
}

status, err := actions.GetHealthStatus(ctx, k8sClient, namespace)
if err != nil {
return stream.Send(&pb.GetInstanceHealthResponse{
Complete: true,
Error: err.Error(),
})
}

return stream.Send(healthStatusToHealthResponse(status, true))
}

// Helper to convert internal type to proto
func healthStatusToHealthResponse(status *actions.HealthStatus, complete bool) *pb.GetInstanceHealthResponse {
pods := make([]*pb.PodStatus, len(status.Pods))
for i, pod := range status.Pods {
pods[i] = &pb.PodStatus{
Name: pod.Name,
Phase: string(pod.Status.Phase),
Ready: actions.IsPodReady(&pod),
}
}

return &pb.GetInstanceHealthResponse{
Healthy: status.Healthy,
ReadyPods: int32(status.Ready),
TotalPods: int32(status.Total),
ActivePods: int32(status.ActivePods),
Pods: pods,
Complete: complete,
}
}
Loading
Loading