这是indexloc提供的服务,不要输入任何密码
Skip to content

Enable Mount Propagation as a Optional Feature #15758

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

Merged
merged 5 commits into from
Apr 21, 2025

Conversation

elijah-rou
Copy link
Contributor

@elijah-rou elijah-rou commented Feb 7, 2025

Proposal: Feature-Gated Mount Propagation

At my org we use the JuiceFS filesystem internally, accessed through PVCs. In order to recover the mount point in case of a network drop, it is required that the pod set mountPropagation to HostToContainer or Bidirectional for the volumeMount to facilitate this functionality. Currently, Knative does not allow mountPropagation to be used. Since it's a feature that should have care when using, this proposal is to to add the ability to use Mount Propagation gated under an optional feature the user will have to enable explicitly. I have implemented this internally already, but think this could be useful to the broader community.

Add the ability to use mountPropagation for volumeMounts, gated under kubernetes.podspec-volumes-mount-propagation

Copy link

linux-foundation-easycla bot commented Feb 7, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@knative-prow knative-prow bot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Feb 7, 2025
Copy link

knative-prow bot commented Feb 7, 2025

Welcome @elijah-rou! It looks like this is your first PR to knative/serving 🎉

Copy link

knative-prow bot commented Feb 7, 2025

Hi @elijah-rou. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@knative-prow knative-prow bot requested review from dprotaso and skonto February 7, 2025 19:46
@dprotaso
Copy link
Member

dprotaso commented Feb 9, 2025

/ok-to-test

@knative-prow knative-prow bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 9, 2025
@dprotaso
Copy link
Member

dprotaso commented Feb 9, 2025

/lgtm
/approve

thanks for the change!

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Feb 9, 2025
Copy link

knative-prow bot commented Feb 9, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dprotaso, elijah-rou

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 9, 2025
@dprotaso
Copy link
Member

dprotaso commented Feb 9, 2025

please take a look at the unit test failure

@skonto
Copy link
Contributor

skonto commented Feb 10, 2025

In pkg/reconciler/route/resources/service_test.go pls add the corresponding flag.

@skonto
Copy link
Contributor

skonto commented Feb 10, 2025

As in #15669 pls add the right validation for this new flag. Also pls you will need to create some docs in knative/docs repo.

@skonto
Copy link
Contributor

skonto commented Feb 10, 2025

/hold

@knative-prow knative-prow bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 10, 2025
@elijah-rou
Copy link
Contributor Author

Will fix everything today :) docs PR will probably only come tomorrow

@elijah-rou
Copy link
Contributor Author

As in #15669 pls add the right validation for this new flag. Also pls you will need to create some docs in knative/docs repo.

Mostly done. Just one comment with this. What validation needs to be done? I don't believe there are specific restrictions using mountPropagation beyond specifying an appropriate mode (None, HostToContainer, Bidirectional), validation which should be taken care of by K8s

@elijah-rou elijah-rou force-pushed the feat/enable-mount-propagation branch from 0e846e1 to e943d8a Compare February 12, 2025 02:18
@knative-prow knative-prow bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Feb 12, 2025
@elijah-rou elijah-rou force-pushed the feat/enable-mount-propagation branch from e943d8a to 100ade5 Compare February 12, 2025 02:22
@skonto
Copy link
Contributor

skonto commented Feb 12, 2025

What validation needs to be done?

Fail when user uses the feature but the flag is disabled, for example for the hostPath we have:

	if volume.HostPath != nil && features.PodSpecVolumesHostPath != config.Enabled {
		errs = errs.Also(&apis.FieldError{Message: fmt.Sprintf("HostPath volume support is disabled, "+
			"but found HostPath volume %s", volume.Name)})
	}

There is more to it in the link.

@skonto
Copy link
Contributor

skonto commented Feb 12, 2025

I don't believe there are specific restrictions using mountPropagation beyond specifying an appropriate mode (None, HostToContainer, Bidirectional), validation which should be taken care of by K8s

There are actually see here, especially if we want to fail fast:


	if *mountPropagation == core.MountPropagationBidirectional && !privileged {
		allErrs = append(allErrs, field.Forbidden(fldPath, "Bidirectional mount propagation is available only to privileged containers"))
	}

...

if we add support for some other  flags there are more restrictions:

	case core.RecursiveReadOnlyEnabled, core.RecursiveReadOnlyIfPossible:
....
		if mount.MountPropagation != nil && *mount.MountPropagation != core.MountPropagationNone {
			allErrs = append(allErrs, field.Forbidden(fldPath, "may only be specified when mountPropagation is None or not specified"))
		}

@elijah-rou
Copy link
Contributor Author

I don't believe there are specific restrictions using mountPropagation beyond specifying an appropriate mode (None, HostToContainer, Bidirectional), validation which should be taken care of by K8s

There are actually see here, especially if we want to fail fast:


	if *mountPropagation == core.MountPropagationBidirectional && !privileged {
		allErrs = append(allErrs, field.Forbidden(fldPath, "Bidirectional mount propagation is available only to privileged containers"))
	}

...

if we add support for some other  flags there are more restrictions:

	case core.RecursiveReadOnlyEnabled, core.RecursiveReadOnlyIfPossible:
....
		if mount.MountPropagation != nil && *mount.MountPropagation != core.MountPropagationNone {
			allErrs = append(allErrs, field.Forbidden(fldPath, "may only be specified when mountPropagation is None or not specified"))
		}

Sorry, didn't realise about the privileged field. Will do it.

What validation needs to be done?

Fail when user uses the feature but the flag is disabled, for example for the hostPath we have:

	if volume.HostPath != nil && features.PodSpecVolumesHostPath != config.Enabled {
		errs = errs.Also(&apis.FieldError{Message: fmt.Sprintf("HostPath volume support is disabled, "+
			"but found HostPath volume %s", volume.Name)})
	}

There is more to it in the link.

Sure I'll get this done as well.

run update schema

add units

remove useless val tests

fix validation
@elijah-rou elijah-rou force-pushed the feat/enable-mount-propagation branch 4 times, most recently from 06c411c to e2b64ea Compare March 16, 2025 23:30
Copy link

codecov bot commented Mar 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.91%. Comparing base (ae7b265) to head (fcc25f9).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15758      +/-   ##
==========================================
- Coverage   80.94%   80.91%   -0.03%     
==========================================
  Files         210      210              
  Lines       16721    16739      +18     
==========================================
+ Hits        13535    13545      +10     
- Misses       2837     2842       +5     
- Partials      349      352       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dprotaso
Copy link
Member

closing and re-opening so we pick up changes in our linter config

@dprotaso dprotaso closed this Apr 14, 2025
@dprotaso dprotaso reopened this Apr 14, 2025
Copy link
Member

@dprotaso dprotaso left a comment

Choose a reason for hiding this comment

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

looks good just a minor lint issue about an unused variable

update checksum

fix unit tests; remove Bidirectional as a valid MountPropagation

fieldmask test uses hostToContainer

fix unused param
@elijah-rou elijah-rou force-pushed the feat/enable-mount-propagation branch from e2b64ea to a25fa18 Compare April 17, 2025 00:39
@dprotaso
Copy link
Member

There's a compile error

@dprotaso
Copy link
Member

/override "codecov"

it's fixed in main

Copy link

knative-prow bot commented Apr 18, 2025

@dprotaso: /override requires failed status contexts, check run or a prowjob name to operate on.
The following unknown contexts/checkruns were given:

  • codecov

Only the following failed contexts/checkruns were expected:

  • EasyCLA
  • License Compliance
  • build-tests_serving_main
  • codecov/project
  • istio-latest-no-mesh-tls_serving_main
  • istio-latest-no-mesh_serving_main
  • style / suggester / github_actions
  • style / suggester / shell
  • tide
  • unit-tests_serving_main
  • upgrade-tests_serving_main

If you are trying to override a checkrun that has a space in it, you must put a double quote on the context.

In response to this:

/override "codecov"

it's fixed in main

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@dprotaso
Copy link
Member

/override "codecov/project"

Copy link

knative-prow bot commented Apr 18, 2025

@dprotaso: Overrode contexts on behalf of dprotaso: codecov/project

In response to this:

/override "codecov/project"

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@dprotaso
Copy link
Member

I tweak the flag name to kubernetes.podspec-volumes-mount-propagation

@dprotaso
Copy link
Member

/hold cancel
/lgtm

@knative-prow knative-prow bot added lgtm Indicates that a PR is ready to be merged. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Apr 21, 2025
@knative-prow knative-prow bot merged commit 7f044f1 into knative:main Apr 21, 2025
68 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants