Modified AwaitServiceByAnnotation to check for service
@@ -5,6 +5,7 @@ import (
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
+ apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
)
@@ -51,8 +52,16 @@ func (f *Framework) CreateTCPService(cluster ClusterIndex, selectorName string,
// AwaitServiceByAnnotation queries the service and looks for the presence of annotation.
func (f *Framework) AwaitServiceByAnnotation(cluster ClusterIndex, annotation string, svcName string, namespace string) *v1.Service {
return AwaitUntil("get"+annotation+" annotation for service "+svcName, func() (interface{}, error) {
- return f.ClusterClients[cluster].CoreV1().Services(namespace).Get(svcName, metav1.GetOptions{})
+ service, err := f.ClusterClients[cluster].CoreV1().Services(namespace).Get(svcName, metav1.GetOptions{})
+ if apierrors.IsNotFound(err) {
+ return nil, nil
+ }
+ return service, err
}, func(result interface{}) (bool, string, error) {
+ if result == nil {
+ return false, "No Service found", nil
+ }
+
svc := result.(*v1.Service)
if svc.GetAnnotations()[annotation] == "" {
return false, fmt.Sprintf("Service %q does not have annotation %q yet", svcName, annotation), nil
