Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop race condition on cloud event YAML test #1517

Merged
merged 1 commit into from
Nov 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions examples/taskruns/cloud-event.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apiVersion: v1
kind: Service
metadata:
name: sink
namespace: default
spec:
selector:
app: cloudevent
Expand All @@ -17,7 +16,6 @@ metadata:
labels:
app: cloudevent
name: message-sink
namespace: default
spec:
containers:
- env:
Expand Down Expand Up @@ -67,6 +65,7 @@ apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
name: send-cloud-event-task

spec:
outputs:
resources:
Expand All @@ -75,6 +74,30 @@ spec:
- name: notification
type: cloudEvent
steps:
- name: wait-for-sink
image: python:3-alpine
imagePullPolicy: IfNotPresent
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the default, so I think we can just omit it for brevity.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch, thanks

command: ["/bin/sh"]
args:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to use script: here? Or maybe wait until it's actually released in 0.9?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can prepare the PR, we can decide to merge it later, but it would be good to have updated examples when 0.9 goes out.

- -ce
- |
cat <<EOF | python
import http.client
import json
import sys
import time

while True:
conn = http.client.HTTPConnection("sink:8080")
try:
conn.request("GET", "/")
break
except:
# Perhaps the service is not setup yet, so service name does not
# resolve or it does not accept connections on 8080 yet
print("Not yet...")
time.sleep(10)
EOF
- name: build-index-json
image: busybox
command:
Expand All @@ -83,8 +106,7 @@ spec:
- -ce
- |
set -e
mkdir -p /builder/home/image-outputs/myimage/
cat <<EOF > /builder/home/image-outputs/myimage/index.json
cat <<EOF > $(outputs.resources.myimage.path)/index.json
{
"schemaVersion": 2,
"manifests": [
Expand Down Expand Up @@ -117,7 +139,7 @@ spec:
import time

while True:
conn = http.client.HTTPConnection("sink.default:8080")
conn = http.client.HTTPConnection("sink:8080")
try:
conn.request("GET", "/")
except:
Expand All @@ -140,6 +162,7 @@ spec:
else:
print("Not yet...")
time.sleep(10)
EOF
---
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
Expand Down