Skip to content

fix: attach policies to Role on create #136

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

michaelhtm
Copy link
Member

@michaelhtm michaelhtm commented May 8, 2025

Description of changes:
Currently the controller attaches policies to Role 30 seconds after
creating them.

These changes attach the policies immediately after Role creation.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ack-prow ack-prow bot requested review from knottnt and rushmash91 May 8, 2025 20:03
@ack-prow ack-prow bot added the approved label May 8, 2025
Copy link
Member

@rushmash91 rushmash91 left a comment

Choose a reason for hiding this comment

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

thanks @michaelhtm! should we be calling the syncManagedPolicies instead?

err := rm.addManagedPolicy(ctx, &resource{ko}, p)
if err != nil {
return &resource{ko}, err
}
Copy link
Member

Choose a reason for hiding this comment

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

can we use the sync function here?

Copy link
Member Author

Choose a reason for hiding this comment

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

sync would require ko.Spec.Policies to be nil, so that we can add all the Policies.
I can set it to nil, call syncPolicies, and then set it back to the ko.Spec.Policies = desired.ko.Spec.Policies

Is there a reason we must call sync?

Copy link
Member

@rushmash91 rushmash91 May 13, 2025

Choose a reason for hiding this comment

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

Not a requirement, but now we have two ways I think I used a different function for EC2 and @a-hilaly uses the one sync in lambda. We should probably choose a way.

if err != nil {
return &resource{ko}, err
}
}
Copy link
Member

Choose a reason for hiding this comment

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

ditto?

Copy link

@knottnt knottnt left a comment

Choose a reason for hiding this comment

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

Is there an issue associated with this fix? If there is it would be helpful to include a link to the issue and brief description of what the PR is changing. Having those links will make it easier for folks in the future to navigate the project's history.

@michaelhtm michaelhtm changed the title fix: add policies on create fix: add policies to role on create May 9, 2025
@michaelhtm michaelhtm changed the title fix: add policies to role on create fix: add policies to Role on create May 9, 2025
@michaelhtm michaelhtm changed the title fix: add policies to Role on create fix: attach policies to Role on create May 9, 2025
Comment on lines 5 to 20
ko.Spec.AssumeRolePolicyDocument = &doc
}
}
for _, p := range desired.ko.Spec.Policies {
err := rm.addManagedPolicy(ctx, &resource{ko}, p)
if err != nil {
return &resource{ko}, err
}
}
for n, p := range desired.ko.Spec.InlinePolicies {
err := rm.addInlinePolicy(ctx, &resource{ko}, n, p)
if err != nil {
return &resource{ko}, err
}
}
ackcondition.SetSynced(&resource{ko}, corev1.ConditionFalse, nil, nil)
Copy link
Member

Choose a reason for hiding this comment

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

nit: we can move it into a hook, just a suggestion.

Copy link

ack-prow bot commented May 13, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: michaelhtm, rushmash91

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [michaelhtm,rushmash91]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@michaelhtm michaelhtm force-pushed the fix/addpoliciesoncreate branch from 9dbe271 to 589da29 Compare May 14, 2025 21:06
Copy link

ack-prow bot commented May 14, 2025

@michaelhtm: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
iam-verify-attribution 589da29 link false /test iam-verify-attribution

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants