Skip to content

Update to docker-exec-websocket-* 3.0.0#5154

Merged
jwhitlock merged 1 commit intotaskcluster:mainfrom
jwhitlock:docker-exec-websocket
Feb 8, 2022
Merged

Update to docker-exec-websocket-* 3.0.0#5154
jwhitlock merged 1 commit intotaskcluster:mainfrom
jwhitlock:docker-exec-websocket

Conversation

@jwhitlock
Copy link
Contributor

Update docker-exec-websocket-client and docker-exec-websocket-server. These should work under Node v14, and are required for Node v16. They fix an issue when the docker exec command is reading and writing data
to the container.

This is part of PR #5095. The tests are failing under Node 16.13.2, and I'm curious if they also fail under the current Node 14.17.5.

@jwhitlock jwhitlock requested a review from a team as a code owner February 8, 2022 17:09
@jwhitlock jwhitlock requested review from lotas and petemoore and removed request for a team February 8, 2022 17:09
@jwhitlock jwhitlock marked this pull request as draft February 8, 2022 17:21
@jwhitlock jwhitlock force-pushed the docker-exec-websocket branch from 2884d1e to 6bc53fe Compare February 8, 2022 19:30
Update docker-exec-websocket-client and docker-exec-websocket-server.
These should work under Node v14, and are required for Node v16. They
fix an issue when the `docker exec` command is reading and writing data
to the container.

The test was using Buffer.compare(), which returns 0 when the buffers
are equal, 1 when the first argument sorts first, and -1 when the second
argument sorts first. This means the test was confirming the two buffers
were _not_ equal, since 2015 or so.
@jwhitlock jwhitlock force-pushed the docker-exec-websocket branch from 6bc53fe to 2a7d877 Compare February 8, 2022 20:04
@jwhitlock jwhitlock marked this pull request as ready for review February 8, 2022 20:04
@jwhitlock
Copy link
Contributor Author

The test was:

assert(data.compare(buf), 'buffer mismatch');

.compare() is similar to compare from the C library, and returns 0 if equal, -1 if the left side should be sorted first, and 1 if the right side should be sorted first. I believe the intent is to check that buf (a megabyte of random data) is equal to data (concatenated buffer of the output of piping that random data to cat), so this test was confirming that the feature was not working.

The code was changed to use .compare() in 2015, to add something call "noVNC" support: taskcluster/docker-worker#185. Previously, it checked the input was the same as the output, byte by byte, so it is very possible this change broke the feature. This might be related to VNC not working, which was dropped in #4121.

I've switched to use .equals(), which does what you'd expect.

@jwhitlock
Copy link
Contributor Author

I've been staring at that test code for at least two weeks, and didn't notice compare until I added some debug lines and saw everything else was equal. Node in 2015 was a different beast, .compare and .equals() weren't added until v0.11.13.

I looked for other uses of .compare in the JS code, and just found this one, which correctly asserts the return is zero:

assert.equal(data.compare(Buffer.from([0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, //header
0x74, 0x65, 0x73, 0x74, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x0a])), 0); //testString\n

Still, .equals would be less awkward...

@jwhitlock jwhitlock requested a review from matt-boris February 8, 2022 20:30
@jwhitlock jwhitlock merged commit ee0212c into taskcluster:main Feb 8, 2022
@jwhitlock jwhitlock deleted the docker-exec-websocket branch February 8, 2022 22:18
@djmitche
Copy link
Collaborator

djmitche commented Feb 8, 2022

so this test was confirming that the feature was not working

Aren't surprises fun?

@petemoore
Copy link
Member

@jwhitlock If I'm reading correctly, this means, we might be able to bring the vnc code alive again for interactive graphical sessions? This would be brilliant, this was a killer feature, and it would be awesome to have it back working again.

Copy link
Contributor

@lotas lotas left a comment

Choose a reason for hiding this comment

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

Nice!

@jwhitlock
Copy link
Contributor Author

If I'm reading correctly, this means, we might be able to bring the vnc code alive again for interactive graphical sessions? This would be brilliant, this was a killer feature, and it would be awesome to have it back working again.

Maybe! The lack of two-way communication seems like it could have busted VNC, but I'm not familiar with the feature at all. It is possible it worked with a more traditional route like exposed ports.

@djmitche
Copy link
Collaborator

djmitche commented Feb 9, 2022

I doubt it's worth the effort to get something that complex working for docker-worker :)

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.

5 participants