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

[SURE-8832] fix: add check for external rules while updating roleTemplate #1389

Merged
merged 1 commit into from
Sep 5, 2024

Conversation

pratikjagrut
Copy link
Contributor

Issue: #1381

Problem

JIRA issue: https://jira.suse.com/browse/SURE-8832
When attempting to update a RoleTemplate using the rancher2 tf provider v4.2.0 you will get the following error:

Error: Bad response statusCode [400]. Status [400 Bad Request]. Body: [baseType=error,
code=BadRequest, message=admission webhook "rancher.cattle.io.roletemplates.management.cattle.io" 
denied the request: ExternalRules can't be set in RoleTemplates with external=false] from 
[https://example.com/v3/roleTemplates/rt-mb28r]

Solution

  • Modified the roleTemplate update logic to include a check for external rules.
  • Added a condition to ensure external rules are only updated when the external flag is set.
  • Set externalRules to nil if the external flag is not set.

Testing

Engineering Testing

Manual Testing

The fix was tested using the reproduction steps, and the issue was resolved.

Automated Testing

QA Testing Considerations

Regressions Considerations

@matttrach matttrach changed the title [SURE-8832] fix: add check for external rules while updating roleTelate [SURE-8832] fix: add check for external rules while updating roleTemplate Sep 3, 2024
Copy link
Member

@jiaqiluo jiaqiluo left a comment

Choose a reason for hiding this comment

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

lgtm

Hi @matttrach, could you help arrange the backporting if it is necessary?

Copy link
Collaborator

@matttrach matttrach left a comment

Choose a reason for hiding this comment

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

The code is reasonable here, and the unit tests pass.

@matttrach
Copy link
Collaborator

@pratikjagrut would you mind signing your commit? Then I will get this merged into the proper branches.

…late

- Modified the roleTemplate update logic to include a check for external rules.
- Added a condition to ensure external rules are only updated when the `external` flag is set.
- Set `externalRules` to `nil` if the `external` flag is not set.

Signed-off-by: Pratik Jagrut <[email protected]>
@pratikjagrut
Copy link
Contributor Author

@pratikjagrut would you mind signing your commit? Then I will get this merged into the proper branches.

@matttrach I've signed the commit.

@matttrach
Copy link
Collaborator

I will backport this to release/v5 and release/v4 in separate PRs.

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

Successfully merging this pull request may close these issues.

3 participants