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

fix for synced pvs and retain SC #1723

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

facchettos
Copy link
Contributor

@facchettos facchettos commented Apr 29, 2024

What issue type does this pull request address? (keep at least one, remove the others)
/kind bugfix

What does this pull request do? Which issues does it resolve? (use resolves #<issue_number> if possible)
resolves #1464
resolves eng-2701

Please provide a short message that should be published in the vcluster release notes
Fixed an issue where vcluster would not make persistent volumes available when retain policy was set on the storage class.

What else do we need to know?
The PV syncing in the host->vcluster direction was not syncing at the right time because it was relying exclusively on claimrefs, but did not detect the claimref being deleted from the vcluster object, and thus was forcing it back onto it

Copy link

netlify bot commented Apr 29, 2024

Deploy Preview for vcluster-docs canceled.

Built without sensitive environment variables

Name Link
🔨 Latest commit d9af0e5
🔍 Latest deploy log https://app.netlify.com/sites/vcluster-docs/deploys/66432bfdac4f9800083ca27d

Copy link
Member

@FabianKramm FabianKramm left a comment

Choose a reason for hiding this comment

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

we need to add tests for this before we can merge here, preferably multiple unit tests + an e2e test

@rohantmp
Copy link
Contributor

rohantmp commented May 3, 2024

Can do a review here (lmk if not necessary), could you write a brief description?

@FabianKramm
Copy link
Member

@facchettos your tests are failing, can you fix them?

@facchettos
Copy link
Contributor Author

@rohantmp @FabianKramm I know the tests are failing, didn't have time to do more before I left for my PTO :)

@facchettos facchettos force-pushed the pv-fix branch 3 times, most recently from 7422401 to ece23b9 Compare May 6, 2024 14:13
@heiko-braun heiko-braun requested a review from rohantmp May 7, 2024 08:11
@heiko-braun
Copy link
Contributor

@rohantmp make sense. please review it.

@FabianKramm
Copy link
Member

@facchettos since the test only takes a couple of seconds, I feel like a separate job is too much. Can we include it in an existing test suite?

if err != nil {
return ctrl.Result{}, err
}
if syncBack {
Copy link
Member

Choose a reason for hiding this comment

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

Why make a variable for this, can we not just put the condition here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought it was more readable this way, but I can change it if really needed

Copy link
Member

Choose a reason for hiding this comment

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

Yeah please change that

}

pPvc := &corev1.PersistentVolumeClaim{}
err = s.physicalClient.Get(ctx, types.NamespacedName{Namespace: pObj.Spec.ClaimRef.Namespace, Name: pObj.Spec.ClaimRef.Name}, pPvc)
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we validate here that the ClaimRef.Namespace actually matches the namespace we are working in as vCluster?

Copy link
Member

Choose a reason for hiding this comment

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

e.g. this could cause problematic errors if we cannot list in that namespace, which would make everything fail as a non not found error is thrown

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but isn't that what we want though? if the pv has a claimref with a pvc that we don't have access to, we don't own the pv

pkg/controllers/resources/persistentvolumes/translate.go Outdated Show resolved Hide resolved
@@ -124,6 +129,10 @@ func (s *persistentVolumeSyncer) translateUpdate(ctx context.Context, vPv *corev
}

translatedStorageClassName := translateStorageClass(vPv.Spec.StorageClassName)
if !s.useFakePersistentVolumes {
translatedStorageClassName = vPv.Spec.StorageClassName
Copy link
Member

Choose a reason for hiding this comment

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

Why is this necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because if we use real persistent volumes, they need to reference the proper storage class, for some reasons the storage class was updated to something different than the one at creation time when the persistent volume was updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PV with reclam policy can never be claimed again in vclusters
4 participants