Skip to content

Commit ca508e1

Browse files
committed
Remove reboot for now
1 parent 1d8f180 commit ca508e1

File tree

8 files changed

+77
-516
lines changed

8 files changed

+77
-516
lines changed

cmd/api/api/instances.go

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -426,53 +426,6 @@ func (s *ApiService) StartInstance(ctx context.Context, request oapi.StartInstan
426426
return oapi.StartInstance200JSONResponse(instanceToOAPI(*inst)), nil
427427
}
428428

429-
// RebootInstance reboots a running instance
430-
// The id parameter can be an instance ID, name, or ID prefix
431-
func (s *ApiService) RebootInstance(ctx context.Context, request oapi.RebootInstanceRequestObject) (oapi.RebootInstanceResponseObject, error) {
432-
log := logger.FromContext(ctx)
433-
434-
// Resolve to get the actual instance ID
435-
resolved, err := s.InstanceManager.GetInstance(ctx, request.Id)
436-
if err != nil {
437-
switch {
438-
case errors.Is(err, instances.ErrNotFound):
439-
return oapi.RebootInstance404JSONResponse{
440-
Code: "not_found",
441-
Message: "instance not found",
442-
}, nil
443-
case errors.Is(err, instances.ErrAmbiguousName):
444-
return oapi.RebootInstance404JSONResponse{
445-
Code: "ambiguous",
446-
Message: "multiple instances match, use full instance ID",
447-
}, nil
448-
default:
449-
log.ErrorContext(ctx, "failed to get instance", "error", err, "id", request.Id)
450-
return oapi.RebootInstance500JSONResponse{
451-
Code: "internal_error",
452-
Message: "failed to get instance",
453-
}, nil
454-
}
455-
}
456-
457-
inst, err := s.InstanceManager.RebootInstance(ctx, resolved.Id)
458-
if err != nil {
459-
switch {
460-
case errors.Is(err, instances.ErrInvalidState):
461-
return oapi.RebootInstance409JSONResponse{
462-
Code: "invalid_state",
463-
Message: err.Error(),
464-
}, nil
465-
default:
466-
log.ErrorContext(ctx, "failed to reboot instance", "error", err, "id", resolved.Id)
467-
return oapi.RebootInstance500JSONResponse{
468-
Code: "internal_error",
469-
Message: "failed to reboot instance",
470-
}, nil
471-
}
472-
}
473-
return oapi.RebootInstance200JSONResponse(instanceToOAPI(*inst)), nil
474-
}
475-
476429
// logsStreamResponse implements oapi.GetInstanceLogsResponseObject with proper SSE flushing
477430
type logsStreamResponse struct {
478431
logChan <-chan string

cmd/api/api/instances_test.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func TestCreateInstance_InvalidSizeFormat(t *testing.T) {
128128
assert.Contains(t, badReq.Message, "invalid size format")
129129
}
130130

131-
func TestInstanceLifecycle_StopStartReboot(t *testing.T) {
131+
func TestInstanceLifecycle_StopStart(t *testing.T) {
132132
// Require KVM access for VM creation
133133
if _, err := os.Stat("/dev/kvm"); os.IsNotExist(err) {
134134
t.Skip("/dev/kvm not available - skipping lifecycle test")
@@ -194,17 +194,7 @@ func TestInstanceLifecycle_StopStartReboot(t *testing.T) {
194194
// Wait for Running state after start
195195
waitForState(t, svc, instanceID, "Running", 30*time.Second)
196196

197-
// 4. Reboot the instance
198-
t.Log("Rebooting instance...")
199-
rebootResp, err := svc.RebootInstance(ctx(), oapi.RebootInstanceRequestObject{Id: instanceID})
200-
require.NoError(t, err)
201-
202-
rebooted, ok := rebootResp.(oapi.RebootInstance200JSONResponse)
203-
require.True(t, ok, "expected 200 response for reboot, got %T", rebootResp)
204-
assert.Equal(t, oapi.InstanceState("Running"), rebooted.State)
205-
t.Log("Instance rebooted successfully")
206-
207-
// 5. Cleanup - delete the instance
197+
// 4. Cleanup - delete the instance
208198
t.Log("Deleting instance...")
209199
deleteResp, err := svc.DeleteInstance(ctx(), oapi.DeleteInstanceRequestObject{Id: instanceID})
210200
require.NoError(t, err)

lib/instances/manager.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ type Manager interface {
2626
RestoreInstance(ctx context.Context, id string) (*Instance, error)
2727
StopInstance(ctx context.Context, id string) (*Instance, error)
2828
StartInstance(ctx context.Context, id string) (*Instance, error)
29-
RebootInstance(ctx context.Context, id string) (*Instance, error)
3029
StreamInstanceLogs(ctx context.Context, id string, tail int, follow bool) (<-chan string, error)
3130
RotateLogs(ctx context.Context, maxBytes int64, maxFiles int) error
3231
AttachVolume(ctx context.Context, id string, volumeId string, req AttachVolumeRequest) (*Instance, error)
@@ -141,14 +140,6 @@ func (m *manager) StartInstance(ctx context.Context, id string) (*Instance, erro
141140
return m.startInstance(ctx, id)
142141
}
143142

144-
// RebootInstance reboots a running instance
145-
func (m *manager) RebootInstance(ctx context.Context, id string) (*Instance, error) {
146-
lock := m.getInstanceLock(id)
147-
lock.Lock()
148-
defer lock.Unlock()
149-
return m.rebootInstance(ctx, id)
150-
}
151-
152143
// ListInstances returns all instances
153144
func (m *manager) ListInstances(ctx context.Context) ([]Instance, error) {
154145
// No lock - eventual consistency is acceptable for list operations.

lib/instances/metrics.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ type Metrics struct {
1616
standbyDuration metric.Float64Histogram
1717
stopDuration metric.Float64Histogram
1818
startDuration metric.Float64Histogram
19-
rebootDuration metric.Float64Histogram
2019
stateTransitions metric.Int64Counter
2120
tracer trace.Tracer
2221
}
@@ -68,15 +67,6 @@ func newInstanceMetrics(meter metric.Meter, tracer trace.Tracer, m *manager) (*M
6867
return nil, err
6968
}
7069

71-
rebootDuration, err := meter.Float64Histogram(
72-
"hypeman_instances_reboot_duration_seconds",
73-
metric.WithDescription("Time to reboot an instance"),
74-
metric.WithUnit("s"),
75-
)
76-
if err != nil {
77-
return nil, err
78-
}
79-
8070
stateTransitions, err := meter.Int64Counter(
8171
"hypeman_instances_state_transitions_total",
8272
metric.WithDescription("Total number of instance state transitions"),
@@ -122,7 +112,6 @@ func newInstanceMetrics(meter metric.Meter, tracer trace.Tracer, m *manager) (*M
122112
standbyDuration: standbyDuration,
123113
stopDuration: stopDuration,
124114
startDuration: startDuration,
125-
rebootDuration: rebootDuration,
126115
stateTransitions: stateTransitions,
127116
tracer: tracer,
128117
}, nil

lib/instances/reboot.go

Lines changed: 0 additions & 76 deletions
This file was deleted.

0 commit comments

Comments
 (0)