-
Notifications
You must be signed in to change notification settings - Fork 97
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
duplicated cloud config entries after installation #2492
Comments
@mudler isn't this happening on Stylus, only? |
@mauromorales i think this can happen with kairos also. For example, if you have two identical cloudconfigs with something like this
logic here would append stages in initramfs |
Since golang slices by default is not a comparable type, this probably is not a bug but an expected behavior. But maybe we can implement some custom comparators for different stages to merge slices instead of appending them. |
@nianyush ah got it, sorry I thought it was generated code, but indeed if the user requests the same users multiple times they are just appened. Hmm I would just be afraid that this kind of logic can make the parser "too" smart. When should it DRY config, and when not? Specially because user can be added at different stages, including also the |
Yes you are right. And user might want to execute a same stage more than once but just in different postitions of initramfs |
Hello! I'm a bot, an experiment of @mudler and @jimmykarily. Thank you for opening the issue about the duplicated cloud config entries after the installation of Kairos. I have added the 'triage' label to your issue, which means that it has been reviewed and we're in the process of determining whether it's a bug or not. If you have more information to provide or any additional questions, feel free to add a comment to the issue. Thank you for using Kairos and for reporting this issue! |
Should we close this then? Is it about cleaning up the configs or can't these multiplied entries not be avoided? |
Relevant old issue: #1341 |
This should fix this issue, mainly making it irrelevant to have multiple users, as it wont trigger any side effects: |
Also related: #1665 |
I checked the CanvOS build logic and it only copies in the cloud-config data once to the ISO:
But somehow, this file gets processed twice by Kairos, resulting in the duplicate entries. If we can remove the double processing, the duplicate entries problem becomes a LOT smaller. |
Seems like kairos is trying to read cloudconfigs under /system/oem/ and config.yaml under root of iso twice while generating 90_custom |
We used an provider to handle installation event and the stages injected through that provider is not duplicated. |
@kreeuwijk no I have verified removing this line would not help. I will push a fix to remove this line in CanvOS |
Based on some troubleshooting, the file So unless that section of the |
Hmm even if I remove the @mudler I'm starting to suspect that this is the culprit of all the duplication: https://github.com/kairos-io/kairos-agent/blob/main/internal/agent/install.go#L102-L103 |
@kreeuwijk right, we need to check if the collector is responsible indeed and we need to have a deeper look at it. That is the only place where it can actually happen we can duplicate config files. Meanwhile mudler/yip#147 should have addressed #2488 and this issue shouldn't now be anymore blocking (even if not nice to have as a bug). |
Also https://github.com/mudler/yip/blob/93948138a7b6826ff8344952874faf48e08e0400/pkg/plugins/datasource.go#L250 could have caused this, but we addressed that specific case already in kairos-io/kairos-sdk#58 , but maybe we still do some mangling in the system cloud configs that could affect that? https://github.com/kairos-io/packages/blob/1a6d7667700a3fdf09eabd8729885c10117bffd6/packages/static/kairos-overlay-files/files/system/oem/00_datasource.yaml#L22 @kreeuwijk when you see duplicated content, are you supplying the cloud config on the userdata? or it always happens in any case? |
@mudler what does mudler/yip#147 do exactly? Does it only run one of the steps if it find duplicate entries? I'm specifically seeing 2 things get duplicated:
As the content gets merged, you only see the duplication in practice for lists, hence it shows up in |
@kreeuwijk mudler/yip#147 will find the x duplicated users for example, and will run all of them but in serial. This to avoid any racecondition. There's also another fix that will try to reuse the uid if the user already exists mudler/yip#145 |
Ah I see, so you will end up with e.g. multiple entries in |
@kreeuwijk actually just one entry because the User plugin for yip, will actually "update" the user |
Hmmm I'll check that as I saw the |
@kreeuwijk yes I think that cold come from mudler/yip#145 because it's only checking if a user already exists, but not if a group already exists. So if you have 2 times the same user creation, it will create it twice (with 2 groups too) but it will try to reuse the uid from the first one for the second user ... I'm not sure if this is better than letting it just take a new user, we would need to investigate why it was done this way |
As long as multiple entries in |
yeah, I mean we have to make a decision here as to what constitutes a duplication, but the problem is that yaml can take anything without its context. So let's say for a user, maybe a duplicated username is enough to say this is a duplication, and the merge will take the last found (which can also be problematic because maybe you put different passwords there and the one that ends up taken is the last with another password), but every other item can also have its own context, running a command could get merged, but maybe you actually wanted to run two of them because you are doing a @kreeuwijk For me, one of the questions is, why does the canvas cloud-config file contain at least 2 creations of the user (one with a name and one without)? And can we just have 1 instead? |
I would rather just avoid the duplication in the first place, instead of trying to deal with the fallout of duplication. |
@mauromorales where are you seeing CanvOS make a user twice? |
@kreeuwijk yes that is my point that the configs already come with the duplication in the first place. The picture that was placed in the issue, comes from an installation using CanvOS. I never get such a duplication if I install a Kairos system with a single user |
you can simply see it because there is:
and also
|
@mauromorales i think that's from an old test installation... maybe i was giving users in multiple places. But in my most recent installation , I don't have such behavior and I can confirm I have only defined users stage in user data once but not in any other cloud config. Which I still see that entry got duplicated |
@nianyush could you share all your different cloud-configs that you are using on a system? My assumption is that when I search for creation of users in stylus https://github.com/search?q=repo%3Aspectrocloud%2Fstylus%20passwd%3A%20kairos&type=code I see so many of them, so if by any chance the system picks 2+ of those, then you will have duplications |
Correct, CanvOS is not setting a
This is what most user-data files in CanvOS have. On a flashed device, you see this in /oem/90_custom.yaml twice due to the duplication. I checked the /etc/passwd file on a device and it did only show 1 entry for |
@mauromorales til the point I was facing issues, stylus service hasn't really started. Only the provider plugin to handle installation event is ran |
Relates to kairos-io/kairos#2492 Signed-off-by: Mauro Morales <[email protected]>
Relates to kairos-io/kairos#2492 Signed-off-by: Mauro Morales <[email protected]>
Relates to kairos-io/kairos#2492 Signed-off-by: Mauro Morales <[email protected]>
So far our best assumption of the issue is as follows: the issue only happens on Canvos because it happens to pass a cloud config via a payload through the install event. While on the provider Kairos this could only be experienced when doing a config via a QR but we don't really have tests for this and it's rarely tested manually.
While we haven't been able to reproduce exactly, this steps differ from the original busines logic which should be:
This means that the |
Relates to kairos-io/kairos#2492 Signed-off-by: Mauro Morales <[email protected]>
fix is working with provider payload now |
Relates to kairos-io/kairos#2492 Signed-off-by: Mauro Morales <[email protected]>
Relates to kairos-io/kairos#2492 Signed-off-by: Mauro Morales <[email protected]>
Looks like after installation all the list items aren't merged, but appended
The text was updated successfully, but these errors were encountered: