-
Notifications
You must be signed in to change notification settings - Fork 113
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
[A2-572] Add 'viewer' and 'editor' users to local-dev and dev/acceptance envs, add --skip-policy-migration
to upgrade-to-v2
#403
[A2-572] Add 'viewer' and 'editor' users to local-dev and dev/acceptance envs, add --skip-policy-migration
to upgrade-to-v2
#403
Conversation
bae9a81
to
38cca3c
Compare
--skip-legacy-upgrade
to upgrade-to-v2
563cdfa
to
cc93a17
Compare
Reusing the logic we've had for resetting admin access. Signed-off-by: Stephan Renatus <[email protected]>
This hooks in the call to the new dev command. The resulting logins will be: - viewer:chefautomate - editor:chefautomate Signed-off-by: Stephan Renatus <[email protected]>
Signed-off-by: Stephan Renatus <[email protected]>
Signed-off-by: Stephan Renatus <[email protected]>
…tion Signed-off-by: Stephan Renatus <[email protected]>
Signed-off-by: Stephan Renatus <[email protected]>
Signed-off-by: Stephan Renatus <[email protected]>
…buf] Signed-off-by: Stephan Renatus <[email protected]>
Signed-off-by: Stephan Renatus <[email protected]>
Signed-off-by: Stephan Renatus <[email protected]>
…otobuf] Signed-off-by: Stephan Renatus <[email protected]>
Signed-off-by: Stephan Renatus <[email protected]>
Signed-off-by: Stephan Renatus <[email protected]>
Signed-off-by: Stephan Renatus <[email protected]>
Signed-off-by: Stephan Renatus <[email protected]>
…icies Signed-off-by: Stephan Renatus <[email protected]>
Signed-off-by: Stephan Renatus <[email protected]>
Since this call only happens once (the second time it's run, the existance of the a2-iamv2-enabled file will block execution), it will only affect our short-lived environments. Should we ever re-deploy our long-lived ones, then this _would_ also skip their legacy policies. However, I'm not sure why we'd like to avoid that. Signed-off-by: Stephan Renatus <[email protected]>
Now, the zero value reflects the current behaviour. Without this, existing caller (tests!) would have requested the v1 policies to be ignored. Signed-off-by: Stephan Renatus <[email protected]>
Signed-off-by: Stephan Renatus <[email protected]>
Signed-off-by: Stephan Renatus <[email protected]>
Signed-off-by: Stephan Renatus <[email protected]>
Signed-off-by: Stephan Renatus <[email protected]>
cc93a17
to
8d4e9e7
Compare
git grep skip-legacy-upgrade |\ gawk -F: '!a[$1]++{ print $1 }' |\ xargs -- gsed -i s/skip-policy-upgrade/skip-policy-migration/g Signed-off-by: Stephan Renatus <[email protected]>
8d4e9e7
to
61ccc53
Compare
--skip-legacy-upgrade
to upgrade-to-v2
--skip-policy-migration
to upgrade-to-v2
Signed-off-by: Stephan Renatus <[email protected]>
} | ||
|
||
// all flags are hidden right now | ||
cmd.PersistentFlags().VisitAll(func(f *pflag.Flag) { f.Hidden = !isDevMode() }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the team consensus was that skip-policy-migration
was for public consumption as well...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i believe that consensus convo happened last friday during subtasking and i wasnt there. if we do make it public we should have a corresponding docs update, so id like to do that in a separate pr if possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm all in favour of not adding anything here 😉
recordFailure() | ||
return nil, status.Errorf(codes.Internal, "list v1 policies: %s", err.Error()) | ||
} | ||
reports = append(reports, fmt.Sprintf("%d v1 policies", len(pols))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider "%d v1 policies found -- skipping"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The output, in the end, will be
[79][default:/src:0]# chef-automate iam upgrade-to-v2 --beta2.1 --skip-policy-migration
Enabling IAM v2.1
Skipped policies:
28 v1 policies
(see PR message) -- I'd rather not use skipped twice there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@srenatus do you mind if we have a single line with Skipped: %d v1 policies
, then a newline before the teams output?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now, that's shared between a migration and no migration (see https://github.com/chef/a2/pull/4120#issuecomment-433389839), so it's a little more work than just the formatting. But yeah, we can do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh i see.... nah, just leave it as is for now.
return err | ||
} | ||
// Note: the teams SHOULD exist. But since you never know what happens in a | ||
// long running acceptance env, we'll better ensure them: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/we'll/we'd/
"editor": {"Editor User", "chefautomate", "editors"}, | ||
} { | ||
userID, _, err := adminmgmt.CreateUserOrUpdatePassword(ctx, | ||
apiClient, username, data.displayName, data.password, false /* dry run */) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personal style thing for sure, but just my 2 cents:
false /* dry run */
suggests to me that "setting this param false here and that means it is a dry run".
Whereas:
/* dry run */ false
suggests to me that "this is supplying a value of false for 'dry run' and that means it is not a dry run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hehe I didn't mean to convey that much -- I really just meant "this bool
is the dry run parameter". But yeah, you're not wrong with that connotation 😉
touch /root/a2-iamv2-enabled | ||
;; | ||
"v2") | ||
chef-automate iam upgrade-to-v2 | ||
chef-automate iam upgrade-to-v2 --skip-policy-migration | ||
chef-automate dev create-iam-dev-users |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good stuff!
I'll merge this on Monday and deal with the fallout. |
🔩 Description
Our environments, both for local development and dev/acceptance, are less useful than they could be if everyone keeps using the admin user for all the things. Especially in the short-lived ones, it's cumbersome to add these users manually for acceptance testing time and time again.
The same goes for the local development environment. The world looks quite different if you're not an admin 😉
All of this only applies to envs using IAM v2 or v2.1. However, the users can exist in v1 environments in just the same way, so the local studio env is not upgraded to IAM v2 or IAM v2.1 yet (as of now).✔️ local studio env is upgrade as well.Reviewers!
Please follow the commits. There's a few of them, and they should tell the story of this PR 😉
👍 Definition of Done
team:local:viewers
,team:local:editors
)a2-iam-v2-only-integration
inspec suite no longer creates the users itself, but relies on the newly added cli command for thatchef-automate iam upgrade-to-v2
,--skip-legacy-upgrade
, that causes v1 policies to not get migratedstart_all_services
--skip-policy-migration
for clarity (discussed this with @susanev)👟 Demo Script / Repro Steps
local development
rebuild components/automate-cli
rebuild components/automate-gateway
,rebuild components/authz-service
for testingchef-automate iam update-to-v2 --skip-policy-migration
start_all_services
login as either "viewer" or "editor" (password is "chefautomate")
to independently check the
--skip-policy-migration
flag's output:CHEF_DEV_ENVIRONMENT
to something that's notyes
:dev/acceptance envs
⛓️ Related Resources
✅ Checklist