-
Notifications
You must be signed in to change notification settings - Fork 559
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
rbd: use blocklist range cmd, fallback if it fails #3385
Conversation
// iterating through IP range. | ||
err := nf.addCephBlocklist(ctx, cidr, true) | ||
if err == nil { | ||
return nil |
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.
we should not return here its for loop.
// iterating through IP range. | ||
err := nf.removeCephBlocklist(ctx, cidr, true) | ||
if err == nil { | ||
return nil |
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.
continue instead of return
return nil | ||
} | ||
if !strings.Contains(err.Error(), "invalid command") { | ||
return fmt.Errorf("failed to blocklist range rm %q: %w", cidr, err) |
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.
return fmt.Errorf("failed to blocklist range rm %q: %w", cidr, err) | |
return fmt.Errorf("failed to remove blocklist range %q: %w", cidr, err) |
if !strings.Contains(err.Error(), "invalid command") { | ||
return fmt.Errorf("failed to blocklist range rm %q: %w", cidr, err) | ||
} | ||
log.DebugLog(ctx, "failed to use blocklist range cmd, falling back to single ip blocklisting: %s", err) |
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.
remove debug log
return nil | ||
} | ||
if !strings.Contains(err.Error(), "invalid command") { | ||
return fmt.Errorf("failed to blocklist range add %q: %w", cidr, err) |
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.
return fmt.Errorf("failed to blocklist range add %q: %w", cidr, err) | |
return fmt.Errorf("failed to add blocklist range %q: %w", cidr, err) |
@@ -93,6 +98,16 @@ func (nf *NetworkFence) addCephBlocklist(ctx context.Context, ip string) error { | |||
func (nf *NetworkFence) AddNetworkFence(ctx context.Context) error { | |||
// for each CIDR block, convert it into a range of IPs so as to perform blocklisting operation. | |||
for _, cidr := range nf.Cidr { | |||
// try range blocklist cmd, if invalid fallback to | |||
// iterating through IP range. | |||
err := nf.addCephBlocklist(ctx, cidr, true) |
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.
Can you move this to a helper and use a NetworkFence.hasBlocklistRange
bool? No need to pass it around that way, and it will only be tried once for the cidr
in nf.Cidr
.
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.
made modifications so we only check fail with invalid command in the first iteration.
4b06c7b
to
082dba4
Compare
// try range blocklist cmd, if invalid fallback to | ||
// iterating through IP range. | ||
if hasBlocklistRangeSupport { | ||
err := nf.addCephBlocklist(ctx, cidr, true) |
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.
instead of true and false pass hasBlocklistRangeSupport
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.
pass it where ?
We would still need to parse and loop through the range in this layer.
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.
instead of passing true to addCephBlocklist
pass hasBlocklistRangeSupport
if err == nil { | ||
continue | ||
} | ||
if !strings.Contains(err.Error(), "invalid command") { |
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.
define const of invalid command
@Rakshith-R planning to backport this to 3.7? |
This commit adds blocklist range cmd feature, while fallbacks to old blocklist one ip at a time if the cmd is invalid(not available). Signed-off-by: Rakshith R <[email protected]>
082dba4
to
3a5f29d
Compare
yes |
/retest all skipping e2e, since we dont have any for networkfence |
/retest all |
This commit adds blocklist range cmd feature,
while fallbacks to old blocklist one ip at a
time if the cmd is invalid(not available).
Signed-off-by: Rakshith R [email protected]