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

Colima runs should never overwrite configuration on disk #613

Open
purajit opened this issue Feb 8, 2023 · 6 comments
Open

Colima runs should never overwrite configuration on disk #613

purajit opened this issue Feb 8, 2023 · 6 comments

Comments

@purajit
Copy link

purajit commented Feb 8, 2023

Description

Currently, running colima start with any configuration overwrites the profile on disk:

➜  colima start > /dev/null 2>&1 && yq .memory ~/.colima/default/colima.yaml
2

➜  colima stop  > /dev/null 2>&1 && colima start -m 4  > /dev/null 2>&1 && yq .memory ~/.colima/default/colima.yaml
4

➜  colima stop  > /dev/null 2>&1 && colima start -m 8  > /dev/null 2>&1 &&  yq .memory ~/.colima/default/colima.yaml
8

➜  colima start

# within container
$ free -h | head -2 | tail -1 | awk '{print $2}'
7.7Gi

This is highly undesirable unless explicitly asked for (for instance, maybe with a --save-config), since this means that a run of just colima start implies running the previous configuration, rather than running a profile you had saved. The point of a profile is to have a consistent saved config you can rely on, and any CLI args should be assumed to be overrides just for that specific run.

This is especially true when you're not using a profile, where the assumption of running colima start with no args would be to choose the documented defaults (for example, 2GB of memory).

(I also understand here that there might be a split in opinions on what the assumed behavior is, in which case I'd request at least having an option to prevent overwriting the configuration on disk, even if it doesn't default to that)

@abiosoft
Copy link
Owner

abiosoft commented Feb 8, 2023

I can understand your point.

Yeah, Colima basically merges the CLI flags (if specified) with the current config to generate a new config file, and thereafter starts off the (newly generated) config file.

It is kinda convenient and works for most people.

(I also understand here that there might be a split in opinions on what the assumed behavior is, in which case I'd request at least having an option to prevent overwriting the configuration on disk, even if it doesn't default to that)

I have no objections with that. What shall we call it? --temporary-config, --discard-config, --override-config=false, --save-config=false ? Naming things is hard :|

I would prefer to have a flag that the zero value defaults to the current behaviour i.e specifying it would disable overwriting the config file.

@purajit
Copy link
Author

purajit commented Feb 8, 2023

I would prefer to have a flag that the zero value defaults to the current behaviour i.e specifying it would disable overwriting the config file.

Makes sense, I'm not too opinionated on that

What shall we call it?

Again, no strong opinions. I think --override-config=false or --save-config=false are the most obvious.

I haven't dug into the codebase, but how reasonable would it be to have this flag in the profile config as well, indicating that that profile should never be overwritten by CLI?

A use case would be to distribute a colima profile for everyone working in an org with some canonical configs, which won't unintentionally be changed when someone's running some experiments. If it's something you're ok with but can't prioritize, I can give it a shot.

@abiosoft
Copy link
Owner

abiosoft commented Feb 8, 2023

how reasonable would it be to have this flag in the profile config as well, indicating that that profile should never be overwritten by CLI?

Simply having a locked config might suffice.

# Prevent this config file from being updated by user specified CLI flags and temporary edits via the `--edit` flag.
# By default, Colima updates the config file to persist the changes specified via CLI flags or temporary edits.
# Default: false
locked: false

The other question woud be the behaviour of the --edit flag, should it be handled in similar fashion like the sample yaml snippet above?

@purajit
Copy link
Author

purajit commented Feb 16, 2023

Sorry, had a busy week.

I'm happy with that configuration, and I think it makes sense to prevent --edit from altering it as well.

Btw another behavior I've noticed, which may impact even people who don't want to lock their profiles - any additional comments written get erased. So for instance, even without changing any configs, if my original config had comment explanations for why a certain default was changed, it gets erased on a plain colima start.

@pangdaxing23
Copy link

The current behavior is extremely jarring and reads as a bug rather than a feature. Please do not touch the config unless it is asked for. And it is very natural for most people to assume overwriting the config would be opt-in rather than opt-out, so if you go with --save-config as the flag, I would vote that it should default to false . A simple colima start should simply run the default config.

@kustodian
Copy link

Are there any updates if this is going to be implemented? Because Colima always overwrites the configuration file it's hard to automate the Colima configuration.

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

No branches or pull requests

4 participants