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 image size calculation #499

Closed
wants to merge 6 commits into from
Closed

Conversation

jimmykarily
Copy link
Contributor

@jimmykarily jimmykarily commented Aug 28, 2024

dnugmanov and others added 4 commits August 28, 2024 13:22
Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
@jimmykarily jimmykarily force-pushed the fix-image-size-calculation-tests branch from 40ea4d2 to 69e7e6a Compare August 28, 2024 11:11
pkg/config/spec.go Outdated Show resolved Hide resolved
Copy link

codecov bot commented Aug 28, 2024

Codecov Report

Attention: Patch coverage is 41.17647% with 10 lines in your changes missing coverage. Please review.

Project coverage is 52.00%. Comparing base (390bc6a) to head (961e1ff).
Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
pkg/config/spec.go 46.66% 4 Missing and 4 partials ⚠️
internal/agent/upgrade.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #499      +/-   ##
==========================================
- Coverage   52.07%   52.00%   -0.07%     
==========================================
  Files          52       52              
  Lines        4941     4951      +10     
==========================================
+ Hits         2573     2575       +2     
- Misses       2083     2087       +4     
- Partials      285      289       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
@jimmykarily jimmykarily marked this pull request as ready for review August 28, 2024 11:51
@jimmykarily jimmykarily requested a review from a team August 28, 2024 11:55
@jimmykarily jimmykarily changed the title Fix image size calculation tests Fix image size calculation Aug 28, 2024
@jimmykarily
Copy link
Contributor Author

With kairos-agent from this branch, I still see this text:

2024-08-28T12:43:40Z INF Creating file system image /run/initramfs/cos-state/cOS/transition.img with size 3072Mb

on the ugprade logs. Either the text is wrong or it didn't work as expected.

there are 3 ways:

- cli arg: --recovery
- cli arg: --boot-entry
- config setting: upgrade.recovery: true

We only checked the config setting

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
@@ -238,12 +238,14 @@ func upgradeUki(source string, dirs []string, upgradeEntry string, strictValidat
// ExtraConfigUpgrade is the struct that holds the upgrade options that come from flags and events
type ExtraConfigUpgrade struct {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We take the cli args and we make a new type of config (this one). Then we serialize this thing to a json (or YAML?) string and we merge it with the rest of the config. The keys of the resulting string didn't match those of the Config we are trying to build thus the setting only made it to the raw Config (which we store as a separate key). That's why the original PR (see the first commit in this one) had to use cfg.Query to get to this key.

With the changes here, the actual fields of the Config get populated correctly.

entry := ""
_, ok := cfg.Config["upgrade"]
if ok {
// check value from --recovery and --boot-entry
entry, _ = cfg.Config["upgrade"].(collector.Config)["entry"].(string)
Copy link
Contributor Author

@jimmykarily jimmykarily Aug 28, 2024

Choose a reason for hiding this comment

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

We were skipping this but no tests were broken. This means we need to add a test to make sure we don't break it again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems that this wasn't needed because of the unmarshallFullSpec below: https://github.com/kairos-io/kairos-agent/pull/499/files#diff-53b724197bc14c3828ce6725322b892cb788860b0526184b63d7d114edb60941R370

generateUpgradeConfForCLIArgs has added the field upgrade.entry (see ExtraConfigUpgrade) which is marshalled into a yaml and passed to the config collector (as a string).

Let's check if this is still working as intended.

@jimmykarily jimmykarily requested a review from a team August 28, 2024 14:35
@@ -146,8 +146,8 @@ func generateUpgradeConfForCLIArgs(source, upgradeEntry string) (string, error)
// have access to that yet, we just set both uri values which shouldn't matter
// anyway, the right one will be used later in the process.
if source != "" {
upgradeConfig.Upgrade.RecoverySystem.URI = source
upgradeConfig.Upgrade.System.URI = source
upgradeConfig.Install.RecoverySystem.URI = source
Copy link
Member

Choose a reason for hiding this comment

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

this feels wrong. This has worked with cli flags since forever, so it doesnt seem like it would be the source of the issue. The end config/spec has the proper sources so it seems wrong to me that this would be broken here?

Are we sure this doesnt break anything? IIRC our test use the cli flags to upgrade by setting a source, so this seems to be working as expected or our tests are fully broken.

I dont have anything else to proof this other than a feeling that if source cli flags work, this migth be working but I could be wrong...

@jimmykarily
Copy link
Contributor Author

We discussed this in the planning meeting and we agreed this part of the code needs some refactoring but for now we'll go with this fix instead: https://github.com/kairos-io/kairos-agent/pull/508/files

I will try to move the new test from this PR to the #508 one to have it as an additional check.

@jimmykarily
Copy link
Contributor Author

I created this PR for the test and the additional fix: #509
Closing this one.

@jimmykarily jimmykarily closed this Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants