mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 12:18:16 +00:00 
			
		
		
		
	Merge pull request #36022 from janetkuo/statefulset-e2e-hostname
Automatic merge from submit-queue StatefulSet e2e: verify stateful pod hostname cc @erictune @foxish @kubernetes/sig-apps
This commit is contained in:
		@@ -125,11 +125,14 @@ var _ = framework.KubeDescribe("StatefulSet [Slow] [Feature:PetSet]", func() {
 | 
				
			|||||||
			By("Verifying statefulset mounted data directory is usable")
 | 
								By("Verifying statefulset mounted data directory is usable")
 | 
				
			||||||
			ExpectNoError(pst.checkMount(ps, "/data"))
 | 
								ExpectNoError(pst.checkMount(ps, "/data"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								By("Verifying statefulset provides a stable hostname for each pod")
 | 
				
			||||||
 | 
								ExpectNoError(pst.checkHostname(ps))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			cmd := "echo $(hostname) > /data/hostname; sync;"
 | 
								cmd := "echo $(hostname) > /data/hostname; sync;"
 | 
				
			||||||
			By("Running " + cmd + " in all pets")
 | 
								By("Running " + cmd + " in all pets")
 | 
				
			||||||
			ExpectNoError(pst.execInPets(ps, cmd))
 | 
								ExpectNoError(pst.execInPets(ps, cmd))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			By("Restarting pet set " + ps.Name)
 | 
								By("Restarting statefulset " + ps.Name)
 | 
				
			||||||
			pst.restart(ps)
 | 
								pst.restart(ps)
 | 
				
			||||||
			pst.saturate(ps)
 | 
								pst.saturate(ps)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -572,6 +575,20 @@ func (p *statefulSetTester) execInPets(ps *apps.StatefulSet, cmd string) error {
 | 
				
			|||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (p *statefulSetTester) checkHostname(ps *apps.StatefulSet) error {
 | 
				
			||||||
 | 
						cmd := "printf $(hostname)"
 | 
				
			||||||
 | 
						podList := p.getPodList(ps)
 | 
				
			||||||
 | 
						for _, pet := range podList.Items {
 | 
				
			||||||
 | 
							hostname, err := framework.RunHostCmd(pet.Namespace, pet.Name, cmd)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if hostname != pet.Name {
 | 
				
			||||||
 | 
								return fmt.Errorf("unexpected hostname (%s) and stateful pod name (%s) not equal", hostname, pet.Name)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
func (p *statefulSetTester) saturate(ps *apps.StatefulSet) {
 | 
					func (p *statefulSetTester) saturate(ps *apps.StatefulSet) {
 | 
				
			||||||
	// TODO: Watch events and check that creation timestamps don't overlap
 | 
						// TODO: Watch events and check that creation timestamps don't overlap
 | 
				
			||||||
	var i int32
 | 
						var i int32
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user