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

Trying to trigger on 3rd party resource creation. #11

Open
jeremyjjbrown opened this issue May 2, 2017 · 4 comments
Open

Trying to trigger on 3rd party resource creation. #11

jeremyjjbrown opened this issue May 2, 2017 · 4 comments

Comments

@jeremyjjbrown
Copy link

I created a Kubernetes 3rd party resource api and I'd like to trigger a rule. However I am not getting any trigger instances in my ST2 and it appears most K8s events are failing validation.

st2 trigger-instance list --trigger="kubernetes.pods"+----+---------+-----------------+--------+
| id | trigger | occurrence_time | status |
+----+---------+-----------------+--------+
+----+---------+-----------------+--------+
ubuntu@st2vagrant2:~ $ st2 trigger-instance list --trigger="kubernetes.deployments"
+----+---------+-----------------+--------+
| id | trigger | occurrence_time | status |
+----+---------+-----------------+--------+
+----+---------+-----------------+--------+

/var/log/st2/st2sensorcontainer.log is full of log info from the K8s API server with many instances of

WARNING sensor_wrapper [-] Trigger payload validation failed and validation is enabled, not dispatching a trigger "kubernetes.thirdpartyresources" ({'resource': 'ADDED', 'uid': '53e7d4a9-2f6a-11e7-88e8-0ebd2ffaca5c', 'labels': 'None', 'namespace': 'None', 'object_kind': 'ThirdPartyResource', 'name': 'buckets.stable.here.com'})
WARNING sensor_wrapper [-] Failed to validate payload ({'resource': 'MODIFIED', 'uid': 'b60476a4-2a0c-11e7-bc9d-0a0ac53f9d60', 'labels': 'None', 'namespace': 'kafka', 'object_kind': 'Event', 'name': 'zoo-0.14b8c6e1bb4a477d'}) for trigger "kubernetes.events": [u'obj', 'null'] is not valid under any of the given schemas

Failed validating 'anyOf' in schema['properties']['properties']['additionalProperties']['properties']['type']:
    {'anyOf': [{'$ref': '#/definitions/simpleTypes'},
               {'items': {'$ref': '#/definitions/simpleTypes'},
                'minItems': 1,
                'type': 'array',
                'uniqueItems': True}]}

On instance['properties'][u'resource']['type']:
    [u'obj', 'null']

Not sure what the issue is here.

@Kami
Copy link
Contributor

Kami commented May 3, 2017

Thanks for reporting this.

This is related to the issue StackStorm/st2#3385.

@LindsayHill
Copy link
Contributor

LindsayHill commented May 8, 2017

@Kami is right that part of the problem is st2/#3385, where validation is also enabled.

The problem also seems to be related to this template https://github.com/StackStorm-Exchange/stackstorm-kubernetes/blob/master/etc/st2packgen/templates/sensor_template.yaml.jinja#L13

      payload_schema:
        type: "object"
        properties:
          resource:
            type: "obj"
          name:
            type: "obj"
          labels:
            type: "obj"
          object_kind:
            type: "obj"
          namespace:
            type: "obj"

Rather than type: "obj", it probably needs to be type: "object". May need a uid object in there too.

@Mierdin
Copy link

Mierdin commented May 23, 2017

Just FYI - this behavior is addressed in StackStorm/st2#3390 and will be included in the next release. Still, the schema should be adjusted to match the trigger payload anyways in the meantime.

@AndyMoore111
Copy link
Contributor

I've created branch 1.5 from the latest 1.5.x kubernetes swagger.json

We're currently testing this on our dev cluster - if it looks good I'll merge tonight/tomorrow

gamunu pushed a commit that referenced this issue Jun 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants