Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.
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
18 changes: 18 additions & 0 deletions internal/handler/api/capsule/rollback.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package capsule

import (
"context"

"github.com/bufbuild/connect-go"
"github.com/rigdev/rig-go-api/api/v1/capsule"
)

func (h *Handler) Rollback(ctx context.Context, req *connect.Request[capsule.RollbackRequest]) (*connect.Response[capsule.RollbackResponse], error) {
rollout, err := h.cs.Rollback(ctx, req.Msg.GetCapsuleId(), req.Msg.GetRolloutId())
if err != nil {
return nil, err
}
return connect.NewResponse(&capsule.RollbackResponse{
RolloutId: rollout,
}), nil
}
6 changes: 6 additions & 0 deletions internal/service/capsule/rollout.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ func (s *Service) AbortRollout(ctx context.Context, capsuleID string, rolloutID
return s.CreateEvent(ctx, capsuleID, rolloutID, "rollout aborted", &capsule.EventData{Kind: &capsule.EventData_Abort{}})
}

func (s *Service) constructNewRollout(ctx context.Context, capsuleId string, cs []*capsule.Change) (*capsule.Rollout, error) {
return nil, nil
}

func (s *Service) newRollout(ctx context.Context, capsuleID string, cs []*capsule.Change) (uint64, error) {
if _, err := s.ccg.GetCapsuleConfig(ctx, capsuleID); err != nil {
return 0, err
Expand Down Expand Up @@ -129,6 +133,8 @@ func (s *Service) newRollout(ctx context.Context, capsuleID string, cs []*capsul
}
case *capsule.Change_AutoAddRigServiceAccounts:
rc.AutoAddRigServiceAccounts = v.AutoAddRigServiceAccounts
case *capsule.Change_HorizontalScale:
rc.HorizontalScale = v.HorizontalScale
default:
return 0, errors.InvalidArgumentErrorf("unhandled change field '%v'", reflect.TypeOf(v))
}
Expand Down
4 changes: 4 additions & 0 deletions internal/service/capsule/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,7 @@ func applyUpdates(d *capsule.Capsule, us []*capsule.Update) error {
}
return nil
}

func (s *Service) Rollback(ctx context.Context, capsuleID string, rolloutID uint64) (uint64, error) {
return 0, nil
}
10 changes: 10 additions & 0 deletions pkg/api/config/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions pkg/api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions proto/rig/api/v1/capsule/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ service Service {
rpc ListEvents(ListEventsRequest) returns (ListEventsResponse) {}
// Get metrics for a capsule
rpc CapsuleMetrics(CapsuleMetricsRequest) returns (CapsuleMetricsResponse) {}

// Rolls the capsule back to a previous rollout
rpc Rollback(RollbackRequest) returns (RollbackResponse) {}
}

message CreateRequest {
Expand Down Expand Up @@ -221,3 +224,12 @@ message CapsuleMetricsRequest {
message CapsuleMetricsResponse {
repeated InstanceMetrics instance_metrics = 1;
}

message RollbackRequest {
string capsule_id = 1;
uint64 rollout_id = 2;
}

message RollbackResponse {
uint64 rollout_id = 1;
}