Skip to content
This repository has been archived by the owner on Dec 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #52 from nre-learning/advanced-status
Browse files Browse the repository at this point in the history
Add more detail around the status of a livelesson's startup progress
  • Loading branch information
Mierdin committed Jan 16, 2019
2 parents bd499a7 + da8e77b commit 7d73e52
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 54 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -7,6 +7,7 @@
- Simplify and improve safety of in-memory state model [#42](https://github.com/nre-learning/syringe/pull/42)
- Introduce garbage collection whitelist functionality [#45](https://github.com/nre-learning/syringe/pull/45)
- Fixed bug with bridge naming and reachability timeout [#51](https://github.com/nre-learning/syringe/pull/51)
- Add more detail around the status of a livelesson's startup progress [#52](https://github.com/nre-learning/syringe/pull/52)

## 0.1.4 - January 08, 2019

Expand Down
14 changes: 12 additions & 2 deletions api/exp/definitions/livelesson.proto
Expand Up @@ -52,15 +52,24 @@ message SyringeState {

}

enum Status {
DONOTUSE = 0; // Protobuf doesn't encode the default value. Throwing this one away.
INITIAL_BOOT = 1;
CONFIGURATION = 2;
READY = 3;
}

// A provisioned lab without the scheduler details. The server will translate from an underlying type
// (i.e. KubeLab) into this, so only the abstract, relevant details are presented.
message LiveLesson {
string LessonUUID = 1;
int32 LessonId = 2;
repeated LiveEndpoint LiveEndpoints = 3;
map <string, LiveEndpoint> LiveEndpoints = 3;
int32 LessonStage = 4;
string LabGuide = 5;
bool Ready = 6;

Status LiveLessonStatus = 6;

google.protobuf.Timestamp createdTime = 7;
string LessonDiagram = 8;
string LessonVideo = 9;
Expand All @@ -87,6 +96,7 @@ message LiveEndpoint {

string IframePath = 5;

bool Reachable = 6;
}

message LessonParams {
Expand Down
23 changes: 18 additions & 5 deletions api/exp/definitions/livelesson.swagger.json
Expand Up @@ -143,6 +143,10 @@
},
"IframePath": {
"type": "string"
},
"Reachable": {
"type": "boolean",
"format": "boolean"
}
}
},
Expand All @@ -157,8 +161,8 @@
"format": "int32"
},
"LiveEndpoints": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/expLiveEndpoint"
}
},
Expand All @@ -169,9 +173,8 @@
"LabGuide": {
"type": "string"
},
"Ready": {
"type": "boolean",
"format": "boolean"
"LiveLessonStatus": {
"$ref": "#/definitions/expStatus"
},
"createdTime": {
"type": "string",
Expand Down Expand Up @@ -209,6 +212,16 @@
}
}
},
"expStatus": {
"type": "string",
"enum": [
"DONOTUSE",
"INITIAL_BOOT",
"CONFIGURATION",
"READY"
],
"default": "DONOTUSE"
},
"expSyringeState": {
"type": "object",
"properties": {
Expand Down
17 changes: 11 additions & 6 deletions api/exp/livelessons.go
Expand Up @@ -103,9 +103,14 @@ func (s *server) RequestLiveLesson(ctx context.Context, lp *pb.LessonParams) (*p

s.recordRequestTSDB(req)

// Pre-emptively populate livelessons map with non-ready livelesson.
// Pre-emptively populate livelessons map with initial status.
// This will be updated when the scheduler response comes back.
s.SetLiveLesson(lessonUuid, &pb.LiveLesson{Ready: false, LessonId: lp.LessonId, LessonUUID: lessonUuid, LessonStage: lp.LessonStage})
s.SetLiveLesson(lessonUuid, &pb.LiveLesson{
LiveLessonStatus: pb.Status_INITIAL_BOOT,
LessonId: lp.LessonId,
LessonUUID: lessonUuid,
LessonStage: lp.LessonStage,
})

return &pb.LessonUUID{Id: lessonUuid}, nil
}
Expand Down Expand Up @@ -139,10 +144,10 @@ func (s *server) GetLiveLesson(ctx context.Context, uuid *pb.LessonUUID) (*pb.Li
}

// Remove all blackbox entries
newEndpoints := []*pb.LiveEndpoint{}
for e := range ll.LiveEndpoints {
if ll.LiveEndpoints[e].Type != pb.LiveEndpoint_BLACKBOX {
newEndpoints = append(newEndpoints, ll.LiveEndpoints[e])
newEndpoints := map[string]*pb.LiveEndpoint{}
for name, e := range ll.LiveEndpoints {
if e.Type != pb.LiveEndpoint_BLACKBOX {
newEndpoints[name] = e
}
}
ll.LiveEndpoints = newEndpoints
Expand Down
3 changes: 1 addition & 2 deletions api/exp/server.go
Expand Up @@ -118,7 +118,6 @@ func StartAPI(ls *scheduler.LessonScheduler, grpcPort, httpPort int, buildInfo m
uuid := strings.TrimRight(result.GCLessons[i], "-ns")
apiServer.DeleteLiveLesson(uuid)
}

} else {
log.Error("FOO")
}
Expand Down Expand Up @@ -164,7 +163,7 @@ func (s *server) UpdateLiveLessonStage(uuid string, stage int32) {
defer s.liveLessonsMu.Unlock()

s.liveLessonState[uuid].LessonStage = stage
s.liveLessonState[uuid].Ready = false
s.liveLessonState[uuid].LiveLessonStatus = pb.Status_CONFIGURATION
}

func (s *server) DeleteLiveLesson(uuid string) {
Expand Down
23 changes: 18 additions & 5 deletions api/exp/swagger/swagger.pb.go
Expand Up @@ -393,6 +393,10 @@ Livelesson = `{
},
"IframePath": {
"type": "string"
},
"Reachable": {
"type": "boolean",
"format": "boolean"
}
}
},
Expand All @@ -407,8 +411,8 @@ Livelesson = `{
"format": "int32"
},
"LiveEndpoints": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/expLiveEndpoint"
}
},
Expand All @@ -419,9 +423,8 @@ Livelesson = `{
"LabGuide": {
"type": "string"
},
"Ready": {
"type": "boolean",
"format": "boolean"
"LiveLessonStatus": {
"$ref": "#/definitions/expStatus"
},
"createdTime": {
"type": "string",
Expand Down Expand Up @@ -459,6 +462,16 @@ Livelesson = `{
}
}
},
"expStatus": {
"type": "string",
"enum": [
"DONOTUSE",
"INITIAL_BOOT",
"CONFIGURATION",
"READY"
],
"default": "DONOTUSE"
},
"expSyringeState": {
"type": "object",
"properties": {
Expand Down

0 comments on commit 7d73e52

Please sign in to comment.