Skip to content
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

Fix autocalculating size image for upgrade action #467

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions pkg/config/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,28 +276,49 @@ func NewUpgradeSpec(cfg *Config) (*v1.UpgradeSpec, error) {
recMnt = constants.TransitionDir
}

upgradeRecoverySystemUri, err := cfg.Query("upgrade.\"recovery-system\".uri")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm trying to fix the tests currently. I think this should be install.recovery-system.uri but I'm not sure yet. On it.

upgradeRecoverySystemUri = strings.TrimRight(upgradeRecoverySystemUri, "\n")
if err != nil {
return nil, fmt.Errorf("failed to found recovery upgrade source: %w", err)
}

recoverySrc, err := v1.NewSrcFromURI(upgradeRecoverySystemUri)
if err != nil {
return nil, fmt.Errorf("failed to parse recovery upgrade source uri: %w", err)
}
recovery = v1.Image{
File: filepath.Join(ep.Recovery.MountPoint, "cOS", constants.TransitionImgFile),
Size: constants.ImgSize,
Label: recLabel,
FS: recFs,
MountPoint: recMnt,
Source: v1.NewEmptySrc(),
Source: recoverySrc,
}
}

if ep.State != nil {
if ep.State.MountPoint == "" {
ep.State.MountPoint = constants.StateDir
}
upgradeSystemUri, err := cfg.Query("upgrade.system.uri")
upgradeSystemUri = strings.TrimRight(upgradeSystemUri, "\n")

if err != nil {
return nil, fmt.Errorf("failed to found upgrade source: %w", err)
}

src, err := v1.NewSrcFromURI(upgradeSystemUri)
if err != nil {
return nil, fmt.Errorf("failed to parse upgrade source uri: %w", err)
}

active = v1.Image{
File: filepath.Join(ep.State.MountPoint, "cOS", constants.TransitionImgFile),
Size: constants.ImgSize,
Label: constants.ActiveLabel,
FS: constants.LinuxImgFs,
MountPoint: constants.TransitionDir,
Source: v1.NewEmptySrc(),
Source: src,
}

passive = v1.Image{
Expand Down Expand Up @@ -330,8 +351,10 @@ func NewUpgradeSpec(cfg *Config) (*v1.UpgradeSpec, error) {
Partitions: ep,
State: installState,
}

setUpgradeSourceSize(cfg, spec)
err = setUpgradeSourceSize(cfg, spec)
if err != nil {
return nil, fmt.Errorf("failed calculate transition image size: %w", err)
}

err = unmarshallFullSpec(cfg, "upgrade", spec)
if err != nil {
Expand All @@ -355,7 +378,6 @@ func setUpgradeSourceSize(cfg *Config, spec *v1.UpgradeSpec) error {
if targetSpec.Source.IsEmpty() {
return nil
}

size, err = GetSourceSize(cfg, targetSpec.Source)
if err != nil {
return err
Expand Down
Loading