-
Notifications
You must be signed in to change notification settings - Fork 23
[OCTRL-1018] Once NewEnvironmentAsync returns, the env should exist #710
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -309,13 +309,13 @@ func (m *RpcServer) doNewEnvironmentAsync(cxt context.Context, userVars map[stri | |
| // we store the last known request user in the environment | ||
| lastRequestUserJ, _ := json.Marshal(requestUser) | ||
| userVars["last_request_user"] = string(lastRequestUserJ[:]) | ||
| id, err = m.state.environments.CreateEnvironment(workflowTemplate, userVars, public, id, autoTransition) | ||
| err = m.state.environments.RunEnvironment(workflowTemplate, id, autoTransition) | ||
| if err != nil { | ||
| the.EventWriterWithTopic(topic.Environment).WriteEvent(&evpb.Ev_EnvironmentEvent{ | ||
| EnvironmentId: id.String(), | ||
| State: "ERROR", | ||
| Error: err.Error(), | ||
| Message: "cannot create new environment", // GUI listens for this concrete string | ||
| Message: "cannot run new environment", // GUI listens for this concrete string | ||
| LastRequestUser: requestUser, | ||
| WorkflowTemplateInfo: &evpb.WorkflowTemplateInfo{ | ||
| Public: public, | ||
|
|
@@ -374,7 +374,26 @@ func (m *RpcServer) NewEnvironmentAsync(cxt context.Context, request *pb.NewEnvi | |
| } | ||
| defer setCurrentUnixMilli(&reply.Timestamp) | ||
|
|
||
| go m.doNewEnvironmentAsync(cxt, userVars, request.GetRequestUser(), request.GetWorkflowTemplate(), request.GetPublic(), request.GetAutoTransition(), id) | ||
| public := request.GetPublic() | ||
| workflowTemplate := request.GetWorkflowTemplate() | ||
| requestUser := request.GetRequestUser() | ||
|
|
||
| id, err = m.state.environments.CreateEnvironment(request.GetWorkflowTemplate(), userVars, request.GetPublic(), id) | ||
| if err != nil { | ||
| the.EventWriterWithTopic(topic.Environment).WriteEvent(&evpb.Ev_EnvironmentEvent{ | ||
| EnvironmentId: id.String(), | ||
| State: "ERROR", | ||
| Error: err.Error(), | ||
| Message: "cannot create new environment", // GUI listens for this concrete string | ||
| LastRequestUser: requestUser, | ||
| WorkflowTemplateInfo: &evpb.WorkflowTemplateInfo{ | ||
| Public: public, | ||
| Path: workflowTemplate, | ||
| }, | ||
| }) | ||
| return | ||
| } | ||
| go m.doNewEnvironmentAsync(cxt, userVars, requestUser, workflowTemplate, public, request.GetAutoTransition(), id) | ||
|
|
||
| return | ||
| } | ||
|
|
@@ -421,7 +440,7 @@ func (m *RpcServer) NewEnvironment(cxt context.Context, request *pb.NewEnvironme | |
|
|
||
| // Create new Environment instance with some roles, we get back a UUID | ||
| id := uid.New() | ||
| id, err = m.state.environments.CreateEnvironment(request.GetWorkflowTemplate(), inputUserVars, request.GetPublic(), id, request.GetAutoTransition()) | ||
| id, err = m.state.environments.CreateEnvironment(request.GetWorkflowTemplate(), inputUserVars, request.GetPublic(), id) | ||
| if err != nil { | ||
| st := status.Newf(codes.Internal, "cannot create new environment: %s", utils.TruncateString(err.Error(), MAX_ERROR_LENGTH)) | ||
| ei := &pb.EnvironmentInfo{ | ||
|
|
@@ -436,6 +455,20 @@ func (m *RpcServer) NewEnvironment(cxt context.Context, request *pb.NewEnvironme | |
| return | ||
| } | ||
|
|
||
| err = m.state.environments.RunEnvironment(request.GetWorkflowTemplate(), id, request.GetAutoTransition()) | ||
| if err != nil { | ||
| st := status.Newf(codes.Internal, "cannot run new environment: %s", utils.TruncateString(err.Error(), MAX_ERROR_LENGTH)) | ||
| ei := &pb.EnvironmentInfo{ | ||
| Id: id.String(), | ||
| CreatedWhen: time.Now().UnixMilli(), | ||
| State: "ERROR", // not really, but close | ||
| NumberOfFlps: 0, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would it be difficult to have a correct value for the
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no idea, I didn't change anything, I just split the code. |
||
| } | ||
| st, _ = st.WithDetails(ei) | ||
| err = st.Err() | ||
|
|
||
| return | ||
| } | ||
| newEnv, err := m.state.environments.Environment(id) | ||
| if err != nil { | ||
| st := status.Newf(codes.Internal, "cannot get newly created environment: %s", utils.TruncateString(err.Error(), MAX_ERROR_LENGTH)) | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
One has to recognize that this will move environment creation into the synchronous part, which is a change in the behaviour. I imagine that the creation of an environment with all FLPs and no cached workflow templates may take 1-2 minutes. Please make sure that this is OK with George.
Uh oh!
There was an error while loading. Please reload this page.
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 know, but this is the only way how to achieve George's desired behavior without changing order of operations and other code changes.
And it is also the reason why I gave binary with these changes to STG for him to play with so he can see how it will behave.
I also don't want to merge this before he okays this