-
Notifications
You must be signed in to change notification settings - Fork 819
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
Introduced flag to specify when sts deleted, pvc's behavious #4759
base: master
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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 |
fdd4571
to
ebcf41d
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #4759 +/- ##
==========================================
- Coverage 51.81% 51.78% -0.03%
==========================================
Files 250 250
Lines 24983 24991 +8
==========================================
- Hits 12944 12942 -2
- Misses 11330 11340 +10
Partials 709 709
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
ebcf41d
to
0915630
Compare
pkg/karmadactl/cmdinit/cmdinit.go
Outdated
flags.StringVarP(&opts.EtcdImage, "etcd-image", "", "", "etcd image") | ||
flags.StringVarP(&opts.EtcdInitImage, "etcd-init-image", "", kubernetes.DefaultInitImage, "etcd init container image") | ||
flags.Int32VarP(&opts.EtcdReplicas, "etcd-replicas", "", 1, "etcd replica set, cluster 3,5...singular") | ||
flags.StringVarP(&opts.EtcdHostDataPath, "etcd-data", "", "/var/lib/karmada-etcd", "etcd data path,valid in hostPath mode.") | ||
flags.StringVarP(&opts.EtcdNodeSelectorLabels, "etcd-node-selector-labels", "", "", "etcd pod select the labels of the node. valid in hostPath mode ( e.g. --etcd-node-selector-labels karmada.io/etcd=true)") | ||
flags.StringVarP(&opts.EtcdPersistentVolumeSize, "etcd-pvc-size", "", "5Gi", "etcd data path,valid in pvc mode.") | ||
flags.StringVarP(&opts.EtcdStsPvcDeletePolicy, "etcd-sts-pvc-delete-policy", "", "Retain", fmt.Sprintf("(%s). retain or delete pvc when their stateful set is deleted. Retain, need k8s >= v1.27", strings.Join(kubernetes.SupportedPvcRetentionPolicyType().List(), ","))) |
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.
Hi @chaosi-zju @prodanlabs @liangyuanpeng @RainbowMango How do you think this new flag?
@@ -733,6 +735,11 @@ func generateServerURL(serverIP string, nodePort int32) (string, error) { | |||
} | |||
|
|||
// SupportedStorageMode Return install etcd supported storage mode | |||
func SupportedStorageMode() []string { | |||
return []string{etcdStorageModeEmptyDir, etcdStorageModeHostPath, etcdStorageModePVC} | |||
func SupportedStorageMode() sets.String { |
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.
set.String is deprecated, how about use sets.Set[string]
to replace it?
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.
how about use sets.Set[string] to replace it?
ok
if i.EtcdStsPvcDeletePolicy == string(appsv1.DeletePersistentVolumeClaimRetentionPolicyType) { | ||
stsPvcRetentionPolicy = &appsv1.StatefulSetPersistentVolumeClaimRetentionPolicy{ | ||
WhenDeleted: appsv1.DeletePersistentVolumeClaimRetentionPolicyType, | ||
WhenScaled: appsv1.RetainPersistentVolumeClaimRetentionPolicyType, |
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.
I have a question, I don't understand why this is set up.
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.
why this is set up.
Default policy is appsv1.RetainPersistentVolumeClaimRetentionPolicyType; if set flag, WhenDeleted value shoule be set to appsv1.DeletePersistentVolumeClaimRetentionPolicyType
…behavious Signed-off-by: chang.qiangqiang <chang.qiangqiang@immomo.com>
0915630
to
e5f0662
Compare
flags.StringVarP(&opts.EtcdImage, "etcd-image", "", "", "etcd image") | ||
flags.StringVarP(&opts.EtcdInitImage, "etcd-init-image", "", kubernetes.DefaultInitImage, "etcd init container image") | ||
flags.Int32VarP(&opts.EtcdReplicas, "etcd-replicas", "", 1, "etcd replica set, cluster 3,5...singular") | ||
flags.StringVarP(&opts.EtcdHostDataPath, "etcd-data", "", "/var/lib/karmada-etcd", "etcd data path,valid in hostPath mode.") | ||
flags.StringVarP(&opts.EtcdNodeSelectorLabels, "etcd-node-selector-labels", "", "", "etcd pod select the labels of the node. valid in hostPath mode ( e.g. --etcd-node-selector-labels karmada.io/etcd=true)") | ||
flags.StringVarP(&opts.EtcdPersistentVolumeSize, "etcd-pvc-size", "", "5Gi", "etcd data path,valid in pvc mode.") | ||
flags.StringVarP(&opts.EtcdStsPvcDeletePolicy, "etcd-sts-pvc-delete-policy", "", "Retain", fmt.Sprintf("(%s). retain or delete pvc when their stateful set is deleted. Retain, need k8s >= v1.27", strings.Join(kubernetes.SupportedPvcRetentionPolicyType().UnsortedList(), ","))) |
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.
Can we directly provide two flags to set the WhenDeleted
and WhenScaled
rotation policy type respectively without processing an extra layer and changing the original meaning?
What should we do with these flags for Kubernetes versions prior to v1.26? |
patch ovnerreference to pvc metedata |
Sorry, let me rephrase my question. If the version of karmada-apiserver is before 1.27, will the current change have no effect or will it cause the etcd statefulset to report an error? |
sts has no field spec.persistentVolumeClaimRetentionPolicy, so sts can't be created and report an error |
This behavior may not be expected as we allow the user to set the version of the apiserver: karmada/pkg/karmadactl/cmdinit/cmdinit.go Line 121 in 456d099
We may need to add some judgment logic. |
What type of PR is this?
/kind bug
What this PR does / why we need it:
Introduced flag to specify when sts deleted, pvc's behavious
Which issue(s) this PR fixes:
Fixes #4750
Special notes for your reviewer:
Does this PR introduce a user-facing change?: