TykTechnologies / tyk-operator

Tyk Operator for Kubernetes
https://tyk.io
Other
198 stars 41 forks source link

Error when adding a graphQL API #315

Closed bmonteiro closed 3 years ago

bmonteiro commented 3 years ago

Hey @asoorm,

Please find below a full log when adding the trevorblades example from "Quickstart Examples-> GraphQL Proxy" (YAML) The API in visible (imported) in the Dashboard. Is this error in the log expected ? The API can be called but the Dashboard is missing logs (example: Log Browser) and a policy was configured/created. When created directly via the Dashboard (without using the tyk operator) the Log Browser shows logs.

Error:

tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"error","ts":1621277048.8770208,"logger":"controller-runtime.manager.controller.apidefinition","msg":"Reconciler error","reconciler group":"tyk.tyk.io","reconciler kind":"ApiDefinition","name":"trevorblades","namespace":"tyk-operator-system","error":"Operation cannot be fulfilled on apidefinitions.tyk.tyk.io \"trevorblades\": the object has been modified; please apply your changes to the latest version and try again","stacktrace":"github.com/go-logr/zapr.(*zapLogger).Error\n\t/go/pkg/mod/github.com/go-logr/zapr@v0.2.0/zapr.go:132\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.7.2/pkg/internal/controller/controller.go:267\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.7.2/pkg/internal/controller/controller.go:235\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func1.1\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.7.2/pkg/internal/controller/controller.go:198\nk8s.io/apimachinery/pkg/util/wait.JitterUntilWithContext.func1\n\t/go/pkg/mod/k8s.io/apimachinery@v0.19.2/pkg/util/wait/wait.go:185\nk8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1\n\t/go/pkg/mod/k8s.io/apimachinery@v0.19.2/pkg/util/wait/wait.go:155\nk8s.io/apimachinery/pkg/util/wait.BackoffUntil\n\t/go/pkg/mod/k8s.io/apimachinery@v0.19.2/pkg/util/wait/wait.go:156\nk8s.io/apimachinery/pkg/util/wait.JitterUntil\n\t/go/pkg/mod/k8s.io/apimachinery@v0.19.2/pkg/util/wait/wait.go:133\nk8s.io/apimachinery/pkg/util/wait.JitterUntilWithContext\n\t/go/pkg/mod/k8s.io/apimachinery@v0.19.2/pkg/util/wait/wait.go:185\nk8s.io/apimachinery/pkg/util/wait.UntilWithContext\n\t/go/pkg/mod/k8s.io/apimachinery@v0.19.2/pkg/util/wait/wait.go:99"}

I used the master version of the operator.

Full stack when adding the API:


tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.6963706,"logger":"apidefinition-resource","msg":"validate create","name":"trevorblades"}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.707207,"logger":"controllers.ApiDefinition","msg":"Reconciling ApiDefinition instance","ApiDefinition":"tyk-operator-system/trevorblades"}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.7073793,"logger":"controllers.ApiDefinition","msg":"Updating linked policies"}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.707428,"logger":"controllers.ApiDefinition","msg":"updating looping targets"}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.7523844,"logger":"controllers.ApiDefinition","msg":"Call","Method":"POST","URL":"http://dashboard-svc-tyk-pro.tyk.svc.cluster.local:3000/api/apis","Status":200}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.756142,"logger":"controllers.ApiDefinition","msg":"Call","Method":"GET","URL":"http://dashboard-svc-tyk-pro.tyk.svc.cluster.local:3000/api/apis/60a2b97876456d0001bcfa80","Status":200}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.7658768,"logger":"controllers.ApiDefinition","msg":"Call","Method":"PUT","URL":"http://dashboard-svc-tyk-pro.tyk.svc.cluster.local:3000/api/apis/60a2b97876456d0001bcfa80","Status":200}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.7934701,"logger":"apidefinition-resource","msg":"default","name":"trevorblades"}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.8098311,"logger":"apidefinition-resource","msg":"validate update","name":"trevorblades"}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.8202176,"logger":"controllers.ApiDefinition","msg":"Completed reconciling ApiDefinition instance","ApiDefinition":"tyk-operator-system/trevorblades"}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.8211124,"logger":"controllers.ApiDefinition","msg":"Reconciling ApiDefinition instance","ApiDefinition":"tyk-operator-system/trevorblades"}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.8224268,"logger":"controllers.ApiDefinition","msg":"Updating linked policies"}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.822445,"logger":"controllers.ApiDefinition","msg":"updating looping targets"}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.8224518,"logger":"controllers.ApiDefinition","msg":"Updating ApiDefinition","ApiDefinition":"tyk-operator-system/trevorblades"}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.8380976,"logger":"controllers.ApiDefinition","msg":"Call","Method":"GET","URL":"http://dashboard-svc-tyk-pro.tyk.svc.cluster.local:3000/api/apis","Status":200}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.8388538,"logger":"controllers.ApiDefinition","msg":"All api's","Count":3}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.857855,"logger":"controllers.ApiDefinition","msg":"Call","Method":"PUT","URL":"http://dashboard-svc-tyk-pro.tyk.svc.cluster.local:3000/api/apis/60a2b97876456d0001bcfa80","Status":200}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.8641741,"logger":"apidefinition-resource","msg":"default","name":"trevorblades"}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.8739283,"logger":"apidefinition-resource","msg":"default","name":"trevorblades"}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"error","ts":1621277048.8770208,"logger":"controller-runtime.manager.controller.apidefinition","msg":"Reconciler error","reconciler group":"tyk.tyk.io","reconciler kind":"ApiDefinition","name":"trevorblades","namespace":"tyk-operator-system","error":"Operation cannot be fulfilled on apidefinitions.tyk.tyk.io \"trevorblades\": the object has been modified; please apply your changes to the latest version and try again","stacktrace":"github.com/go-logr/zapr.(*zapLogger).Error\n\t/go/pkg/mod/github.com/go-logr/zapr@v0.2.0/zapr.go:132\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.7.2/pkg/internal/controller/controller.go:267\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.7.2/pkg/internal/controller/controller.go:235\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func1.1\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.7.2/pkg/internal/controller/controller.go:198\nk8s.io/apimachinery/pkg/util/wait.JitterUntilWithContext.func1\n\t/go/pkg/mod/k8s.io/apimachinery@v0.19.2/pkg/util/wait/wait.go:185\nk8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1\n\t/go/pkg/mod/k8s.io/apimachinery@v0.19.2/pkg/util/wait/wait.go:155\nk8s.io/apimachinery/pkg/util/wait.BackoffUntil\n\t/go/pkg/mod/k8s.io/apimachinery@v0.19.2/pkg/util/wait/wait.go:156\nk8s.io/apimachinery/pkg/util/wait.JitterUntil\n\t/go/pkg/mod/k8s.io/apimachinery@v0.19.2/pkg/util/wait/wait.go:133\nk8s.io/apimachinery/pkg/util/wait.JitterUntilWithContext\n\t/go/pkg/mod/k8s.io/apimachinery@v0.19.2/pkg/util/wait/wait.go:185\nk8s.io/apimachinery/pkg/util/wait.UntilWithContext\n\t/go/pkg/mod/k8s.io/apimachinery@v0.19.2/pkg/util/wait/wait.go:99"}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.8771293,"logger":"controllers.ApiDefinition","msg":"Reconciling ApiDefinition instance","ApiDefinition":"tyk-operator-system/trevorblades"}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.877176,"logger":"controllers.ApiDefinition","msg":"Updating linked policies"}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.877185,"logger":"controllers.ApiDefinition","msg":"updating looping targets"}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.877191,"logger":"controllers.ApiDefinition","msg":"Updating ApiDefinition","ApiDefinition":"tyk-operator-system/trevorblades"}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.8911293,"logger":"controllers.ApiDefinition","msg":"Call","Method":"GET","URL":"http://dashboard-svc-tyk-pro.tyk.svc.cluster.local:3000/api/apis","Status":200}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.8930662,"logger":"controllers.ApiDefinition","msg":"All api's","Count":3}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.9166515,"logger":"controllers.ApiDefinition","msg":"Call","Method":"PUT","URL":"http://dashboard-svc-tyk-pro.tyk.svc.cluster.local:3000/api/apis/60a2b97876456d0001bcfa80","Status":200}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.9171605,"logger":"controllers.ApiDefinition","msg":"Completed reconciling ApiDefinition instance","ApiDefinition":"tyk-operator-system/trevorblades"}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.9172282,"logger":"controllers.ApiDefinition","msg":"Reconciling ApiDefinition instance","ApiDefinition":"tyk-operator-system/trevorblades"}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.9172947,"logger":"controllers.ApiDefinition","msg":"Updating linked policies"}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.9173062,"logger":"controllers.ApiDefinition","msg":"updating looping targets"}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.917313,"logger":"controllers.ApiDefinition","msg":"Updating ApiDefinition","ApiDefinition":"tyk-operator-system/trevorblades"}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.9430459,"logger":"controllers.ApiDefinition","msg":"Call","Method":"GET","URL":"http://dashboard-svc-tyk-pro.tyk.svc.cluster.local:3000/api/apis","Status":200}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.9574547,"logger":"controllers.ApiDefinition","msg":"All api's","Count":3}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.9678106,"logger":"controllers.ApiDefinition","msg":"Call","Method":"PUT","URL":"http://dashboard-svc-tyk-pro.tyk.svc.cluster.local:3000/api/apis/60a2b97876456d0001bcfa80","Status":200}
tyk-operator-controller-manager-685b65ff77-22gns manager {"level":"info","ts":1621277048.9683163,"logger":"controllers.ApiDefinition","msg":"Completed reconciling ApiDefinition instance","ApiDefinition":"tyk-operator-system/trevorblades"}```
asoorm commented 3 years ago

@gernest could you take a look? Thanks

gernest commented 3 years ago

@bmonteiro can you please share a sample ApiDefinition resource that will reproduce this issue?

bmonteiro commented 3 years ago
apiVersion: tyk.tyk.io/v1alpha1
kind: ApiDefinition
metadata:
  name: trevorblades
spec:
  name: trevorblades
  use_keyless: true
  protocol: http
  active: true
  proxy:
    target_url: https://countries.trevorblades.com
    listen_path: /trevorblades
    strip_listen_path: true
  graphql:
    enabled: true
    execution_mode: proxyOnly
    schema: |
      directive @cacheControl(maxAge: Int, scope: CacheControlScope) on FIELD_DEFINITION | OBJECT | INTERFACE

      enum CacheControlScope {
        PUBLIC
        PRIVATE
      }

      type Continent {
        code: ID!
        name: String!
        countries: [Country!]!
      }

      input ContinentFilterInput {
        code: StringQueryOperatorInput
      }

      type Country {
        code: ID!
        name: String!
        native: String!
        phone: String!
        continent: Continent!
        capital: String
        currency: String
        languages: [Language!]!
        emoji: String!
        emojiU: String!
        states: [State!]!
      }

      input CountryFilterInput {
        code: StringQueryOperatorInput
        currency: StringQueryOperatorInput
        continent: StringQueryOperatorInput
      }

      type Language {
        code: ID!
        name: String
        native: String
        rtl: Boolean!
      }

      input LanguageFilterInput {
        code: StringQueryOperatorInput
      }

      type Query {
        continents(filter: ContinentFilterInput): [Continent!]!
        continent(code: ID!): Continent
        countries(filter: CountryFilterInput): [Country!]!
        country(code: ID!): Country
        languages(filter: LanguageFilterInput): [Language!]!
        language(code: ID!): Language
      }

      type State {
        code: String
        name: String!
        country: Country!
      }

      input StringQueryOperatorInput {
        eq: String
        ne: String
        in: [String]
        nin: [String]
        regex: String
        glob: String
      }

      """The `Upload` scalar type represents a file upload."""
      scalar Upload
    playground:
      enabled: true
      path: /playground

@gernest ^^

gernest commented 3 years ago

Thanks

bmonteiro commented 3 years ago

@gernest, I also noticed that APIs added via the K8s Tyk Operator are not logging the requests in the Dashboard "API Usage Data - Log Browser". Pls let me know if it happens the same with you.

asoorm commented 3 years ago

I also noticed that APIs added via the K8s Tyk Operator are not logging the requests in the Dashboard "API Usage Data - Log Browser". Pls let me know if it happens the same with you.

Could you try setting do_not_track: false. This should explicitly turn on analytics recording. It's a bit confusing, apologies for this.

gernest commented 3 years ago

@bmonteiro I failed to reproduce this on latest master commit d39e3dd what version of the operator are you using?

{"level":"info","ts":1621885335.5927582,"logger":"apidefinition-resource","msg":"default","name":"trevorblades"}
{"level":"info","ts":1621885335.6020331,"logger":"apidefinition-resource","msg":"validate create","name":"trevorblades"}
{"level":"info","ts":1621885335.6233692,"logger":"controllers.ApiDefinition","msg":"Reconciling ApiDefinition instance","ApiDefinition":"default/trevorblades"}
{"level":"info","ts":1621885335.623463,"logger":"controllers.ApiDefinition","msg":"Updating linked policies"}
{"level":"info","ts":1621885335.6235962,"logger":"controllers.ApiDefinition","msg":"updating looping targets"}
{"level":"info","ts":1621885335.6954143,"logger":"controllers.ApiDefinition","msg":"Call","Method":"POST","URL":"http://dashboard-svc-pro-tyk-pro.tykpro-control-plane.svc.cluster.local:3000/api/apis","Status":200}
{"level":"info","ts":1621885335.7123349,"logger":"controllers.ApiDefinition","msg":"Call","Method":"GET","URL":"http://dashboard-svc-pro-tyk-pro.tykpro-control-plane.svc.cluster.local:3000/api/apis/60ac01972d60f9000191ff9b","Status":200}
{"level":"info","ts":1621885335.740829,"logger":"controllers.ApiDefinition","msg":"Call","Method":"PUT","URL":"http://dashboard-svc-pro-tyk-pro.tykpro-control-plane.svc.cluster.local:3000/api/apis/60ac01972d60f9000191ff9b","Status":200}
{"level":"info","ts":1621885335.7943926,"logger":"apidefinition-resource","msg":"default","name":"trevorblades"}
{"level":"info","ts":1621885335.8108892,"logger":"apidefinition-resource","msg":"validate update","name":"trevorblades"}
{"level":"info","ts":1621885335.8278265,"logger":"controllers.ApiDefinition","msg":"Completed reconciling ApiDefinition instance","ApiDefinition":"default/trevorblades"}
{"level":"info","ts":1621885335.8322914,"logger":"controllers.ApiDefinition","msg":"Reconciling ApiDefinition instance","ApiDefinition":"default/trevorblades"}
{"level":"info","ts":1621885335.832398,"logger":"controllers.ApiDefinition","msg":"Updating linked policies"}
{"level":"info","ts":1621885335.8324199,"logger":"controllers.ApiDefinition","msg":"updating looping targets"}
{"level":"info","ts":1621885335.8324826,"logger":"controllers.ApiDefinition","msg":"Updating ApiDefinition","ApiDefinition":"default/trevorblades"}
{"level":"info","ts":1621885335.847605,"logger":"controllers.ApiDefinition","msg":"Call","Method":"GET","URL":"http://dashboard-svc-pro-tyk-pro.tykpro-control-plane.svc.cluster.local:3000/api/apis","Status":200}
{"level":"info","ts":1621885335.8484218,"logger":"controllers.ApiDefinition","msg":"All api's","Count":1}
{"level":"info","ts":1621885335.8726113,"logger":"controllers.ApiDefinition","msg":"Call","Method":"PUT","URL":"http://dashboard-svc-pro-tyk-pro.tykpro-control-plane.svc.cluster.local:3000/api/apis/60ac01972d60f9000191ff9b","Status":200}
{"level":"info","ts":1621885335.8758144,"logger":"controllers.ApiDefinition","msg":"Completed reconciling ApiDefinition instance","ApiDefinition":"default/trevorblades"}
W0524 19:42:21.978601       1 warnings.go:70] networking.k8s.io/v1beta1 Ingress is deprecated in v1.19+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress
bmonteiro commented 3 years ago

@gernest I think it was 5233be6103c434f6a630a7cf95ec1d3ef9f2e807

bmonteiro commented 3 years ago

Could you try setting do_not_track: false. This should explicitly turn on analytics recording. It's a bit confusing, apologies for this.

yep, but indeed it is confusing having the dashboard working in a different way. I would suggest to get both aligned.

gernest commented 3 years ago

Closing this since we failed to reproduce on master , feel free to reopen.