Skip to content

Conversation

@songhahaha66
Copy link
Contributor

Type of Change

  • New Feature
  • Bug Fix
  • Documentation
  • Performance Improvement
  • Test/CI
  • Refactor
  • Other:

Related Issues

#643

Summary of Changes

fix bugs in exporting policies and service account

Checklist

  • I have read and followed the CONTRIBUTING.md guidelines
  • Passed make pre-commit
  • Added/updated necessary tests
  • Documentation updated (if needed)
  • CI/CD passed (if applicable)

Impact

  • Breaking change (compatibility)
  • Requires doc/config/deployment update
  • Other impact:

Additional Notes


Thank you for your contribution! Please ensure your PR follows the community standards (CODE_OF_CONDUCT.md) and sign the CLA if this is your first contribution.

@CLAassistant
Copy link

CLAassistant commented Oct 18, 2025

CLA assistant check
All committers have signed the CLA.

@houseme houseme requested a review from Copilot October 19, 2025 10:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Fixes bugs in exporting policies and service accounts by correcting policy version validation, adjusting IAM import behavior, and fixing a service account check.

  • Validate Policy and BucketPolicy using the version field (not id).
  • Change IAM import to aggregate per-policy errors and remove “removed” from ImportIAMResult.
  • Fix service account verification logic in IamSys.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
rustfs/src/admin/handlers/user.rs Changes import flow to set policies and collect failures instead of failing fast; removes “removed” entities from the import result.
crates/policy/src/policy/policy.rs Validates Policy and BucketPolicy against DEFAULT_VERSION using the version field.
crates/madmin/src/user.rs Removes removed from ImportIAMResult and updates doc for added.
crates/iam/src/sys.rs Corrects service account check to reject non-service accounts.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 377 to 387
/// imported entries. We dont fail hard in this case and
pub skipped: IAMEntities,

/// Removed entries - this mostly happens for policies
/// where empty might be getting imported and that's invalid
pub removed: IAMEntities,

/// Newly added entries
/// Newly added or updated entries
pub added: IAMEntities,

/// Failed entries while import. This would have details of
Copy link

Copilot AI Oct 19, 2025

Choose a reason for hiding this comment

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

Removing the removed field from ImportIAMResult is a breaking change for any external consumers of the madmin API. To preserve backward compatibility, consider keeping removed as an optional, deprecated field with serde defaults (e.g., #[serde(default, skip_serializing_if = "Option::is_none")] pub removed: Option) or explicitly bump the crate’s major version and note the API change.

Copilot uses AI. Check for mistakes.
@houseme houseme requested a review from weisd October 19, 2025 10:55
@houseme houseme requested a review from Copilot October 20, 2025 07:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

.map_err(|e| S3Error::with_message(S3ErrorCode::InternalError, e.to_string()))?;
for (name, policy) in policies {
if policy.id.is_empty() {
if policy.is_empty() {
Copy link

Copilot AI Oct 20, 2025

Choose a reason for hiding this comment

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

Policy does not expose an is_empty() method; this will not compile. Based on the related changes switching from id to version, this condition should check the version field instead (e.g., policy.version.is_empty()).

Suggested change
if policy.is_empty() {
if policy.version.is_empty() {

Copilot uses AI. Check for mistakes.
Comment on lines 679 to 681
let res = iam_store.delete_policy(&name, true).await;
removed.policies.push(name.clone());
if let Err(e) = res {
Copy link

Copilot AI Oct 20, 2025

Choose a reason for hiding this comment

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

The removal is recorded before confirming delete_policy succeeded, which can produce inaccurate export results. Move removed.policies.push(name.clone()) after a successful deletion (e.g., inside the Ok branch) so failures are not reported as removed.

Copilot uses AI. Check for mistakes.
@weisd weisd merged commit 46797dc into rustfs:main Oct 20, 2025
12 checks passed
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.

4 participants