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

Registry sync should not delete profiles when failing to sync #386

Closed
Nevon opened this issue Mar 15, 2023 · 4 comments
Closed

Registry sync should not delete profiles when failing to sync #386

Nevon opened this issue Mar 15, 2023 · 4 comments

Comments

@Nevon
Copy link

Nevon commented Mar 15, 2023

Currently the way that the sync works is that it deletes all the content of the aws config that was created by granted, and then it fetches the new configuration and writes it back into the config file. If there is any error syncing a registry, all the other profiles are added into the config file.

I encountered this behavior the other day when I couldn't find any of the profiles I expected. The reason was that at the beginning of the workday I forgot to connect to the company VPN, which means that the first time I used assume it tried to sync my profiles but couldn't reach the remote repository and thus deleted most of my profiles from my config. I didn't notice this until later when I was very confused.

My suggestion would be that the configuration should have some kind of marker that shows which registry a profile was synced from. If syncing from a particular registry fails, print an error but don't delete that section.

@Eddie023
Copy link
Collaborator

Hi @Nevon, thank you for raising this issue. Currently you can use --prefix-all-profile flag with granted registry add to add your registry name as prefix to show which registry a profile was synced from.

On the registry sync failure case, removing the whole section on error was so that user will have visibility if there is some issues with the latest remote registry sync and can quickly update it. But in your case it was caused on the user end which is a bit of a problem. I will have a look on how we can make this experience better. Thanks again for raising this!

@webframp
Copy link

webframp commented Jun 2, 2023

Just hit this myself:

[i] Syncing Profile Registries
[!] Sync failed for registry o11n
[Γ£ö] Completed syncing Profile Registries

[Γ£ÿ] Granted couldn't find any AWS profiles in your config file or your credentials file
[i] You can add profiles to your AWS config by following our guide:
[i] https://docs.commonfate.io/granted/getting-started#set-up-your-aws-profile-file

I had valid config of course, remote git repo is unreachable during sync (with no way to skip sync when running assume) so sync fails and config is deleted

@sosheskaz
Copy link
Contributor

"Automatically zero the configs I use for production access" is not an acceptable failure mode for something that runs automatically. It creates a situation where, if there is an SCM issue — whether client-side connectivity, configuration, or Github is down, users cannot access their AWS configs.

If you understand granted and granted registries well, there are generally workarounds, but the typical user should not need to be aware of them.

sosheskaz added a commit to sosheskaz/granted that referenced this issue Dec 7, 2023
chrnorm pushed a commit that referenced this issue Dec 14, 2023
* Do not overwrite AWS config when sync fails

Fix issue #386

* Add WriteOnSyncFailure option to repo sync
sosheskaz added a commit to sosheskaz/granted that referenced this issue Dec 19, 2023
* Do not overwrite AWS config when sync fails

Fix issue common-fate#386

* Add WriteOnSyncFailure option to repo sync
@chrnorm
Copy link
Contributor

chrnorm commented Mar 14, 2024

Fixed in #569

@chrnorm chrnorm closed this as completed Mar 14, 2024
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

5 participants