Skip to content

Commit

Permalink
Respect user defined/default sizes on upgrade
Browse files Browse the repository at this point in the history
We were ignoring if the user set any values in there and just
overwriting it with our calculated size

Signed-off-by: Itxaka <[email protected]>
  • Loading branch information
Itxaka committed Nov 5, 2024
1 parent 00d0447 commit f3e44c9
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions pkg/config/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,14 @@ func NewUpgradeSpec(cfg *Config) (*v1.UpgradeSpec, error) {
func setUpgradeSourceSize(cfg *Config, spec *v1.UpgradeSpec) error {
var size int64
var err error
var originalSize int64

// Store the default given size in the spec. This includes the user specified values which have already been marshalled in the spec
if spec.RecoveryUpgrade() {
originalSize = int64(spec.Recovery.Size)

Check failure

Code scanning / gosec

integer overflow conversion uint -> int64 Error

integer overflow conversion uint -> int64
} else {
originalSize = int64(spec.Active.Size)

Check failure

Code scanning / gosec

integer overflow conversion uint -> int64 Error

integer overflow conversion uint -> int64
}

var targetSpec *v1.Image
if spec.RecoveryUpgrade() {
Expand All @@ -420,8 +428,15 @@ func setUpgradeSourceSize(cfg *Config, spec *v1.UpgradeSpec) error {
return err
}

cfg.Logger.Infof("Setting image size to %dMb", size)
targetSpec.Size = uint(size)
if size < originalSize {
cfg.Logger.Debugf("Calculated size (%dMb) is less than specified/default size (%dMb)", size, originalSize)
targetSpec.Size = uint(originalSize)

Check failure

Code scanning / gosec

integer overflow conversion uint -> int64 Error

integer overflow conversion int64 -> uint
} else {
cfg.Logger.Debugf("Calculated size (%dMb) is higher than specified/default size (%dMb)", size, originalSize)
targetSpec.Size = uint(size)

Check failure

Code scanning / gosec

integer overflow conversion uint -> int64 Error

integer overflow conversion int64 -> uint
}

cfg.Logger.Infof("Setting image size to %dMb", targetSpec.Size)

return nil
}
Expand Down

0 comments on commit f3e44c9

Please sign in to comment.