Skip to content

feat: explicit optional compression in dropgz #3648

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rbtr
Copy link
Contributor

@rbtr rbtr commented May 9, 2025

Previously, dropgz has expected and required that embedded blobs be gzip compressed.
This change makes decompressing the stream optional and defaults to no decompression, by adding a --compression flag and simply streaming the embed out if compression is unset.
dropgz deploy now defaults to assuming uncompressed embeds. Only gzip compression is supported and may be set.

@Copilot Copilot AI review requested due to automatic review settings May 9, 2025 20:59
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces an optional decompression mechanism for embedded blobs in dropgz by adding a new compression flag. Key changes include:

  • Introducing a new Compression type with supported constants (None and Gzip) in payload.go.
  • Updating the Extract, deploy, and Deploy functions to accept and propagate the compression parameter.
  • Adding a new CLI flag for compression in the payload command and removing outdated local-run instructions from the README.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
dropgz/pkg/embed/payload.go Added Compression type and integrated conditional decompression.
dropgz/cmd/payload.go Updated command definitions to pass the compression parameter.
dropgz/README.md Removed outdated instructions that enforced gzip compression.
Comments suppressed due to low confidence (1)

dropgz/README.md:1

  • [nitpick] The removal of local run instructions may leave users without guidance on how to use the new '--compression' flag; please update or provide alternative documentation reflecting the new behavior.
-### Running the dropgz locally

@rbtr rbtr self-assigned this May 9, 2025
@rbtr rbtr added dropgz dropgz release/latest Change affects latest release train labels May 9, 2025
@rbtr rbtr requested a review from QxBytes May 9, 2025 21:04
@rbtr
Copy link
Contributor Author

rbtr commented May 13, 2025

/azp run Azure Container Networking PR

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@rbtr rbtr enabled auto-merge May 13, 2025 16:06
Copy link
Contributor

@QxBytes QxBytes left a comment

Choose a reason for hiding this comment

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

If dropgz's default behavior now assumes uncompressed files, and previously we placed compressed files into the dropgz image (like inside azure-cni), do we also need to update these other dockerfiles (to place uncompressed files), or make it so that dropgz runs with gzip compression (your new flag) in pipelines etc.? Or does this compression on pertain to how the files are transferred out?

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be beneficial to add a new README with updated instructions for running dropgz?

@rbtr
Copy link
Contributor Author

rbtr commented May 13, 2025

do we also need to update these other dockerfiles (to place uncompressed files)

Yes, but dropgz is a separate go mod and is used as a library in those dockerfiles. It must be released before they can be updated, and if we make no change to them they just keep using the older version with compression.

@QxBytes
Copy link
Contributor

QxBytes commented May 16, 2025

do we also need to update these other dockerfiles (to place uncompressed files)

Yes, but dropgz is a separate go mod and is used as a library in those dockerfiles. It must be released before they can be updated, and if we make no change to them they just keep using the older version with compression.

So let's say this PR gets merged and then we build a new cni/cns image right after-- will this image be broken because we place compressed images inside when we build dropgz, and then try to extract with the default compression as none?

@rbtr
Copy link
Contributor Author

rbtr commented May 17, 2025

nothing will break or change until we release a dropgz 0.0.13, and update the CNS/CNI dockerfiles to use it

@rbtr rbtr requested a review from Copilot May 19, 2025 16:45
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Make decompression of embedded blobs optional by introducing a --compression flag and defaulting to no decompression.

  • Define a Compression enum (None, Gzip) and update Extract, deploy, and Deploy to accept it.
  • Add a --compression CLI flag in payload.go and pass it through to the embed API.
  • Remove outdated local usage instructions from the README (needs replacement).

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
dropgz/pkg/embed/payload.go Add Compression type/constants and update Extract/deploy to use it
dropgz/cmd/payload.go Introduce --compression flag, propagate to extract/deploy
dropgz/README.md Remove old local usage steps (no replacement for new flag usage)
Comments suppressed due to low confidence (2)

dropgz/cmd/payload.go:10

  • The code references embed.Compression and embed.Deploy but does not import the embed package. Add "dropgz/pkg/embed" to the import block.
import (

dropgz/README.md:1

  • The README content was removed but no new instructions were added for the --compression flag. Add updated usage examples covering compression modes.
-### Running the dropgz locally

if err != nil {
return nil, errors.Wrap(err, "failed to build reader")
var rc io.ReadCloser = f
switch compression {
Copy link
Preview

Copilot AI May 19, 2025

Choose a reason for hiding this comment

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

The switch ignores unsupported compression values and silently defaults to no decompression. Consider adding a default case that returns an error for unknown Compression values.

Copilot uses AI. Check for mistakes.

@@ -10,6 +10,12 @@ import (
"go.uber.org/zap"
)

var (
compression embed.Compression
skipVerify bool
Copy link
Preview

Copilot AI May 19, 2025

Choose a reason for hiding this comment

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

The skipVerify flag is declared and bound but never used in the deploy command. Remove it or implement its logic to skip checksum validation.

Copilot uses AI. Check for mistakes.

@@ -120,6 +121,7 @@ func init() {
root.AddCommand(verify)

deploy.ValidArgs, _ = embed.Contents() // setting this after the command is initialized is required
deploy.Flags().StringVarP((*string)(&compression), "compression", "c", "none", "compression type (default none)")
Copy link
Preview

Copilot AI May 19, 2025

Choose a reason for hiding this comment

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

[nitpick] Casting an alias type pointer to *string is error-prone. Consider implementing flag.Value on Compression and using Flags().VarP() for stronger type safety.

Suggested change
deploy.Flags().StringVarP((*string)(&compression), "compression", "c", "none", "compression type (default none)")
deploy.Flags().VarP(&compression, "compression", "c", "compression type (default none)")

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dropgz dropgz release/latest Change affects latest release train
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants