Skip to content

When error happens on deck gateway sync, the output shows nothing is changed in Kong but actually some enntities may changed #1840

@randmonkey

Description

@randmonkey

When error happens on running deck gateway sync, the output of summary always shows that there are no changes on entities, but there may be other entity actually gets changed.

The performdiff returns on error here and tells the caller that 0 operation performed:

if errs != nil {

And also the updates of JSONoutput showing the performed operations are placed after the premature return:
if enableJSONOutput {

However, the performed changes before the error happens are not rollbacked, so the returned message can be very misleading.

For example, if you have the existing configuration in the postgresDB

_format_version: "3.0"
services:
- connect_timeout: 60000
  enabled: true
  host: mockbin.org
  name: svc1
  routes:
  - https_redirect_status_code: 301
    name: r1
    path_handling: v0
    paths:
    - /r1
    preserve_host: false
    protocols:
    - http
    - https
- connect_timeout: 60000
  enabled: true
  host: mockbin.org
  name: svc2
  port: 80
  protocol: http
  retries: 5
  routes:
  - https_redirect_status_code: 301
    name: r2
    path_handling: v0
    paths:
    - /r2
    preserve_host: false
    protocols:
    - http
    - https

Then you sync with the invalid configuration

_format_version: "3.0"
services:
- connect_timeout: 60000
  host: mockbin.org
  name: svc1
  port: 80
  protocol: http
  read_timeout: 60000
  retries: 5
  routes:
  - name: r1 # invalid route because path is not specified
- connect_timeout: 60000
  host: mockbin.org
  name: svc2
  port: 80
  protocol: http
  read_timeout: 60000
  retries: 5
  routes:
  - name: r2
    https_redirect_status_code: 301
    paths:
    - /r2-2

The output show that

Summary:
  Created: 0
  Updated: 0
  Deleted: 0
Error: 1 errors occurred:
	while processing event: Update route r1 failed: HTTP status 400 (message: "schema violation (must set one of 'methods', 'hosts', 'headers', 'paths', 'snis' when 'protocols' is 'https')")

The user may think that the route r2 remains unchanged. However, when we run deck gateway dump to show the current Kong configuration in postgresDB, it shows that the route r2 is actually changed:

_format_version: "3.0"
services:
- connect_timeout: 60000
  enabled: true
  host: mockbin.org
  name: svc1
  port: 80
  protocol: http
  read_timeout: 60000
  retries: 5
  routes:
  - https_redirect_status_code: 301
    name: r1
    path_handling: v0
    paths:
    - /r1
    preserve_host: false
    protocols:
    - http
    - https
    regex_priority: 0
    request_buffering: true
    response_buffering: true
    strip_path: true
  write_timeout: 60000
- connect_timeout: 60000
  enabled: true
  host: mockbin.org
  name: svc2
  port: 80
  protocol: http
  read_timeout: 60000
  retries: 5
  routes:
  - https_redirect_status_code: 301
    name: r2
    path_handling: v0
    paths:
    - /r2-2 # The route r2 is actually changed.
    preserve_host: false
    protocols:
    - http
    - https
    regex_priority: 0
    request_buffering: true
    response_buffering: true
    strip_path: true
  write_timeout: 60000

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions