mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-08 03:33:56 +00:00
Added a comment about the reasoning.
This commit is contained in:
parent
bcddb157e4
commit
ae03433a70
@ -173,8 +173,18 @@ var _ = framework.KubeDescribe("[Feature:Federation]", func() {
|
|||||||
|
|
||||||
service = createServiceOrFail(f.FederationClientset_1_5, nsName, FederatedServiceName)
|
service = createServiceOrFail(f.FederationClientset_1_5, nsName, FederatedServiceName)
|
||||||
obj, err := conversion.NewCloner().DeepCopy(service)
|
obj, err := conversion.NewCloner().DeepCopy(service)
|
||||||
// Cloning shouldn't fail. On the off-chance it does, we should
|
// Cloning shouldn't fail. On the off-chance it does, we
|
||||||
// shallow copy service to serviceShard before failing.
|
// should shallow copy service to serviceShard before
|
||||||
|
// failing. If we don't do this we will never really
|
||||||
|
// get a chance to clean up the underlying services
|
||||||
|
// when the cloner fails for reasons not in our
|
||||||
|
// control. For example, cloner bug. That will cause
|
||||||
|
// the resources to leak, which in turn causes the
|
||||||
|
// test project to run out of quota and the entire
|
||||||
|
// suite starts failing. So we must try as hard as
|
||||||
|
// possible to cleanup the underlying services. So
|
||||||
|
// if DeepCopy fails, we are going to try with shallow
|
||||||
|
// copy as a last resort.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
serviceCopy := *service
|
serviceCopy := *service
|
||||||
serviceShard = &serviceCopy
|
serviceShard = &serviceCopy
|
||||||
@ -182,6 +192,8 @@ var _ = framework.KubeDescribe("[Feature:Federation]", func() {
|
|||||||
}
|
}
|
||||||
var ok bool
|
var ok bool
|
||||||
serviceShard, ok = obj.(*v1.Service)
|
serviceShard, ok = obj.(*v1.Service)
|
||||||
|
// Same argument as above about using shallow copy
|
||||||
|
// as a last resort.
|
||||||
if !ok {
|
if !ok {
|
||||||
serviceCopy := *service
|
serviceCopy := *service
|
||||||
serviceShard = &serviceCopy
|
serviceShard = &serviceCopy
|
||||||
|
Loading…
Reference in New Issue
Block a user