Exemple #1
0
func DeleteService(svcId string) error {
	// in case of failure
	oldService, err := database.GetService(svcId)
	if err != nil {
		if !strings.Contains(err.Error(), "No Service Found") {
			return err
		}
	}

	// delete backend rule
	err = balance.DeleteService(svcId)
	if err != nil {
		return err
	}

	if !database.CentralStore {
		// remove from backend
		err = database.DeleteService(svcId)
		if err != nil {
			// undo balance action
			if oldService != nil {
				if uerr := balance.SetService(oldService); uerr != nil {
					err = fmt.Errorf("%v - %v", err.Error(), uerr.Error())
				}
			}
			return err
		}
	}
	return nil
}
Exemple #2
0
func TestDeleteServiceNginx(t *testing.T) {
	if !nginxPrep() {
		t.SkipNow()
	}
	if err := balance.DeleteService(testService2.Id); err != nil {
		t.Errorf("Failed to DELETE nonexistant service - %v", err)
	}

	balance.SetService(&testService2)

	if err := balance.DeleteService(testService2.Id); err != nil {
		t.Errorf("Failed to DELETE service - %v", err)
	}

	_, err := balance.GetService(testService2.Id)
	if err == nil {
		t.Error(err)
	}
}
Exemple #3
0
func TestDeleteService(t *testing.T) {
	if skip {
		t.SkipNow()
	}
	if err := balance.DeleteService(testService2.Id); err != nil {
		t.Errorf("Failed to GET service - %v", err)
	}

	// todo: read from ipvsadm
	_, err := balance.GetService(testService2.Id)
	if !strings.Contains(err.Error(), "No Service Found") {
		t.Error(err)
	}
}