-
Notifications
You must be signed in to change notification settings - Fork 61
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
feat(hostpath):enforce xfs quota on the hostpath #78
Conversation
fe648f5
to
1fd4435
Compare
Codecov Report
@@ Coverage Diff @@
## develop #78 +/- ##
===========================================
- Coverage 33.99% 33.49% -0.50%
===========================================
Files 29 29
Lines 2518 2618 +100
===========================================
+ Hits 856 877 +21
- Misses 1618 1697 +79
Partials 44 44
Continue to review full report at Codecov.
|
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.
@almas33 Given some comments for changes.
lastPid := "PID=`xfs_quota -x -c 'report -h' /data | tail -2 | awk 'NR==1{print substr ($1,2)}+0'` ;" | ||
newPid := "PID=`expr $PID + 1` ;" | ||
initializeProject := "xfs_quota -x -c 'project -s -p " + filepath.Join("/data/", config.volumeDir) + " '$PID /data ;" | ||
setQuota := "xfs_quota -x -c 'limit -p bsoft=" + config.bsoft + " bhard=" + config.bhard + " '$PID /data" |
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.
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.
Also in this way, if one commands fails then what's the point of running the subsequent commands. I feel rather than passing these commands like this better to create a shell script for all these commands(with proper error or successful logs) but still the logs in the pod won't be of much help as the pod will be deleted after few seconds and pass them as configmap volumes to the helper pod and execute the script. cc: @kmova @akhilerm .
7109615
to
e42f2be
Compare
bsoft := opts.StorageClass.Parameters[Bsoft] | ||
bhard := opts.StorageClass.Parameters[Bhard] | ||
|
||
podOpts := &HelperPodOptions{ | ||
name: name, | ||
path: path, | ||
nodeAffinityLabelKey: nodeAffinityKey, | ||
nodeAffinityLabelValue: nodeAffinityValue, | ||
serviceAccountName: saName, | ||
selectedNodeTaints: taints, | ||
imagePullSecrets: imagePullSecrets, | ||
bsoft: bsoft, | ||
bhard: bhard, | ||
} |
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.
All these can be performed outside of this if condition. If the fields are not filled by the user then they will remain empty. And for if condition you can check for:
bsoft := opts.StorageClass.Parameters[Bsoft] | |
bhard := opts.StorageClass.Parameters[Bhard] | |
podOpts := &HelperPodOptions{ | |
name: name, | |
path: path, | |
nodeAffinityLabelKey: nodeAffinityKey, | |
nodeAffinityLabelValue: nodeAffinityValue, | |
serviceAccountName: saName, | |
selectedNodeTaints: taints, | |
imagePullSecrets: imagePullSecrets, | |
bsoft: bsoft, | |
bhard: bhard, | |
} | |
if scType == "enforceXfsQuota" && (len(Bsoft) != 0 || len(Bhard) != 0) |
And then have proper error handling checks too.
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.
I don't think we should check like this if scType == "enforceXfsQuota" && (len(Bsoft) != 0 || len(Bhard) != 0)
because if user has given type enforceXfsQuota
that means he wants to set quota , then we should try to create quota pod , but while pod creation the error both limits can't be 0
will be displayed and it will fail but doing like the way you suggested there will be no error displayed
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.
If we want to remove redeclaration of podOpts
we can declare value of bsoft
and bhard
while sending it to helper pod , it will be empty anyways ( values are not provided in parameters )as variable is declared in podOpts
.
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.
@almas33 - it is quite possible to misconfigure the parameters or provide incorrect parameters by users - while they are learning how to use the solution. The code should handle this via:
- Sane defaults
- Catch errors
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.
@kmova - does that mean there will be some default limits applied if there is error in limits entered in parameter . Error handling of incorrect parameters are already taken care in convertToK()
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.
@almas33, let us get back to this comment after the changes suggested in the design doc for storage class parameters are updated. The validation will change.
e42f2be
to
5e9c64a
Compare
9530e83
to
1b00e61
Compare
The PR looks good to me. @kmova can you review it once. |
I'll try to add integration tests in the same PR. Or else, we can take that up in a separate PR. |
@almas33 Could you please rebase your branch with 'develop' once? Thanks. |
1b00e61
to
3efe43a
Compare
Initial implementation to enforce quota on the XFS volumes. - The feature is controlled by specifying the quota parameter in the StorageClass along with specifying the values for limits. Note: Additional PRs will be raised to refactor the implementation and add integration tests. Signed-off-by : Almas Ahmad <ahmadalmas.786.aa@gmail.com>
feat(hostpath):enforce xfs quota on the hostpath
Issue no. - #13
To test:-
almas33/openebs-pv
in place ofopenebs/provisioner-localpv
andalmas33/xfs-quota
in place ofopenebs/linux-utils
type:enforceXfsQuota
,bsoft
as soft limit andbhard
as hard limit in the parameters in storage class.yaml