-
Notifications
You must be signed in to change notification settings - Fork 12
NOISSUE : Enhance Event Status #235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
agent/service.go
Outdated
svc.sm.StateFunctions[resultsReady] = svc.publishEvent("in-progress", json.RawMessage{}) | ||
svc.sm.StateFunctions[complete] = svc.publishEvent("in-progress", json.RawMessage{}) | ||
svc.sm.StateFunctions[results] = svc.publishEvent("ready", json.RawMessage{}) | ||
svc.sm.StateFunctions[complete] = svc.publishEvent("complete", json.RawMessage{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use constants here and any other appropriate place.
agent/state.go
Outdated
receivingData | ||
running | ||
resultsReady | ||
results |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use a verb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's results so that the full event with status would be: results
ready
. Rather than resultsReady
ready
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
state results is not really self explanatory here, a better term is required
agent/service.go
Outdated
svc.sm.StateFunctions[idle] = svc.publishEvent("idle", json.RawMessage{}) | ||
svc.sm.StateFunctions[receivingManifest] = svc.publishEvent(progress, json.RawMessage{}) | ||
svc.sm.StateFunctions[receivingAlgorithm] = svc.publishEvent(progress, json.RawMessage{}) | ||
svc.sm.StateFunctions[receivingData] = svc.publishEvent(progress, json.RawMessage{}) | ||
svc.sm.StateFunctions[results] = svc.publishEvent("ready", json.RawMessage{}) | ||
svc.sm.StateFunctions[complete] = svc.publishEvent("complete", json.RawMessage{}) | ||
svc.sm.StateFunctions[running] = svc.runComputation | ||
svc.sm.StateFunctions[failed] = svc.publishEvent("failed", json.RawMessage{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make status a typed constant for consistency
17b9d30
to
148d1f8
Compare
agent/state.go
Outdated
ReceivingAlgorithm | ||
ReceivingData | ||
Running | ||
ResultFetch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ConsumingResults is better here, with status started, in progress and complete
type Status uint8 | ||
|
||
const ( | ||
IdleState Status = iota | ||
InProgress | ||
Ready | ||
Completed | ||
Terminated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
manager also has status and will have a general pattern, started, in progress, complete and failed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am using these statuses for manager.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
events are also published from manager on other files like agent events, and vm package as well as logging
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see also agent logging and algorithm package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All events use the states and statuses in manger, except for this one:
https://github.com/ultravioletrs/cocos/blob/main/agent/algorithm/logging.go#L68-L70
Since it is unique.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
define all of them in a list including that one
manager/service.go
Outdated
ms.qemuCfg.VSockConfig.Vnc++ | ||
|
||
ms.publishEvent("vm-provision", c.Id, "complete", json.RawMessage{}) | ||
ms.publishEvent("vm-provision", c.Id, agent.Completed.String(), json.RawMessage{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also set a typed constant for manager states, i.e vm-provision, vm-running, ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only have two states for manager states, vm provision and stop computation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are additional states, see vm package and qemu package
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
865f906
to
b23f9c7
Compare
manager/manager_states.go
Outdated
const ( | ||
VmProvision ManagerState = iota | ||
StopComputation | ||
Starting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
state and status are different
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
agent/algorithm/logging.go
Outdated
} | ||
|
||
if err := s.EventSvc.SendEvent("algorithm-run", "error", json.RawMessage{}); err != nil { | ||
if err := s.EventSvc.SendEvent(manager.AlgorithmRun.String(), manager.Error.String(), json.RawMessage{}); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
algo run should be in agent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we move this to agent package, importing it here will result in an import cycle hence that will return us to using a string literal.
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
agent/algorithm/logging.go
Outdated
} | ||
|
||
if err := s.EventSvc.SendEvent("algorithm-run", "error", json.RawMessage{}); err != nil { | ||
if err := s.EventSvc.SendEvent("AlgorithmRun", manager.Error.String(), json.RawMessage{}); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be a constant, also avoid imports from manager on agent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is pkg/manager
and not manager
package. Also, what do you mean by should be a string
?
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
What type of PR is this?
This is an enhancement that improves the status of events sent from agent and manager.
What does this do?
This enhances the events sent from agent and manager to make them more user friendly.
Which issue(s) does this PR fix/relate to?
Have you included tests for your changes?
Not needed.
Did you document any new/modified feature?
No
Notes
To be merged along with: https://github.com/ultravioletrs/prism/pull/478