Commit 7df01780 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #42975 from smarterclayton/time_namespace

Automatic merge from submit-queue (batch tested with PRs 40234, 45885, 42975) Log how much time it takes e2e tests to clean up the namespace
parents faf556ec 7da310ea
...@@ -155,7 +155,9 @@ func (nm *NamespaceController) worker() { ...@@ -155,7 +155,9 @@ func (nm *NamespaceController) worker() {
// syncNamespaceFromKey looks for a namespace with the specified key in its store and synchronizes it // syncNamespaceFromKey looks for a namespace with the specified key in its store and synchronizes it
func (nm *NamespaceController) syncNamespaceFromKey(key string) (err error) { func (nm *NamespaceController) syncNamespaceFromKey(key string) (err error) {
startTime := time.Now() startTime := time.Now()
defer glog.V(4).Infof("Finished syncing namespace %q (%v)", key, time.Now().Sub(startTime)) defer func() {
glog.V(4).Infof("Finished syncing namespace %q (%v)", key, time.Now().Sub(startTime))
}()
namespace, err := nm.lister.Get(key) namespace, err := nm.lister.Get(key)
if errors.IsNotFound(err) { if errors.IsNotFound(err) {
...@@ -174,16 +176,14 @@ func (nm *NamespaceController) Run(workers int, stopCh <-chan struct{}) { ...@@ -174,16 +176,14 @@ func (nm *NamespaceController) Run(workers int, stopCh <-chan struct{}) {
defer utilruntime.HandleCrash() defer utilruntime.HandleCrash()
defer nm.queue.ShutDown() defer nm.queue.ShutDown()
glog.Info("Starting namespace controller")
defer glog.Infof("Shutting down namespace controller")
if !controller.WaitForCacheSync("namespace", stopCh, nm.listerSynced) { if !controller.WaitForCacheSync("namespace", stopCh, nm.listerSynced) {
return return
} }
glog.V(5).Info("Starting workers")
for i := 0; i < workers; i++ { for i := 0; i < workers; i++ {
go wait.Until(nm.worker, time.Second, stopCh) go wait.Until(nm.worker, time.Second, stopCh)
} }
<-stopCh <-stopCh
glog.V(1).Infof("Shutting down")
} }
...@@ -539,6 +539,7 @@ func doConfigMapE2EWithoutMappings(f *framework.Framework, uid, fsGroup int64, d ...@@ -539,6 +539,7 @@ func doConfigMapE2EWithoutMappings(f *framework.Framework, uid, fsGroup int64, d
framework.Failf("unable to create test configMap %s: %v", configMap.Name, err) framework.Failf("unable to create test configMap %s: %v", configMap.Name, err)
} }
one := int64(1)
pod := &v1.Pod{ pod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "pod-configmaps-" + string(uuid.NewUUID()), Name: "pod-configmaps-" + string(uuid.NewUUID()),
...@@ -572,7 +573,8 @@ func doConfigMapE2EWithoutMappings(f *framework.Framework, uid, fsGroup int64, d ...@@ -572,7 +573,8 @@ func doConfigMapE2EWithoutMappings(f *framework.Framework, uid, fsGroup int64, d
}, },
}, },
}, },
RestartPolicy: v1.RestartPolicyNever, RestartPolicy: v1.RestartPolicyNever,
TerminationGracePeriodSeconds: &one,
}, },
} }
...@@ -617,6 +619,7 @@ func doConfigMapE2EWithMappings(f *framework.Framework, uid, fsGroup int64, item ...@@ -617,6 +619,7 @@ func doConfigMapE2EWithMappings(f *framework.Framework, uid, fsGroup int64, item
framework.Failf("unable to create test configMap %s: %v", configMap.Name, err) framework.Failf("unable to create test configMap %s: %v", configMap.Name, err)
} }
one := int64(1)
pod := &v1.Pod{ pod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "pod-configmaps-" + string(uuid.NewUUID()), Name: "pod-configmaps-" + string(uuid.NewUUID()),
...@@ -656,7 +659,8 @@ func doConfigMapE2EWithMappings(f *framework.Framework, uid, fsGroup int64, item ...@@ -656,7 +659,8 @@ func doConfigMapE2EWithMappings(f *framework.Framework, uid, fsGroup int64, item
}, },
}, },
}, },
RestartPolicy: v1.RestartPolicyNever, RestartPolicy: v1.RestartPolicyNever,
TerminationGracePeriodSeconds: &one,
}, },
} }
......
...@@ -71,6 +71,7 @@ const testContainerName = "test-container" ...@@ -71,6 +71,7 @@ const testContainerName = "test-container"
func entrypointTestPod() *v1.Pod { func entrypointTestPod() *v1.Pod {
podName := "client-containers-" + string(uuid.NewUUID()) podName := "client-containers-" + string(uuid.NewUUID())
one := int64(1)
return &v1.Pod{ return &v1.Pod{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: podName, Name: podName,
...@@ -82,7 +83,8 @@ func entrypointTestPod() *v1.Pod { ...@@ -82,7 +83,8 @@ func entrypointTestPod() *v1.Pod {
Image: "gcr.io/google_containers/eptest:0.1", Image: "gcr.io/google_containers/eptest:0.1",
}, },
}, },
RestartPolicy: v1.RestartPolicyNever, RestartPolicy: v1.RestartPolicyNever,
TerminationGracePeriodSeconds: &one,
}, },
} }
} }
...@@ -958,12 +958,13 @@ func CheckTestingNSDeletedExcept(c clientset.Interface, skip string) error { ...@@ -958,12 +958,13 @@ func CheckTestingNSDeletedExcept(c clientset.Interface, skip string) error {
// deleteNS deletes the provided namespace, waits for it to be completely deleted, and then checks // deleteNS deletes the provided namespace, waits for it to be completely deleted, and then checks
// whether there are any pods remaining in a non-terminating state. // whether there are any pods remaining in a non-terminating state.
func deleteNS(c clientset.Interface, clientPool dynamic.ClientPool, namespace string, timeout time.Duration) error { func deleteNS(c clientset.Interface, clientPool dynamic.ClientPool, namespace string, timeout time.Duration) error {
startTime := time.Now()
if err := c.Core().Namespaces().Delete(namespace, nil); err != nil { if err := c.Core().Namespaces().Delete(namespace, nil); err != nil {
return err return err
} }
// wait for namespace to delete or timeout. // wait for namespace to delete or timeout.
err := wait.PollImmediate(5*time.Second, timeout, func() (bool, error) { err := wait.PollImmediate(2*time.Second, timeout, func() (bool, error) {
if _, err := c.Core().Namespaces().Get(namespace, metav1.GetOptions{}); err != nil { if _, err := c.Core().Namespaces().Get(namespace, metav1.GetOptions{}); err != nil {
if apierrs.IsNotFound(err) { if apierrs.IsNotFound(err) {
return true, nil return true, nil
...@@ -1011,6 +1012,7 @@ func deleteNS(c clientset.Interface, clientPool dynamic.ClientPool, namespace st ...@@ -1011,6 +1012,7 @@ func deleteNS(c clientset.Interface, clientPool dynamic.ClientPool, namespace st
// no remaining content, but namespace was not deleted (namespace controller is probably wedged) // no remaining content, but namespace was not deleted (namespace controller is probably wedged)
return fmt.Errorf("namespace %v was not deleted with limit: %v, namespace is empty but is not yet removed", namespace, err) return fmt.Errorf("namespace %v was not deleted with limit: %v, namespace is empty but is not yet removed", namespace, err)
} }
Logf("namespace %v deletion completed in %s", namespace, time.Now().Sub(startTime))
return nil return nil
} }
......
...@@ -494,6 +494,7 @@ func (config *RCConfig) create() error { ...@@ -494,6 +494,7 @@ func (config *RCConfig) create() error {
if config.DNSPolicy == nil { if config.DNSPolicy == nil {
config.DNSPolicy = &dnsDefault config.DNSPolicy = &dnsDefault
} }
one := int64(1)
rc := &v1.ReplicationController{ rc := &v1.ReplicationController{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: config.Name, Name: config.Name,
...@@ -517,8 +518,9 @@ func (config *RCConfig) create() error { ...@@ -517,8 +518,9 @@ func (config *RCConfig) create() error {
ReadinessProbe: config.ReadinessProbe, ReadinessProbe: config.ReadinessProbe,
}, },
}, },
DNSPolicy: *config.DNSPolicy, DNSPolicy: *config.DNSPolicy,
NodeSelector: config.NodeSelector, NodeSelector: config.NodeSelector,
TerminationGracePeriodSeconds: &one,
}, },
}, },
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment