-
Notifications
You must be signed in to change notification settings - Fork 73
WINC-1438: Compress payload #3162
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
base: master
Are you sure you want to change the base?
Conversation
/approve cancel |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
// Creates a .tar.gz archive from file data | ||
func createTarGzFile(data []byte, fileName string, outWriter io.Writer) error { | ||
// Chain writers: File -> Gzip -> Tar | ||
gzipWriter := gzip.NewWriter(outWriter) |
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.
consider using func NewWriterLevel(w io.Writer, level int) (*Writer, error)
with BestCompression
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.
actually we can do "Level 1 (Fastest)" for testing and CI,
and "Level 9 (Best Compression)" for final release.
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 switched to gzip level 9 in the Containerfiles. There was unfortunately no difference.
I'll stick to using the default compression level within the go code, as that is the general recommendation:
build time=9, run time=default(6),
74b0d42
to
cd45edb
Compare
@sebsoto: This pull request references WINC-1438 which is a valid jira issue. In response to this: Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
cd45edb
to
f5871c8
Compare
@sebsoto: This pull request references WINC-1438 which is a valid jira issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
/lgtm |
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.
@sebsoto thanks for working on this, looks good overall. Left minor comments with suggestions.
# /payload/ | ||
#├── azure-cloud-node-manager.exe | ||
#├── cni/ | ||
#│ ├── flannel.exe |
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.
Is this file no longer present?
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.
Correct, not sure why this was here
# /payload/ | ||
#├── azure-cloud-node-manager.exe | ||
#├── cni/ | ||
#│ ├── flannel.exe |
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 is another instance in
#│ ├── flannel.exe |
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.
Removed the file in a separate PR
Containerfile
Outdated
sha256sum /build/windows-machine-config-operator/pkg/internal/hns.psm1 >> sha256sum && \ | ||
chmod -R 644 /payload && chmod -R +X /payload &&\ | ||
# Create directory for generated files with open permissions, this allows WMCO to write to this directory | ||
mkdir /payload/generated && \ |
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.
consider creating and set permission in one shot: mkdir -m 0777 /path/to/directory
Containerfile
Outdated
chmod -R 644 /payload && chmod -R +X /payload &&\ | ||
# Create directory for generated files with open permissions, this allows WMCO to write to this directory | ||
mkdir /payload/generated && \ | ||
chmod 0777 /payload/generated |
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.
for my own education:
why is Read + Write + Execute needed for group and others?
// input should be of the format generated by the sha256sum binary: `SHA256SUM filepath` | ||
func parseShaFile(fileData []byte) (map[string]string, error) { | ||
m := make(map[string]string) | ||
for _, line := range strings.Split(string(fileData), "\n") { |
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 recommend to trim spaces and check if string(fileData)
is empty first, is so return error
pkg/nodeconfig/payload/payload.go
Outdated
func parseShaFile(fileData []byte) (map[string]string, error) { | ||
m := make(map[string]string) | ||
for _, line := range strings.Split(string(fileData), "\n") { | ||
if len(line) == 0 { |
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.
trim spaces in line
before calculating the length
pkg/nodeconfig/payload/payload.go
Outdated
if len(line) == 0 { | ||
continue | ||
} | ||
columnSplit := strings.SplitN(line, " ", 2) |
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.
consider a constant for " "
, e.g. sha256sumColumnSeparator
} | ||
fileName := filepath.Base(columnSplit[1]) | ||
if _, present := m[fileName]; present { | ||
return nil, fmt.Errorf("duplicate sha256sum entry for %s", fileName) |
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.
Consider logging the checksum as well, they may be different.
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'm having trouble thinking of a case where this would help us with when debugging.
if _, present := m[fileName]; present { | ||
return nil, fmt.Errorf("duplicate sha256sum entry for %s", fileName) | ||
} | ||
m[fileName] = columnSplit[0] |
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 recommend to check columnSplit[0]
is not empty
assert.Equal(t, string(expectedOut), actual) | ||
} | ||
|
||
func TestParseShaFile(t *testing.T) { |
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.
consider including other negative test cases, missing filename, blank lines, etc.
@sebsoto, why not get all the directories and files into a single compressed file? So that there is only one SSH connection to transfer the payload and one checksum validation? |
@jrvaldes
|
Makes sense, thanks for the details. |
Following this approach, I recommend grouping related and/or dependent files into a single compressed file to reduce the number of files to transfer. For example:
instead of separete gz files for each individual file. WDYT? |
@jrvaldes As we share the same SSH connection for all transfers, the downside of having many small files is that each transfer will cause an exec call to |
true, thanks for the explanation. |
Compresses files at build time with gzip. Reduces size of payload from 550MB to 207MB
Transfers payload files as .tar.gz, and decompresses them on the Windows VM. Reduces the amount of bandwidth required to configure a Windows Node, and reduces the duplicate transfer work caused by network faults triggering a transfer failure.
f5871c8
to
07d266c
Compare
New changes are detected. LGTM label has been removed. |
@sebsoto: The following tests failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Shrinks the WMCO image from 820MB to 459MB.
No significant change in CI runtime.