-
Notifications
You must be signed in to change notification settings - Fork 917
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
Avoid treating PVC managed by VolumeClaimTemplate as dependencies #5568
Conversation
Welcome @jklaw90! It looks like this is your first PR to karmada-io/karmada 🎉 |
46eccf1
to
106eb02
Compare
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #5568 +/- ##
==========================================
+ Coverage 35.19% 35.21% +0.02%
==========================================
Files 645 645
Lines 44869 44885 +16
==========================================
+ Hits 15791 15808 +17
Misses 27846 27846
+ Partials 1232 1231 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
cc @XiShanYongYe-Chang for help |
Thanks @jklaw90 |
Hi @jklaw90 Do you know how to get the correct pvc name from podTemplate? |
Hi @XiShanYongYe-Chang |
You're right, we cannot obtain the PVC name directly from the StatefulSet, as it also needs to be combined with the pod's index. Therefore, the current method of obtaining the dependent PVC name is incorrect. Provide the Pod's YAML information here: apiVersion: v1
kind: Pod
metadata:
generateName: web-
labels:
app: nginx
apps.kubernetes.io/pod-index: "0"
controller-revision-hash: web-59cfccf6c
statefulset.kubernetes.io/pod-name: web-0
name: web-0
namespace: default
ownerReferences:
- apiVersion: apps/v1
blockOwnerDeletion: true
controller: true
kind: StatefulSet
name: web
uid: 13e01c3d-4c7e-4d3a-8611-a0b41dd30be9
spec:
containers:
- image: registry.k8s.io/nginx-slim:0.24
imagePullPolicy: IfNotPresent
name: nginx
ports:
- containerPort: 80
name: web
protocol: TCP
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /usr/share/nginx/html
name: www
dnsPolicy: ClusterFirst
enableServiceLinks: true
hostname: web-0
preemptionPolicy: PreemptLowerPriority
priority: 0
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
serviceAccount: default
serviceAccountName: default
subdomain: nginx
terminationGracePeriodSeconds: 10
volumes:
- name: www
persistentVolumeClaim:
claimName: www-web-0 |
Hi @jklaw90 how are you currently obtaining the dependent PVC, or is it also not being obtained? |
It's not being obtained currently. I assumed getPodDependencies would handle this for pods? |
The |
We could use replicas and StatefulSet name with the claim template to derive pvc names. I think we'd have to query all the pvcs in the namespace to know with 100% certainty. (which is how i'm using it, with this function) |
For the sts resource, according to the template provided by you, when it is distributed to the member cluster, the pvc resource is automatically created. Therefore, there is no need to determine the pvc resource that the sts resource follows and distribute it. Hi @jklaw90, this seems to depend on whether the .spec.volumeClaimTemplates field is defined in the template with sts. If I remove this filed in the sts, the generated pod will looks like this: |
if you remove the template then that PVC should be a dependency. |
Should we execute different logic depending on whether .spec.volumeClaimTemplates exists or not? |
Oh @jklaw90 thanks, I get you, you are right. |
c7c920e
to
b0c0c73
Compare
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.
Thanks~
/lgtm
/cc @RainbowMango
/retitle Avoid treating PVC managed by VolumeClaimTemplate as dependencies |
b0c0c73
to
bdf234a
Compare
@jklaw90 Could you please squash your commits? Then things will be all set. |
bdf234a
to
dbc9318
Compare
@RainbowMango i've been having some issues with |
809874a
to
b4bfaa3
Compare
Co-authored-by: yelshall <[email protected]> Signed-off-by: Julian Lawrence <[email protected]>
No worries. The test |
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.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: RainbowMango 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 |
Hi @jklaw90 @RainbowMango do you think we need to rebase this commit to the previous branch? |
I guess you mean if we need to backport this PR to release branches. I think we can do it although it's not a critical bug fix, as I don't see any risk with it. |
yeah, next release is fine for us. |
…-upstream-release-1.11 Automated cherry pick of #5568: Avoid treating PVC managed by VolumeClaimTemplate as dependencies
…-upstream-release-1.10 Automated cherry pick of #5568: Avoid treating PVC managed by VolumeClaimTemplate as dependencies
…-upstream-release-1.9 Automated cherry pick of #5568: Avoid treating PVC managed by VolumeClaimTemplate as dependencies
What type of PR is this?
/kind bug
What this PR does / why we need it:
It was incorrectly handling PVCs when it belongs to the StatefulSet VolumeClaimTemplates.
If you set the claim name in the to match the StatefulSet VolumeClaimTemplate the StatefulSet controller would replace it for the pod, so the name isn't a backed by a real pvc.
create the following statefulset, and note the pod created has a claim with name
www-web-0
Which issue(s) this PR fixes:
Fixes # n/a
Special notes for your reviewer:
Does this PR introduce a user-facing change?: