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

Logs: disable invalid upstream warning when api_backend is null and e… #1449

Merged

Conversation

tkan145
Copy link
Contributor

@tkan145 tkan145 commented Feb 22, 2024

What

Fix https://issues.redhat.com/browse/THREESCALE-5225

PR #1285 only handles the case where api_backend is nil, however, when api_backend is set to an empty string or null json value, the warning log can still be seen in the log.

Verification steps:

  • Create a apicast-config.json file with the following content
cat <<EOF >apicast-config.json
{
  "services": [
    {
      "backend_version": "1",
      "id": "1",
      "api_backend": null,
      "proxy": {
        "api_backend": null,
        "service_backend_version": "1",
        "hosts": [
          "one"
        ],
        "backend": {
          "endpoint": "http://127.0.0.1:8081",
          "host": "backend"
        },
        "policy_chain": [
          {
            "name": "apicast.policy.routing",
            "version": "builtin",
            "enabled": true,
            "configuration": {
              "rules": [
                {
                  "url": "https://echo-api.3scale.net:443",
                  "replace_path": "{{uri | remove_first: '/test'}}",
                  "owner_type": "BackendApi",
                  "condition": {
                    "operations": [
                      {
                        "match": "path",
                        "op": "matches",
                        "value": "^(/test/.*|/test/?)"
                      }
                    ]
                  }
                }
              ]
            }
          },
          {
            "name": "apicast.policy.apicast"
          }
        ],
        "proxy_rules": [
          {
            "http_method": "GET",
            "pattern": "/",
            "metric_system_name": "hits",
            "delta": 1,
            "parameters": [],
            "querystring_parameters": {}
          }
        ]
      }
    }
  ]
}
EOF
  • Checkout this branch and start dev environment
make development
make dependencies
  • Run apicast locally
THREESCALE_DEPLOYMENT_ENV=staging APICAST_LOG_LEVEL=warn APICAST_WORKER=1 APICAST_CONFIGURATION_LOADER=lazy APICAST_CONFIGURATION_CACHE=0 THREESCALE_CONFIG_FILE=apicast-config.json ./bin/apicast
  • Capture apicast IP
APICAST_IP=$(docker inspect apicast_build_0-development-1 | yq e -P '.[0].NetworkSettings.Networks.apicast_build_0_default.IPAddress' -)
  • Send a request
curl -i -k -H "Host: one" "http://${APICAST_IP}:8080/test?user_key="
  • The response should be HTTP/1.1 200
< HTTP/1.1 200 OK
< Server: openresty
< Date: Thu, 22 Feb 2024 01:44:59 GMT
< Content-Type: application/json
< Content-Length: 564
< Connection: keep-alive
< x-3scale-echo-api: echo-api/1.0.3
< vary: Origin
< x-content-type-options: nosniff
< x-envoy-upstream-service-time: 0

Check that apicast.lua:65: upstream api for the service:1 is invalid, error:Upstream cannot be null, client: XX.XXX.X is not visible in logs

@tkan145 tkan145 requested a review from a team as a code owner February 22, 2024 01:49
@tkan145 tkan145 force-pushed the threescale-5225-upstream_cannot_be_null branch from 9c786b3 to c839867 Compare February 22, 2024 04:24
@tkan145 tkan145 requested a review from eguzki February 26, 2024 23:17
@tkan145 tkan145 force-pushed the threescale-5225-upstream_cannot_be_null branch from c839867 to c312d06 Compare March 8, 2024 00:41
@tkan145
Copy link
Contributor Author

tkan145 commented Mar 8, 2024

Rebased on top of master. @eguzki this one is ready for review

Copy link
Member

@eguzki eguzki left a comment

Choose a reason for hiding this comment

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

verification steps worked

CHANGELOG.md Outdated
@@ -9,219 +9,221 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Fixed

- Fix GRPC on HTTP2 POST method [PR #1419](https://github.com/3scale/apicast/pull/1419) [THREESCALE-9976](https://issues.redhat.com/browse/THREESCALE-9976)
- Fix GRPC on HTTP2 POST method [PR #1419](https://github.com/3scale/apicast/pull/1419) [THREESCALE-9976](https://issues.redhat.com/browse/THREESCALE-9976)
Copy link
Member

Choose a reason for hiding this comment

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

why do you add a new space? Could be unintended change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My editor auto format file on save 😓 . Fixed.

Since I've introduced a new change, I'll need another approval.

@tkan145 tkan145 force-pushed the threescale-5225-upstream_cannot_be_null branch from c312d06 to 511669a Compare March 18, 2024 22:52
@tkan145 tkan145 merged commit d40bd58 into 3scale:master Mar 20, 2024
12 checks passed
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

Successfully merging this pull request may close these issues.

None yet

2 participants