Skip to content

Commit

Permalink
chore: default not to include instanceid in release and examples. Closes
Browse files Browse the repository at this point in the history
 #615 (#623)

* chore: default not to include instanceid in release and examples

* more found
  • Loading branch information
whynowy authored Apr 30, 2020
1 parent 336cb65 commit e7ecad2
Show file tree
Hide file tree
Showing 110 changed files with 76 additions and 301 deletions.
3 changes: 1 addition & 2 deletions controllers/gateway/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (

"github.com/argoproj/argo-events/common"
"github.com/ghodss/yaml"
"github.com/pkg/errors"
apiv1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
Expand Down Expand Up @@ -102,7 +101,7 @@ func (c *Controller) ResyncConfig(namespace string) error {
func (c *Controller) updateConfig(cm *apiv1.ConfigMap) error {
configStr, ok := cm.Data[common.ControllerConfigMapKey]
if !ok {
return errors.Errorf("configMap '%s' does not have key '%s'", c.ConfigMap, common.ControllerConfigMapKey)
return nil
}
var config ControllerConfig
err := yaml.Unmarshal([]byte(configStr), &config)
Expand Down
11 changes: 7 additions & 4 deletions controllers/gateway/informer.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ import (
)

func (c *Controller) instanceIDReq() (*labels.Requirement, error) {
if c.Config.InstanceID == "" {
panic("instance id is required")
var instanceIDReq *labels.Requirement
var err error
if c.Config.InstanceID != "" {
instanceIDReq, err = labels.NewRequirement(LabelControllerInstanceID, selection.Equals, []string{c.Config.InstanceID})
} else {
instanceIDReq, err = labels.NewRequirement(LabelControllerInstanceID, selection.DoesNotExist, nil)
}
instanceIDReq, err := labels.NewRequirement(LabelControllerInstanceID, selection.Equals, []string{c.Config.InstanceID})
if err != nil {
return nil, err
panic(err)
}
c.logger.WithField("instance-id", instanceIDReq.String()).Infoln("instance id requirement")
return instanceIDReq, nil
Expand Down
3 changes: 1 addition & 2 deletions controllers/sensor/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (

"github.com/argoproj/argo-events/common"
"github.com/ghodss/yaml"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -102,7 +101,7 @@ func (controller *Controller) ResyncConfig(namespace string) error {
func (controller *Controller) updateConfig(cm *corev1.ConfigMap) error {
configStr, ok := cm.Data[common.ControllerConfigMapKey]
if !ok {
return errors.Errorf("configMap '%s' does not have key '%s'", controller.ConfigMap, common.ControllerConfigMapKey)
return nil
}
var config ControllerConfig
err := yaml.Unmarshal([]byte(configStr), &config)
Expand Down
6 changes: 3 additions & 3 deletions controllers/sensor/informer.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package sensor

import (
sensorinformers "github.com/argoproj/argo-events/pkg/client/sensor/informers/externalversions"
"github.com/pkg/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/selection"
Expand All @@ -29,9 +28,10 @@ func (controller *Controller) instanceIDReq() (*labels.Requirement, error) {
var instanceIDReq *labels.Requirement
var err error
if controller.Config.InstanceID == "" {
return nil, errors.New("controller instance id must be specified")
instanceIDReq, err = labels.NewRequirement(LabelControllerInstanceID, selection.DoesNotExist, nil)
} else {
instanceIDReq, err = labels.NewRequirement(LabelControllerInstanceID, selection.Equals, []string{controller.Config.InstanceID})
}
instanceIDReq, err = labels.NewRequirement(LabelControllerInstanceID, selection.Equals, []string{controller.Config.InstanceID})
if err != nil {
panic(err)
}
Expand Down
2 changes: 0 additions & 2 deletions docs/demo/notebooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ In this demo, we are going to set up an image processing pipeline using 2 notebo
kind: Sensor
metadata:
name: webhook-sensor
labels:
sensors.argoproj.io/sensor-controller-instanceid: argo-events
spec:
template:
spec:
Expand Down
2 changes: 0 additions & 2 deletions docs/triggers/argo-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ Argo workflow is K8s custom resource which help orchestrating parallel jobs on K
kind: Sensor
metadata:
name: webhook-sensor
labels:
sensors.argoproj.io/sensor-controller-instanceid: argo-events
spec:
template:
spec:
Expand Down
2 changes: 0 additions & 2 deletions docs/triggers/build-your-own-trigger.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ Let's look at the following sensor,
kind: Sensor
metadata:
name: webhook-sensor
labels:
sensors.argoproj.io/sensor-controller-instanceid: argo-events
spec:
template:
spec:
Expand Down
4 changes: 0 additions & 4 deletions docs/triggers/http-trigger.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,6 @@ to invoke OpenFaas function.
kind: Sensor
metadata:
name: redis-sensor
labels:
sensors.argoproj.io/sensor-controller-instanceid: argo-events
spec:
template:
spec:
Expand Down Expand Up @@ -242,8 +240,6 @@ Similar to REST API calls, you can easily invoke Kubeless functions using HTTP t
kind: Sensor
metadata:
name: nats-sensor
labels:
sensors.argoproj.io/sensor-controller-instanceid: argo-events
spec:
template:
spec:
Expand Down
2 changes: 0 additions & 2 deletions docs/triggers/k8s-object-trigger.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ set up event-driven pipelines for existing workloads.
kind: Sensor
metadata:
name: webhook-sensor
labels:
sensors.argoproj.io/sensor-controller-instanceid: argo-events
spec:
template:
spec:
Expand Down
2 changes: 0 additions & 2 deletions docs/triggers/kafka-trigger.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ The Kafka trigger specification is available [here](https://github.com/argoproj/
kind: Sensor
metadata:
name: minio-sensor
labels:
sensors.argoproj.io/sensor-controller-instanceid: argo-events
spec:
template:
spec:
Expand Down
2 changes: 0 additions & 2 deletions docs/triggers/nats-trigger.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ The NATS trigger specification is available [here](https://github.com/argoproj/a
kind: Sensor
metadata:
name: minio-sensor
labels:
sensors.argoproj.io/sensor-controller-instanceid: argo-events
spec:
template:
spec:
Expand Down
10 changes: 0 additions & 10 deletions docs/tutorials/09-events-over-nats.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ Up until now, you have seen the gateway dispatch events to sensor over HTTP. In
kind: Gateway
metadata:
name: webhook-gateway-multi-subscribers
labels:
# gateway controller with instanceId "argo-events" will process this gateway
gateways.argoproj.io/gateway-controller-instanceid: argo-events
spec:
replica: 1
type: webhook
Expand Down Expand Up @@ -128,8 +125,6 @@ Up until now, you have seen the gateway dispatch events to sensor over HTTP. In
kind: Sensor
metadata:
name: webhook-sensor
labels:
sensors.argoproj.io/sensor-controller-instanceid: argo-events
spec:
template:
spec:
Expand Down Expand Up @@ -212,9 +207,6 @@ You can easily set up a gateway to send events over both HTTP and NATS,
kind: Gateway
metadata:
name: webhook-gateway-multi-subscribers
labels:
# gateway controller with instanceId "argo-events" will process this gateway
gateways.argoproj.io/gateway-controller-instanceid: argo-events
spec:
replica: 1
type: webhook
Expand Down Expand Up @@ -262,8 +254,6 @@ You can easily set up a gateway to send events over both HTTP and NATS,
kind: Sensor
metadata:
name: webhook-sensor-over-http-and-nats
labels:
sensors.argoproj.io/sensor-controller-instanceid: argo-events
spec:
template:
spec:
Expand Down
3 changes: 0 additions & 3 deletions examples/gateways/amqp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ apiVersion: argoproj.io/v1alpha1
kind: Gateway
metadata:
name: amqp-gateway
labels:
# gateway controller with instanceId "argo-events" will process this gateway
gateways.argoproj.io/gateway-controller-instanceid: argo-events
spec:
type: amqp
eventSourceRef:
Expand Down
3 changes: 0 additions & 3 deletions examples/gateways/aws-sns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ apiVersion: argoproj.io/v1alpha1
kind: Gateway
metadata:
name: aws-sns-gateway
labels:
# gateway controller with instanceId "argo-events" will process this gateway
gateways.argoproj.io/gateway-controller-instanceid: argo-events
spec:
type: sns
eventSourceRef:
Expand Down
3 changes: 0 additions & 3 deletions examples/gateways/aws-sqs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ apiVersion: argoproj.io/v1alpha1
kind: Gateway
metadata:
name: aws-sqs-gateway
labels:
# gateway controller with instanceId "argo-events" will process this gateway
gateways.argoproj.io/gateway-controller-instanceid: argo-events
spec:
replica: 1
type: sqs
Expand Down
3 changes: 0 additions & 3 deletions examples/gateways/azure-events-hub.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ apiVersion: argoproj.io/v1alpha1
kind: Gateway
metadata:
name: azure-events-hub-gateway
labels:
# gateway controller with instanceId "argo-events" will process this gateway
gateways.argoproj.io/gateway-controller-instanceid: argo-events
spec:
type: azureEventsHub
eventSourceRef:
Expand Down
3 changes: 0 additions & 3 deletions examples/gateways/calendar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ apiVersion: argoproj.io/v1alpha1
kind: Gateway
metadata:
name: calendar-gateway
labels:
# gateway controller with instanceId "argo-events" will process this gateway
gateways.argoproj.io/gateway-controller-instanceid: argo-events
spec:
type: calendar
eventSourceRef:
Expand Down
3 changes: 0 additions & 3 deletions examples/gateways/emitter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ apiVersion: argoproj.io/v1alpha1
kind: Gateway
metadata:
name: emitter-gateway
labels:
# gateway controller with instanceId "argo-events" will process this gateway
gateways.argoproj.io/gateway-controller-instanceid: argo-events
spec:
type: emitter
eventSourceRef:
Expand Down
3 changes: 0 additions & 3 deletions examples/gateways/file.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ apiVersion: argoproj.io/v1alpha1
kind: Gateway
metadata:
name: file-gateway
labels:
# gateway controller with instanceId "argo-events" will process this gateway
gateways.argoproj.io/gateway-controller-instanceid: argo-events
spec:
type: file
eventSourceRef:
Expand Down
3 changes: 0 additions & 3 deletions examples/gateways/gcp-pubsub.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ apiVersion: argoproj.io/v1alpha1
kind: Gateway
metadata:
name: gcp-pubsub-gateway
labels:
# gateway controller with instanceId "argo-events" will process this gateway
gateways.argoproj.io/gateway-controller-instanceid: argo-events
spec:
replica: 1
type: pubsub
Expand Down
3 changes: 0 additions & 3 deletions examples/gateways/github.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ apiVersion: argoproj.io/v1alpha1
kind: Gateway
metadata:
name: github-gateway
labels:
# gateway controller with instanceId "argo-events" will process this gateway
gateways.argoproj.io/gateway-controller-instanceid: argo-events
spec:
type: github
eventSourceRef:
Expand Down
5 changes: 1 addition & 4 deletions examples/gateways/gitlab.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ apiVersion: argoproj.io/v1alpha1
kind: Gateway
metadata:
name: gitlab-gateway
labels:
# gateway controller with instanceId "argo-events" will process this gateway
gateways.argoproj.io/gateway-controller-instanceid: argo-events
spec:
replica: 1
type: gitlab
Expand Down Expand Up @@ -38,4 +35,4 @@ spec:
type: LoadBalancer
subscribers:
http:
- "http://gitlab-sensor.argo-events.svc:9300/"
- "http://gitlab-sensor.argo-events.svc:9300/"
3 changes: 0 additions & 3 deletions examples/gateways/hdfs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ apiVersion: argoproj.io/v1alpha1
kind: Gateway
metadata:
name: hdfs-gateway
labels:
# gateway controller with instanceId "argo-events" will process this gateway
gateways.argoproj.io/gateway-controller-instanceid: argo-events
spec:
replica: 1
type: hdfs
Expand Down
3 changes: 0 additions & 3 deletions examples/gateways/kafka.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ apiVersion: argoproj.io/v1alpha1
kind: Gateway
metadata:
name: kafka-gateway
labels:
# gateway controller with instanceId "argo-events" will process this gateway
gateways.argoproj.io/gateway-controller-instanceid: argo-events
spec:
replica: 1
type: kafka
Expand Down
3 changes: 0 additions & 3 deletions examples/gateways/minio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ apiVersion: argoproj.io/v1alpha1
kind: Gateway
metadata:
name: minio-gateway
labels:
# gateway controller with instanceId "argo-events" will process this gateway
gateways.argoproj.io/gateway-controller-instanceid: argo-events
spec:
type: minio
eventSourceRef:
Expand Down
3 changes: 0 additions & 3 deletions examples/gateways/mqtt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ apiVersion: argoproj.io/v1alpha1
kind: Gateway
metadata:
name: mqtt-gateway
labels:
# gateway controller with instanceId "argo-events" will process this gateway
gateways.argoproj.io/gateway-controller-instanceid: argo-events
spec:
type: mqtt
eventSourceRef:
Expand Down
3 changes: 0 additions & 3 deletions examples/gateways/multi-subscribers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ apiVersion: argoproj.io/v1alpha1
kind: Gateway
metadata:
name: webhook-gateway
labels:
# gateway controller with instanceId "argo-events" will process this gateway
gateways.argoproj.io/gateway-controller-instanceid: argo-events
spec:
replica: 1
type: webhook
Expand Down
3 changes: 0 additions & 3 deletions examples/gateways/nats.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ apiVersion: argoproj.io/v1alpha1
kind: Gateway
metadata:
name: nats-gateway
labels:
# gateway controller with instanceId "argo-events" will process this gateway
gateways.argoproj.io/gateway-controller-instanceid: argo-events
spec:
type: nats
eventSourceRef:
Expand Down
3 changes: 0 additions & 3 deletions examples/gateways/nsq.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ apiVersion: argoproj.io/v1alpha1
kind: Gateway
metadata:
name: nsq-gateway
labels:
# gateway controller with instanceId "argo-events" will process this gateway
gateways.argoproj.io/gateway-controller-instanceid: argo-events
spec:
type: nsq
eventSourceRef:
Expand Down
3 changes: 0 additions & 3 deletions examples/gateways/redis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ apiVersion: argoproj.io/v1alpha1
kind: Gateway
metadata:
name: redis-gateway
labels:
# gateway controller with instanceId "argo-events" will process this gateway
gateways.argoproj.io/gateway-controller-instanceid: argo-events
spec:
type: redis
eventSourceRef:
Expand Down
3 changes: 0 additions & 3 deletions examples/gateways/resource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ apiVersion: argoproj.io/v1alpha1
kind: Gateway
metadata:
name: resource-gateway
labels:
# gateway controller with instanceId "argo-events" will process this gateway
gateways.argoproj.io/gateway-controller-instanceid: argo-events
spec:
type: resource
eventSourceRef:
Expand Down
3 changes: 0 additions & 3 deletions examples/gateways/secure-webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ apiVersion: argoproj.io/v1alpha1
kind: Gateway
metadata:
name: webhook-gateway
labels:
# gateway controller with instanceId "argo-events" will process this gateway
gateways.argoproj.io/gateway-controller-instanceid: argo-events
spec:
type: webhook
eventSourceRef:
Expand Down
Loading

2 comments on commit e7ecad2

@nfp007
Copy link

@nfp007 nfp007 commented on e7ecad2 May 4, 2020

Choose a reason for hiding this comment

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

@whynowy
I tried to use namespace install but, pods refused to start with following errors:

kubectl logs gateway-controller-567b4dcd49-mfsss
INFO[2020-05-04 14:09:18] starting controller                           instance-id="" version=v0.14.0
INFO[2020-05-04 14:09:18] watching gateway-controller config map updates 
panic: instance id is required

goroutine 42 [running]:
github.com/argoproj/argo-events/controllers/gateway.(*Controller).instanceIDReq(0xc000103b00, 0xc00038f7c0, 0x15cc4a0, 0xc0002bc780)
        /go/src/github.com/argoproj/argo-events/controllers/gateway/informer.go:29 +0x1e6
github.com/argoproj/argo-events/controllers/gateway.(*Controller).newGatewayInformer(0xc000103b00, 0x15e2388, 0xc0000fe080, 0x0, 0x1)
        /go/src/github.com/argoproj/argo-events/controllers/gateway/informer.go:41 +0x40
github.com/argoproj/argo-events/controllers/gateway.(*Controller).Run(0xc000103b00, 0x15e90e0, 0xc000042028, 0x1)
        /go/src/github.com/argoproj/argo-events/controllers/gateway/controller.go:162 +0x314
created by main.main
        /go/src/github.com/argoproj/argo-events/controllers/gateway/cmd/main.go:54 +0x1b7
kubectl logs sensor-controller-5f744748b9-qrqq4
time="2020-05-04T14:06:15Z" level=info msg="watching controller config map updates"
INFO[2020-05-04 14:06:15] starting the controller...                    instance-id="" version=v0.14.0
ERRO[2020-05-04 14:06:15] failed to create a new sensor controller      error="controller instance id must be specified"
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x11a4484]

goroutine 75 [running]:
github.com/argoproj/argo-events/controllers/sensor.(*Controller).Run(0xc00015dc20, 0x161c0e0, 0xc0000ea000, 0x1)
        /go/src/github.com/argoproj/argo-events/controllers/sensor/controller.go:167 +0x374
created by main.main
        /go/src/github.com/argoproj/argo-events/controllers/sensor/cmd/main.go:54 +0x1b7

When i added instanceID: argo-events into namespace-install.yaml its working again.

@whynowy
Copy link
Member Author

@whynowy whynowy commented on e7ecad2 May 4, 2020

Choose a reason for hiding this comment

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

We should fix the installation manifests link, it should not point to master.

Please sign in to comment.