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

[KO-327] - Updating read and write quotas in cluster. #281

Merged
merged 2 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions controllers/access_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,16 @@ func (roleCreate aerospikeRoleCreateUpdate) updateRole(
}
}

if role.ReadQuota != roleCreate.readQuota || role.WriteQuota != roleCreate.writeQuota {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add a test for this change.

Copy link
Collaborator

@sud82 sud82 Apr 1, 2024

Choose a reason for hiding this comment

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

Empty, then Setting, Re-setting

Copy link
Contributor Author

Choose a reason for hiding this comment

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

test is already there

if err := client.SetQuotas(
adminPolicy, roleCreate.name, roleCreate.readQuota, roleCreate.writeQuota,
); err != nil {
return fmt.Errorf(
"error setting quotas for role %s: %v", roleCreate.name, err,
)
}
}

logger.Info("Updated role", "role name", roleCreate.name)
recorder.Eventf(
aeroCluster, corev1.EventTypeNormal, "RoleUpdated",
Expand Down
84 changes: 80 additions & 4 deletions test/access_control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1903,6 +1903,8 @@ var _ = Describe(
"read-write.test",
"read-write-udf.test.users",
},
ReadQuota: 2,
WriteQuota: 2,
},
{
Name: "roleToDrop",
Expand Down Expand Up @@ -1971,6 +1973,82 @@ var _ = Describe(
)
Expect(err).ToNot(HaveOccurred())

By("DisableQuota")

accessControl = asdbv1.AerospikeAccessControlSpec{
Roles: []asdbv1.AerospikeRoleSpec{
{
Name: "profiler",
Privileges: []string{
"read-write.test",
"read-write-udf.test.users",
},
},
{
Name: "roleToDrop",
Privileges: []string{
"read-write.test",
"read-write-udf.test.users",
},
Whitelist: []string{
"8.8.0.0/16",
},
},
},
Users: []asdbv1.AerospikeUserSpec{
{
Name: "admin",
SecretName: authSecretName,
Roles: []string{
"sys-admin",
"user-admin",
},
},

{
Name: "profileUser",
SecretName: authSecretName,
Roles: []string{
"profiler",
"sys-admin",
},
},

{
Name: "userToDrop",
SecretName: authSecretName,
Roles: []string{
"profiler",
},
},
},
}

aerospikeConfigSpec, err = NewAerospikeConfSpec(latestImage)
if err != nil {
Fail(
fmt.Sprintf(
"Invalid Aerospike Config Spec: %v",
err,
),
)
}
if err = aerospikeConfigSpec.setEnableSecurity(true); err != nil {
Expect(err).ToNot(HaveOccurred())
}
if err = aerospikeConfigSpec.setEnableQuotas(false); err != nil {
Expect(err).ToNot(HaveOccurred())
}

aeroCluster = getAerospikeClusterSpecWithAccessControl(
clusterNamespacedName, &accessControl,
aerospikeConfigSpec,
)
err = testAccessControlReconcile(
aeroCluster, ctx,
)
Expect(err).ToNot(HaveOccurred())

By("QuotaParamsSpecifiedButFlagIsOff")

accessControl = asdbv1.AerospikeAccessControlSpec{
Expand Down Expand Up @@ -2154,12 +2232,10 @@ func validateAccessControl(

err = validateRoles(clientP, &aeroCluster.Spec)
if err != nil {
return fmt.Errorf("error creating client: %v", err)
return fmt.Errorf("error validating roles: %v", err)
}

err = validateUsers(clientP, aeroCluster)

return err
return validateUsers(clientP, aeroCluster)
}

func getRole(
Expand Down
Loading