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

Support of read only mount of filesystem volumes added #2365

Merged
merged 4 commits into from
Oct 17, 2023

Conversation

k0taperk0t
Copy link
Contributor

@k0taperk0t k0taperk0t commented Sep 29, 2023

Change Overview

This PR adds support of read-only mount required by Ceph-CSI shallow volumes feature, only for filesystem volumes.

PR series:

Pull request type

Please check the type of change your PR introduces:

  • 🚧 Work in Progress
  • 🌈 Refactoring (no functional changes, no api changes)
  • 🐹 Trivial/Minor
  • 🐛 Bugfix
  • 🌻 Feature
  • 🗺️ Documentation
  • 🤖 Test

Issues

Test Plan

  • 💪 Manual
  • ⚡ Unit test
  • 💚 E2E

@k0taperk0t
Copy link
Contributor Author

I agree to the DCO for all the commits in this PR.

@k0taperk0t k0taperk0t marked this pull request as ready for review September 29, 2023 14:13
.gitignore Outdated Show resolved Hide resolved
pkg/kube/job.go Show resolved Hide resolved
pkg/kube/job.go Outdated Show resolved Hide resolved
pkg/kube/pod.go Outdated Show resolved Hide resolved
@k0taperk0t
Copy link
Contributor Author

k0taperk0t commented Oct 13, 2023

These changes needed for adding support of Ceph-CSI shallow volumes.
TL;DR; To support Ceph-CSI shallow volumes feature, we need to mount snapshot (temp PVC, which has snapshot as source) in ReadOnlyMany mode, then using of Ceph-CSI shallow volumes will be possible.

pkg/controllers/repositoryserver/utils.go Outdated Show resolved Hide resolved
pkg/function/copy_volume_data.go Outdated Show resolved Hide resolved
pkg/function/prepare_data.go Outdated Show resolved Hide resolved
pkg/function/restore_data.go Outdated Show resolved Hide resolved
pkg/function/restore_data_using_kopia_server.go Outdated Show resolved Hide resolved
pkg/kube/job.go Outdated Show resolved Hide resolved
pkg/kube/job.go Outdated Show resolved Hide resolved
pkg/kube/utils.go Outdated Show resolved Hide resolved
pkg/kube/utils.go Outdated Show resolved Hide resolved
pkg/kube/pod.go Outdated Show resolved Hide resolved
pkg/controllers/repositoryserver/utils.go Show resolved Hide resolved
Signed-off-by: Sergey Aksenov <sergey.aksenov@veeam.com>
Signed-off-by: Sergey Aksenov <sergey.aksenov@veeam.com>
@k0taperk0t k0taperk0t force-pushed the read-only-volume-mount-support branch from fa335cd to 2178d7f Compare October 16, 2023 09:52
@k0taperk0t k0taperk0t changed the title Read only volume mount support Support of read only mount of filesystem volumes added Oct 16, 2023
Signed-off-by: Sergey Aksenov <sergey.aksenov@veeam.com>
@k0taperk0t
Copy link
Contributor Author

@viveksinghggits please continue review

Comment on lines +118 to +127
validatedVols := make(map[string]kube.VolumeMountOptions)
for pvcName, mountPoint := range vols {
pvc, err := cli.CoreV1().PersistentVolumeClaims(namespace).Get(ctx, pvcName, metav1.GetOptions{})
if err != nil {
return nil, errors.Wrapf(err, "Failed to retrieve PVC. Namespace %s, Name %s", namespace, pvcName)
}

validatedVols[pvcName] = kube.VolumeMountOptions{
MountPath: mountPoint,
ReadOnly: kube.PVCContainsReadOnlyAccessMode(pvc),
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is duplicate of code from, maybe it worth to extract it and reuse ?

Copy link
Contributor Author

@k0taperk0t k0taperk0t Oct 17, 2023

Choose a reason for hiding this comment

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

I'm afraid it's too late to push another commits for this review. But I can prepare another PR with refactoring if it's crucial to fix.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not crucial, I was too late :D We can refactor this piece of code next time.

Comment on lines +187 to +197
validatedVols := make(map[string]kube.VolumeMountOptions)
// Validate volumes
for pvcName, mountPoint := range vols {
pvc, err := cli.CoreV1().PersistentVolumeClaims(namespace).Get(ctx, pvcName, metav1.GetOptions{})
if err != nil {
return nil, errors.Wrapf(err, "Failed to retrieve PVC. Namespace %s, Name %s", namespace, pvcName)
}

validatedVols[pvcName] = kube.VolumeMountOptions{
MountPath: mountPoint,
ReadOnly: kube.PVCContainsReadOnlyAccessMode(pvc),
Copy link
Contributor

Choose a reason for hiding this comment

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

The same is here.

clientset kubernetes.Interface
}

// NewJob creates a new Job object.
func NewJob(clientset kubernetes.Interface, jobName string, namespace string, serviceAccount string, image string, vols map[string]string, command ...string) (*Job, error) {
func NewJob(clientset kubernetes.Interface,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func NewJob(clientset kubernetes.Interface,
func NewJob(
clientset kubernetes.Interface,

@mergify mergify bot merged commit c5432c7 into kanisterio:master Oct 17, 2023
14 checks passed
@k0taperk0t k0taperk0t deleted the read-only-volume-mount-support branch October 17, 2023 16:15
leuyentran pushed a commit that referenced this pull request Oct 18, 2023
* Support of read only mount added

Signed-off-by: Sergey Aksenov <sergey.aksenov@veeam.com>

* review comments fixed

Signed-off-by: Sergey Aksenov <sergey.aksenov@veeam.com>

* renamings regarding review comments

Signed-off-by: Sergey Aksenov <sergey.aksenov@veeam.com>

---------

Signed-off-by: Sergey Aksenov <sergey.aksenov@veeam.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support of Ceph-CSI shallow volumes
4 participants