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

Read actual system configs during k8s upgrade #579

Merged
merged 4 commits into from
Oct 16, 2024
Merged

Conversation

Itxaka
Copy link
Member

@Itxaka Itxaka commented Oct 16, 2024

Because under k8s the actual real system is mounted into a dir, the configs that we are reading by default are not the ones in the system but the ones on the upgrade container, which is running under /

This patch introduces a check to see if we are running under k8s, and if we are it tries to get the host dir where the system is mounted. then it will prepend that host dir to the config scan so we can actually scan the system configs.

Int he case we are out of k8s, this should not affect the upgrade as it will return an empty string resulting in the ususal dirs being scanned

Fixes kairos-io/kairos#2944 and probably others lol

Because under k8s the actual real system is mounted into a dir, the
configs that we are reading by default are not the ones in the system
but the ones on the upgrade container, which is running under /

This patch introduces a check to see if we are running under k8s, and if
we are it tries to get the host dir where the system is mounted. then it
will prepend that host dir to the config scan so we can actually scan
the system configs.

Int he case we are out of k8s, this should not affect the upgrade as it
will return an empty string resulting in the ususal dirs being scanned

Signed-off-by: Itxaka <[email protected]>
@Itxaka Itxaka requested a review from a team October 16, 2024 08:44
Signed-off-by: Itxaka <[email protected]>
thanks tests

Signed-off-by: Itxaka <[email protected]>
Copy link

codecov bot commented Oct 16, 2024

Codecov Report

Attention: Patch coverage is 25.00000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 49.94%. Comparing base (d5ded90) to head (93e22cf).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
internal/agent/upgrade.go 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #579      +/-   ##
==========================================
- Coverage   49.96%   49.94%   -0.03%     
==========================================
  Files          48       48              
  Lines        4653     4655       +2     
==========================================
  Hits         2325     2325              
- Misses       2051     2054       +3     
+ Partials      277      276       -1     

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

hostDir = "/host"
}
hostDir := k8sutils.GetHostDirForK8s()
config.Logger.Logger.Debug().Bool("status", underKubernetes).Str("hostdir", hostDir).Msg("Running under kubernetes host directory")
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 no if anymore. This will always read "Running under kubernetes host directory" no? Or is Bool() a conditions on whether to print this or not?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, indeed, I will change the msg.

this is just to show the values of the kubernetes and hostdirectory for debug purposes as it can happen that its doing it worngly and we have no visibility onto it

return "/host"
}
} else {
// We return an empty string so any filepath.join does nto alter the paths
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// We return an empty string so any filepath.join does nto alter the paths
// We return an empty string so any filepath.join does not alter the paths

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

Signed-off-by: Itxaka <[email protected]>
@Itxaka Itxaka merged commit e2c3a0e into main Oct 16, 2024
9 checks passed
@Itxaka Itxaka deleted the fix_checkusers_k8s branch October 16, 2024 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Check for users do not work under k8s
2 participants