Skip to content
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

feat: Add UI for awaiting agent connections #578

Merged
merged 14 commits into from
Mar 29, 2022
Merged

feat: Add UI for awaiting agent connections #578

merged 14 commits into from
Mar 29, 2022

Conversation

kylecarbs
Copy link
Member

No description provided.

This adds a stage property to logs, and refactors the job logs
cliui.

It also adds tests to the cliui for build logs!
@kylecarbs kylecarbs self-assigned this Mar 27, 2022
@codecov
Copy link

codecov bot commented Mar 27, 2022

Codecov Report

Merging #578 (342b03d) into main (620c889) will increase coverage by 0.54%.
The diff coverage is 72.64%.

@@            Coverage Diff             @@
##             main     #578      +/-   ##
==========================================
+ Coverage   63.67%   64.22%   +0.54%     
==========================================
  Files         197      198       +1     
  Lines       11543    11622      +79     
  Branches       85       85              
==========================================
+ Hits         7350     7464     +114     
+ Misses       3413     3362      -51     
- Partials      780      796      +16     
Flag Coverage Δ
unittest-go- 63.40% <71.22%> (+0.44%) ⬆️
unittest-go-macos-latest 59.12% <51.41%> (+0.65%) ⬆️
unittest-go-ubuntu-latest 62.09% <72.64%> (+0.53%) ⬆️
unittest-go-windows-2022 58.32% <52.83%> (+0.55%) ⬆️
unittest-js 63.32% <ø> (ø)
Impacted Files Coverage Δ
cli/start.go 66.15% <ø> (ø)
coderd/coderd.go 96.47% <ø> (ø)
cli/cliui/select.go 61.22% <59.57%> (+15.51%) ⬆️
provisioner/terraform/provision.go 68.82% <62.90%> (-3.47%) ⬇️
cli/ssh.go 43.33% <77.27%> (+38.20%) ⬆️
coderd/provisionerdaemons.go 59.52% <80.00%> (-2.89%) ⬇️
cli/cliui/agent.go 82.14% <82.14%> (ø)
agent/conn.go 68.96% <100.00%> (+3.58%) ⬆️
cli/root.go 76.84% <100.00%> (ø)
cli/workspaceagent.go 78.16% <100.00%> (ø)
... and 24 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 620c889...342b03d. Read the comment docs.

This adds a stage property to logs, and refactors the job logs
cliui.

It also adds tests to the cliui for build logs!
@misskniss
Copy link

@kylecarbs can this be closed or does it still need to be done?

@kylecarbs
Copy link
Member Author

Needs to be done or else no SSH!

Base automatically changed from nicerlogs to main March 28, 2022 18:43
@kylecarbs kylecarbs changed the title feat: Add config-ssh and tests for resiliency feat: Add UI for awaiting agent connections Mar 28, 2022
@kylecarbs kylecarbs requested review from coadler and Emyrk March 28, 2022 20:19
@@ -258,6 +258,7 @@ func AwaitWorkspaceAgents(t *testing.T, client *codersdk.Client, build uuid.UUID
if resource.Agent == nil {
continue
}
// fmt.Printf("resources: %+v\n", resource.Agent)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a debug line

sensitive = true
}
variable "service_account" {
description = <<EOT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO I mostly see these with <<EOF rather than EOT

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. Zero-clue why I did EOT

Copy link
Member

@Emyrk Emyrk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nits and comments.

case <-timer.C:
}
message := "Don't panic, your workspace is booting up!"
if resource.Agent.Status == codersdk.WorkspaceAgentDisconnected {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fail --race because there is another for loop in the main thread touching this.

We should use atomic or just a mutex to protect that

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I didn't even have a test for this, and now I shall add one.

"github.com/spf13/cobra"
)

func init() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know this survey stuff. Not looking to understand this atm lol

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the libraries are questionable in their own rights tbh

@@ -24,6 +25,12 @@ func workspaceSSH() *cobra.Command {
if err != nil {
return err
}
if workspace.LatestBuild.Job.CompletedAt == nil {
err = cliui.WorkspaceBuild(cmd, client, workspace.LatestBuild.ID, workspace.CreatedAt)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we log some message that their workspace was offline and is being restarted? I feel like this being a silent side effect could be confusing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I need to revamp the SSH command.

}

conn, err := client.DialWorkspaceAgent(cmd.Context(), resource.ID, nil, nil)
conn, err := client.DialWorkspaceAgent(cmd.Context(), resource.ID, []webrtc.ICEServer{{
URLs: []string{"stun:stun.l.google.com:19302"},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For customers with more restrictive firewalls, can they use TURN?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't be hardcoded for long. Just a temporary hack!

WarnInterval time.Duration
}

func Agent(cmd *cobra.Command, opts AgentOptions) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we comment what this function is doing? With lack of returns except error, it's a bit unclear.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, certainly should.

cmd/cliui/main.go Show resolved Hide resolved
Comment on lines +403 to +405
return &proto.UpdateJobResponse{
Canceled: job.CanceledAt.Valid,
}, nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😨 this is a big function. I see it's mostly boiler plate fields, but still

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's ~140 lines, not that bad!

@@ -209,7 +208,7 @@ func (t *terraform) Provision(stream proto.DRPCProvisioner_ProvisionStream) erro
case <-stream.Context().Done():
return
case <-shutdown.Done():
_ = cmd.Process.Signal(os.Kill)
_ = cmd.Process.Signal(os.Interrupt)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice of you to be less aggressive 😄. I'm sure that PID will appreciate it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hahahahah that it will

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants