Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Commit

Permalink
E2E: actually fail when no InternalIP, ssh master tweaks, delete retr…
Browse files Browse the repository at this point in the history
…ies (#3982)
  • Loading branch information
jackfrancis authored Oct 10, 2018
1 parent 7b7e997 commit 2841bc9
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 145 deletions.
39 changes: 26 additions & 13 deletions test/e2e/kubernetes/deployment/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,23 +134,36 @@ func Get(name, namespace string) (*Deployment, error) {
}

// Delete will delete a deployment in a given namespace
func (d *Deployment) Delete() error {
cmd := exec.Command("kubectl", "delete", "deploy", "-n", d.Metadata.Namespace, d.Metadata.Name)
out, err := util.RunAndLogCommand(cmd)
if err != nil {
log.Printf("Error while trying to delete deployment %s in namespace %s:%s\n", d.Metadata.Namespace, d.Metadata.Name, string(out))
return err
func (d *Deployment) Delete(retries int) error {
var kubectlOutput []byte
var kubectlError error
for i := 0; i < retries; i++ {
cmd := exec.Command("kubectl", "delete", "deploy", "-n", d.Metadata.Namespace, d.Metadata.Name)
kubectlOutput, kubectlError = util.RunAndLogCommand(cmd)
if kubectlError != nil {
log.Printf("Error while trying to delete deployment %s in namespace %s:%s\n", d.Metadata.Namespace, d.Metadata.Name, string(kubectlOutput))
continue
}
break
}

if kubectlError != nil {
return kubectlError
}
// Delete any associated HPAs

if d.Metadata.HasHPA {
cmd := exec.Command("kubectl", "delete", "hpa", "-n", d.Metadata.Namespace, d.Metadata.Name)
out, err := util.RunAndLogCommand(cmd)
if err != nil {
log.Printf("Deployment %s has associated HPA but unable to delete in namespace %s:%s\n", d.Metadata.Namespace, d.Metadata.Name, string(out))
return err
for i := 0; i < retries; i++ {
cmd := exec.Command("kubectl", "delete", "hpa", "-n", d.Metadata.Namespace, d.Metadata.Name)
kubectlOutput, kubectlError = util.RunAndLogCommand(cmd)
if kubectlError != nil {
log.Printf("Deployment %s has associated HPA but unable to delete in namespace %s:%s\n", d.Metadata.Namespace, d.Metadata.Name, string(kubectlOutput))
continue
}
break
}
}
return nil

return kubectlError
}

// Expose will create a load balancer and expose the deployment on a given port
Expand Down
6 changes: 1 addition & 5 deletions test/e2e/kubernetes/job/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,5 @@ func (j *Job) Delete(retries int) error {
break
}

if kubectlError != nil {
return kubectlError
}

return nil
return kubectlError
}
Loading

0 comments on commit 2841bc9

Please sign in to comment.