Skip to content

Conversation

sebsoto
Copy link
Contributor

@sebsoto sebsoto commented Aug 13, 2025

Shrinks the WMCO image from 820MB to 459MB.
No significant change in CI runtime.

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 13, 2025
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 13, 2025
@sebsoto
Copy link
Contributor Author

sebsoto commented Aug 13, 2025

/approve cancel

Copy link
Contributor

openshift-ci bot commented Aug 13, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign mansikulkarni96 for approval. For more information see the Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 13, 2025
// 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)
Copy link
Contributor

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

https://pkg.go.dev/compress/gzip#BestCompression

Copy link
Contributor

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.

Copy link
Contributor Author

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),

@sebsoto sebsoto force-pushed the compressPayload branch 2 times, most recently from 74b0d42 to cd45edb Compare August 14, 2025 10:57
@sebsoto sebsoto changed the title [WIP] Compress payload WINC-1438: Compress payload Aug 19, 2025
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Aug 19, 2025
@openshift-ci-robot
Copy link

openshift-ci-robot commented Aug 19, 2025

@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.

@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 19, 2025
@openshift-ci-robot
Copy link

openshift-ci-robot commented Aug 19, 2025

@sebsoto: This pull request references WINC-1438 which is a valid jira issue.

In response to this:

Shrinks the WMCO image from 820MB to 459MB.
No significant change in CI runtime.

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.

@wgahnagl
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 19, 2025
Copy link
Contributor

@jrvaldes jrvaldes left a 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
Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor

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

Copy link
Contributor Author

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 && \
Copy link
Contributor

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
Copy link
Contributor

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") {
Copy link
Contributor

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

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 {
Copy link
Contributor

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

if len(line) == 0 {
continue
}
columnSplit := strings.SplitN(line, " ", 2)
Copy link
Contributor

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)
Copy link
Contributor

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.

Copy link
Contributor Author

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]
Copy link
Contributor

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) {
Copy link
Contributor

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.

@jrvaldes
Copy link
Contributor

jrvaldes commented Aug 19, 2025

@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?

@sebsoto
Copy link
Contributor Author

sebsoto commented Aug 20, 2025

@jrvaldes

@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
Doing one big transfer has two major downsides:

  1. If any file in the payload changes, the entire payload needs to be transferred again. This would mainly affect upgrades.
  2. If there is a network interruption during the transfer process, the whole transfer begins again. By breaking up the payload into smaller chunks, the files that have been completely transferred already can be skipped, removing the duplicate work.

@jrvaldes
Copy link
Contributor

@jrvaldes

@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 Doing one big transfer has two major downsides:

  1. If any file in the payload changes, the entire payload needs to be transferred again. This would mainly affect upgrades.
  2. If there is a network interruption during the transfer process, the whole transfer begins again. By breaking up the payload into smaller chunks, the files that have been completely transferred already can be skipped, removing the duplicate work.

Makes sense, thanks for the details.

@jrvaldes
Copy link
Contributor

If there is a network interruption during the transfer process, the whole transfer begins again. By breaking up the payload into smaller chunks, the files that have been completely transferred already can be skipped, removing the duplicate work

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:
windows_exporter.tar.gz contains:

  • windows_exporter.exe, and
  • windows-exporter-webconfig.yaml

instead of separete gz files for each individual file.

WDYT?

@sebsoto
Copy link
Contributor Author

sebsoto commented Aug 20, 2025

@jrvaldes
That feels a bit like premature optimization.
I dont think the gains we would get by grouping the files would outweigh the additional complexity to map multiple files with different decompressed SHA256's to an archive.

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 tar to unzip. This will only happen if the file needs to be updated. That will probably result in 10s of milliseconds added, I think its worth it to keep things simple.

@jrvaldes
Copy link
Contributor

@jrvaldes That feels a bit like premature optimization. I dont think the gains we would get by grouping the files would outweigh the additional complexity to map multiple files with different decompressed SHA256's to an archive.

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 tar to unzip. This will only happen if the file needs to be updated. That will probably result in 10s of milliseconds added, I think its worth it to keep things simple.

true, thanks for the explanation.

@sebsoto sebsoto changed the title WINC-1438: Compress payload [WIP] WINC-1438: Compress payload Aug 26, 2025
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 26, 2025
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.
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Oct 9, 2025
Copy link
Contributor

openshift-ci bot commented Oct 9, 2025

New changes are detected. LGTM label has been removed.

@sebsoto sebsoto changed the title [WIP] WINC-1438: Compress payload WINC-1438: Compress payload Oct 9, 2025
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 9, 2025
Copy link
Contributor

openshift-ci bot commented Oct 9, 2025

@sebsoto: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/nutanix-e2e-operator 07d266c link true /test nutanix-e2e-operator
ci/prow/platform-none-vsphere-e2e-operator 07d266c link true /test platform-none-vsphere-e2e-operator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants