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

Add support for repeated PVC-claim but using subPath in AA-validation #3091

Conversation

jlpettersson
Copy link
Member

Changes

The validation for compatibility with the Affinity Assistant does not
support the same PVC repeated, but using different subPaths.

This patch adds support for this case.

Closes #3085
/kind bug

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

  • Includes tests (if functionality changed/added)
  • Includes docs (if user facing)
  • Commit messages follow commit message best practices
  • Release notes block has been filled in or deleted (only if no user facing changes)

See the contribution guide for more details.

Double check this list of stuff that's easy to miss:

Reviewer Notes

If API changes are included, additive changes must be approved by at least two OWNERS and backwards incompatible changes must be approved by more than 50% of the OWNERS, and they must first be added in a backwards compatible way.

Release Notes

Fixes a bug with validation for the Affinity Assistant when the same PVC is used for
multiple workspaces but with different subPaths

The validation for compatibility with the Affinity Assistant does not
support the same PVC repeated, but using different subPaths.

This patch adds support for this case.
@tekton-robot tekton-robot added kind/bug Categorizes issue or PR as related to a bug. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Aug 11, 2020
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign bobcatfish
You can assign the PR to them by writing /assign @bobcatfish in a comment when ready.

The full list of commands accepted by this bot can be found 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

@tekton-robot tekton-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Aug 11, 2020
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/taskrun/taskrun.go 78.3% 78.4% 0.1

@jlpettersson jlpettersson marked this pull request as draft August 11, 2020 19:30
@jlpettersson
Copy link
Member Author

jlpettersson commented Aug 11, 2020

I'll leave this as a draft for now - since I have not implemented any test case for this case. I feel it is a bit heavy to add a complete new test case for this case - so the test may need refactoring. Feel free to add test case if anyone feel this fix is in hurry.

@bitsofinfo
Copy link

bitsofinfo commented Aug 12, 2020

will take it with or without a test! :) don't want to be stuck in 0.14.3, haha

@ghost
Copy link

ghost commented Aug 12, 2020

I'll leave this as a draft for now - since I have not implemented any test case for this case. I feel it is a bit heavy to add a complete new test case for this case - so the test may need refactoring. Feel free to add test case if anyone feel this fix is in hurry.

My suggestion would be to move the validation bit into pkg/workspace/validate.go and move the annotation check into the prepare() func of the reconciler. So that would look something like this:

	// pkg/reconciler/taskrun/taskrun.go
	// after workspace.ValidateBindings() is called in prepare()
	_, isAssociatedWithAnAffinityAssistant := tr.Annotations[workspace.AnnotationAffinityAssistantName]
	if isAssociatedWithAnAffinityAssistant {
		if err := workspace.ValidateOnlyOnePVCBindingUsed(tr.Spec.Workspaces); err != nil {
			logger.Errorf("TaskRun %q workspaces are invalid: %v", tr.Name, err)
			tr.Status.MarkResourceFailed(podconvert.ReasonFailedValidation, err)
			return nil, nil, controller.NewPermanentError(err)
		}
	}
// pkg/workspace/validate.go
func ValidateOnlyOnePVCBindingUsed(wbs []v1beta1.WorkspaceBinding) error {
	workspaceVolumes := make(map[string]bool)
	for _, w := range wbs {
		if w.PersistentVolumeClaim != nil {
			workspaceVolumes[w.PersistentVolumeClaim.ClaimName] = true
		}
		if w.VolumeClaimTemplate != nil {
			workspaceVolumes[w.Name] = true
		}
	}

	if len(workspaceVolumes) > 1 {
		return fmt.Errorf("TaskRun mounts more than one ...") // cut for brevity
	}
	return nil
}

Then ValidateOnlyOnePVCBindingUsed can be tested in isolation in pkg/workspace/validate_test.go. @jlpettersson are you happy with this suggestion? I can implement it and push to this PR tomorrow if you agree with the direction.

@jlpettersson
Copy link
Member Author

@sbwsg sounds good to me

@ghost
Copy link

ghost commented Aug 13, 2020

Updated as described and opened #3099

@ghost ghost closed this Aug 13, 2020
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0.15.0: "TaskRun mounts more than one PersistentVolumeClaim" despite single PVC w/ workspace subDirs
3 participants