Skip to content

Commit

Permalink
Merge pull request #636 from kthcloud/dev
Browse files Browse the repository at this point in the history
Maintenance Update
  • Loading branch information
saffronjam authored Jun 1, 2024
2 parents e44cd34 + 5d4a0c8 commit ee2eed2
Show file tree
Hide file tree
Showing 17 changed files with 31 additions and 84 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

- name: Run acceptance tests
run: |
go test -timeout 30m ./test/acc/...
go test -timeout 90m ./test/acc/...
- name: Start main program
run: |
Expand Down
8 changes: 4 additions & 4 deletions pkg/services/system_state_poll/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
func Setup(ctx context.Context) {
log.Println("Starting pollers")

go services.PeriodicWorker(ctx, "statsWorker", StatsWorker, config.Config.Timer.FetchSystemStats)
go services.PeriodicWorker(ctx, "capacitiesWorker", CapacitiesWorker, config.Config.Timer.FetchSystemCapacities)
go services.PeriodicWorker(ctx, "statusWorker", StatusWorker, config.Config.Timer.FetchSystemStatus)
go services.PeriodicWorker(ctx, "gpuInfoWorker", GpuInfoWorker, config.Config.Timer.FetchSystemGpuInfo)
go services.PeriodicWorker(ctx, "systemStatsWorker", StatsWorker, config.Config.Timer.FetchSystemStats)
go services.PeriodicWorker(ctx, "systemCapacitiesWorker", CapacitiesWorker, config.Config.Timer.FetchSystemCapacities)
go services.PeriodicWorker(ctx, "systemStatusWorker", StatusWorker, config.Config.Timer.FetchSystemStatus)
go services.PeriodicWorker(ctx, "systemGpuInfoWorker", GpuInfoWorker, config.Config.Timer.FetchSystemGpuInfo)
}
2 changes: 1 addition & 1 deletion pkg/subsystems/k8s/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (client *Client) CreateOneShotJob(public *models.JobPublic) error {
}

// Wait for the job to complete.
maxIter := 60
maxIter := 600
iter := 0
for {
k8sJob, err := client.K8sClient.BatchV1().Jobs(public.Namespace).Get(context.TODO(), public.Name, metav1.GetOptions{})
Expand Down
6 changes: 3 additions & 3 deletions routers/api/v2/worker_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"go-deploy/dto/v2/query"
"go-deploy/pkg/sys"
"go-deploy/service"
"go-deploy/service/v2/status/opts"
"go-deploy/service/v2/system/opts"
)

// ListWorkerStatus
Expand All @@ -18,7 +18,7 @@ import (
// @Success 200 {array} body.WorkerStatusRead
// @Failure 400 {object} sys.ErrorResponse
// @Failure 500 {object} sys.ErrorResponse
// @Router /v2/status [get]
// @Router /v2/workerStatus [get]
func ListWorkerStatus(c *gin.Context) {
context := sys.NewContext(c)

Expand All @@ -28,7 +28,7 @@ func ListWorkerStatus(c *gin.Context) {
return
}

workerStatus, err := service.V2().Status().ListWorkerStatus(opts.ListWorkerStatusOpts{})
workerStatus, err := service.V2().System().ListWorkerStatus(opts.ListWorkerStatusOpts{})
if err != nil {
context.ServerError(err, InternalError)
return
Expand Down
2 changes: 1 addition & 1 deletion routers/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func NewRouter() *gin.Engine {
router.GET("/", func(c *gin.Context) {
c.HTML(http.StatusOK, "index.html", gin.H{
"staticFolder": basePath + "/static",
"apiUrl": config.Config.ExternalUrl + "/v1/status",
"apiUrl": config.Config.ExternalUrl + "/v2/workerStatus",
})
})

Expand Down
1 change: 0 additions & 1 deletion routers/routes/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func RoutingGroups() []RoutingGroup {
ResourceMigrationRoutes(),
SmRoutes(),
SnapshotRoutes(),
StatusRoutes(),
SystemRoutes(),
TeamRoutes(),
UserRoutes(),
Expand Down
19 changes: 0 additions & 19 deletions routers/routes/status.go

This file was deleted.

2 changes: 2 additions & 0 deletions routers/routes/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const (
SystemCapacitiesPath = "/v2/systemCapacities"
SystemStatsPath = "/v2/systemStats"
SystemStatusPath = "/v2/systemStatus"
WorkerStatusPath = "/v2/workerStatus"
)

type SystemRoutingGroup struct{ RoutingGroupBase }
Expand All @@ -19,5 +20,6 @@ func (group *SystemRoutingGroup) PublicRoutes() []Route {
{Method: "GET", Pattern: SystemCapacitiesPath, HandlerFunc: v2.ListSystemCapacities},
{Method: "GET", Pattern: SystemStatsPath, HandlerFunc: v2.ListSystemStats},
{Method: "GET", Pattern: SystemStatusPath, HandlerFunc: v2.ListSystemStatus},
{Method: "GET", Pattern: WorkerStatusPath, HandlerFunc: v2.ListWorkerStatus},
}
}
1 change: 0 additions & 1 deletion service/clients/v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ type V2 interface {
Jobs() apiV2.Jobs
Notifications() apiV2.Notifications
SMs() apiV2.SMs
Status() apiV2.Status
Teams() apiV2.Teams
Users() apiV2.Users
ResourceMigrations() apiV2.ResourceMigrations
Expand Down
11 changes: 4 additions & 7 deletions service/v2/api/api_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import (
resourceMigrationOpts "go-deploy/service/v2/resource_migrations/opts"
smK8sService "go-deploy/service/v2/sms/k8s_service"
smOpts "go-deploy/service/v2/sms/opts"
statusOpts "go-deploy/service/v2/status/opts"
zoneOpts "go-deploy/service/v2/system/opts"
systemOpts "go-deploy/service/v2/system/opts"
teamOpts "go-deploy/service/v2/teams/opts"
userOpts "go-deploy/service/v2/users/opts"
vmK8sService "go-deploy/service/v2/vms/k8s_service"
Expand Down Expand Up @@ -91,10 +90,6 @@ type SMs interface {
K8s() *smK8sService.Client
}

type Status interface {
ListWorkerStatus(opts ...statusOpts.ListWorkerStatusOpts) ([]model.WorkerStatus, error)
}

type Users interface {
Get(id string, opts ...userOpts.GetOpts) (*model.User, error)
GetByApiKey(apiKey string) (*model.User, error)
Expand Down Expand Up @@ -195,11 +190,13 @@ type System interface {
ListStats(n int) ([]body.TimestampedSystemStats, error)
ListStatus(n int) ([]body.TimestampedSystemStatus, error)

ListWorkerStatus(opts ...systemOpts.ListWorkerStatusOpts) ([]model.WorkerStatus, error)

RegisterNode(params *body.HostRegisterParams) error

ListHosts() ([]model.Host, error)

GetZone(name string) *configModels.Zone
ListZones(opts ...zoneOpts.ListOpts) ([]configModels.Zone, error)
ListZones(opts ...systemOpts.ListOpts) ([]configModels.Zone, error)
ZoneHasCapability(zoneName, capability string) bool
}
5 changes: 0 additions & 5 deletions service/v2/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"go-deploy/service/v2/notifications"
"go-deploy/service/v2/resource_migrations"
"go-deploy/service/v2/sms"
"go-deploy/service/v2/status"
"go-deploy/service/v2/system"
"go-deploy/service/v2/teams"
"go-deploy/service/v2/users"
Expand Down Expand Up @@ -70,10 +69,6 @@ func (c *Client) SMs() api.SMs {
return sms.New(c, c.cache)
}

func (c *Client) Status() api.Status {
return status.New(c, c.cache)
}

func (c *Client) System() api.System {
return system.New(c, c.cache)
}
Expand Down
30 changes: 0 additions & 30 deletions service/v2/status/api_client.go

This file was deleted.

5 changes: 0 additions & 5 deletions service/v2/status/opts/opts.go

This file was deleted.

4 changes: 4 additions & 0 deletions service/v2/system/opts/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ type GetOpts struct {
// ListOpts is used to pass options to the List method
type ListOpts struct {
}

// ListWorkerStatusOpts is used to pass options to the List method
type ListWorkerStatusOpts struct {
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package status
package system

import (
"go-deploy/models/model"
"go-deploy/pkg/db/resources/worker_status_repo"
"go-deploy/service/v2/status/opts"
"go-deploy/service/v2/system/opts"
"time"
)

Expand Down
6 changes: 6 additions & 0 deletions test/e2e/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,12 @@ func MustNotNil(t *testing.T, obj interface{}, msg string) {
}
}

func MustNotEmpty[T any](t *testing.T, slice []T, msg string) {
if len(slice) == 0 {
assert.FailNow(t, msg)
}
}

func IsUserError(code int) bool {
return code >= 400 && code < 500
}
7 changes: 3 additions & 4 deletions test/e2e/v2/sms/route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,17 @@ func TestList(t *testing.T) {
func TestCreate(t *testing.T) {
t.Parallel()

v2.ListDeployments(t, "?all=true")
v2.WithDeployment(t, body.DeploymentCreate{Name: e2e.GenName("sms-create")}, e2e.PowerUser)

// Make sure the storage manager has time to be created
time.Sleep(5 * time.Second)
time.Sleep(30 * time.Second)

storageManagers := v2.ListSMs(t, "?all=false")
assert.NotEmpty(t, storageManagers, "storage managers were empty")
e2e.MustNotEmpty(t, storageManagers, "storage managers were empty")

storageManager := storageManagers[0]
assert.NotEmpty(t, storageManager.ID, "storage manager id was empty")
assert.NotEmpty(t, storageManager.OwnerID, "storage manager owner id was empty")
assert.NotEmpty(t, storageManager.URL, "storage manager url was empty")

v2.WaitForSmRunning(t, storageManager.ID, func(storageManagerRead *body.SmRead) bool {
// Make sure it is accessible
Expand Down

0 comments on commit ee2eed2

Please sign in to comment.