articulate / biplane

A configuration-based management and automation tool for Kong
MIT License
40 stars 5 forks source link

Error running diff against Kong 0.10 #17

Open jhenry82 opened 7 years ago

jhenry82 commented 7 years ago

Hi there, I just came across your project as a new user looking for a declarative config tool compatible with Kong 0.10. Love the idea.

Unfortunately, I am getting errors on the basic operation of trying to to run the "biplane diff" command against a dump of the config. I am totally unfamiliar with Crystal so I'm not sure if this is user error or a bug.

$ ./biplane dump --host localhost --no-https config.yaml
Dumping API to STDOUT
Running against Kong at http://localhost:8001

$ ./biplane diff config.yaml --no-https --host localhost
Running against Kong at http://localhost:8001
Unknown pull kind: NONE (Exception)
[4313030] ???
[4490076] ???
[4489102] ???
[4487659] ???
[4484809] ???
[4752595] ???
[4310841] ???
[4348728] main +40
[140487809432861] __libc_start_main +253
[4283929] ???

Relevant info: Platform: CentOS Linux 6.8 Biplane: Self-built binary using Crystal 0.15.0. Source cloned from github today 3/14/17. Kong: 0.10.0, admin service running at http://localhost:8001. No authentication.

I haven't attached the dumped YAML but let me know if that's significant. It contains a bunch of proprietary company info but I can sanitize it if it helps.

jhenry82 commented 7 years ago

Ha, ok, I found the problem. It's unescaped star (*) characters in the YAML produced by "biplane dump". Those are special characters in YAML and they break the parser. If I manually edit the file and wrap the stars in double quotes, "biplane diff" works as expected.

The stars are coming from the config for the cors plugin, which looks something like this from "biplane dump". Note the last line.

$ cat config.yaml
---
apis:
  - name: heartbeat
    attributes:
      uris: /api/heartbeat
      strip_uri: true
      upstream_url: http://coolurl/api
    plugins:
  - name: search
    attributes:
      uris: /api/search
      strip_uri: true
      upstream_url: http://coolurl/api
    plugins:
      - name: cors
        attributes:
          config:
            max_age: 86400
            credentials: true
            preflight_continue: false
            origin: *

So at least there's an easy workaround, but it seems like there is a bug in the dump command not escaping special chars.

jhenry82 commented 7 years ago

...and to basically close my own ticket, this is apparently a bug in the Crystal language which is fixed in the 0.19.3 release. Their YAML generator wasn't quoting stars. Welp. Probably nothing to be done here, then, until/unless your project is able to get over the Crystal 0.15 hump.

https://github.com/crystal-lang/crystal/issues/3353

plukevdh commented 7 years ago

Love the effort and debugging put in here. Thanks for the info. We had major problems getting off 0.15 initially. I have not tried updating our compile target since the 0.16 releases. They had some significant backwards compat issues that I couldn't get past. I may try to update as I'd love to be on a later version but we're also planning a rewrite of this project in JS at some point so there isn't a lot of effort to maintain this beyond our own usage as we upgrade versions of Kong.

In either case, I'm glad you found the workaround and appreciate the info on the 0.19.3 fixes.