Skip to content

Commit

Permalink
feat(serverless): 502 errors (#4170)
Browse files Browse the repository at this point in the history
* feat(serverless): 502 errors

* Apply suggestions from code review

Co-authored-by: Benedikt Rollik <[email protected]>

* fix(docs): doc review

* fix(docs): doc review

* fix(docs): doc review

* fix(docs): doc review

---------

Co-authored-by: Benedikt Rollik <[email protected]>
Co-authored-by: SamyOubouaziz <[email protected]>
  • Loading branch information
3 people authored Jan 7, 2025
1 parent c3dde8d commit 0955b64
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
8 changes: 8 additions & 0 deletions serverless/containers/how-to/add-trigger-to-a-container.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ The configuration of the queue retention can affect the behavior of the trigger.

When a message is pushed to the selected queues, the container will be triggered with the message content passed in the event object's body.

<Message type="note">
**Retry Policy:** If the Container returns a status code superior or equal to 300, sending the message will be retried up to three times.
</Message>

## NATS triggers

[NATS triggers](/serverless/containers/concepts/#nats-trigger) allow you to automatically invoke a container using messages sent in a [NATS](/serverless/messaging/concepts/#nats) subject.
Expand All @@ -69,6 +73,10 @@ When a message is pushed to the selected queues, the container will be triggered
6. Enter a **name** for your trigger and select the **NATS (Scaleway)** type, then select your NATS account and subject name.
7. Click **Create trigger** to launch the trigger creation.

<Message type="note">
**Retry Policy:** If the Container returns a status code superior or equal to 300, sending the message will be retried up to three times.
</Message>

## CRON triggers

[CRON triggers](/serverless/containers/concepts/#cron-trigger) allow you to invoke your containers based on a recurring schedule. The CRON triggers for Serverless Containers use the **UTC** time zone.
Expand Down
47 changes: 47 additions & 0 deletions serverless/containers/troubleshooting/502-error-when-scaling.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
meta:
title: Error code 502
description: Troubleshoot 502 error codes while sending requests to Serverless Containers.
content:
h1: Error code 502
paragraph: Troubleshoot 502 error codes while sending requests to Serverless Containers.
tags: serverless Containers troubleshooting issue error 502
dates:
validation: 2025-01-03
posted: 2025-01-03
categories:
- serverless
---

## Problem

502 errors can sometimes occur on Serverless Containers during the autoscaling process when new container instances are being created.

### Cause

When a new instance is created, the Serverless health check verification is performed by default on the HTTP port. Once the port is opened, the resource is considered ready, and traffic starts being forwarded to it.

This issue typically occurs when traffic is sent too early to the newly created container before it is fully deployed.

### Possible solutions

To ensure the Serverless Container is completely ready, both in terms of the HTTP port and the software scope, it is recommended to use **custom health checks**.

You can configure [Custom health checks via the Scaleway API](https://www.scaleway.com/en/developers/api/serverless-containers/#path-containers-update-an-existing-container) with the `health_check` parameter. In this case, we recommend you implement a custom HTTP route on the Container that returns its readiness status.

<Message type="tip">
A simple health check to implement is just a simple `GET` on `/` to make sure the HTTP server is properly listening.

Example (incomplete) settings:
```
health_check: {
http: {
path: "/"
}
}
```
</Message>

<Message type="note">
Custom healthcheck feature will be available in the Scaleway console for Q1 2025.
</Message>
8 changes: 8 additions & 0 deletions serverless/functions/how-to/add-trigger-to-a-function.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ The configuration of the queue retention may affect the behavior of the trigger.
6. Enter a **name** for your trigger and select the **Queues (Scaleway)** type, then select your queue name.
7. Click **Create trigger** to launch trigger creation.

<Message type="note">
**Retry Policy:** If the Function returns a status code superior or equal to 300, sending the message will be retried up to three times.
</Message>

## NATS triggers

[NATS triggers](/serverless/functions/concepts/#nats-trigger) allow you to automatically invoke a function using messages sent in a [NATS](/serverless/messaging/concepts/#nats) subject.
Expand All @@ -67,6 +71,10 @@ Scaleway [NATS subjects](/serverless/messaging/quickstart/#quickstart-for-nats)
6. Enter a **name** for your trigger and select the **NATS (Scaleway)** type, then select your NATS account and subject name.
7. Click **Create trigger** to launch trigger creation.

<Message type="note">
**Retry Policy:** If the Function returns a status code superior or equal to 300, sending the message will be retried up to three times.
</Message>

## CRON triggers

[CRON triggers](/serverless/functions/concepts/#cron-trigger) allow you to invoke your functions based on a recurring schedule. The CRON triggers for Serverless Functions use the **UTC** time zone.
Expand Down

0 comments on commit 0955b64

Please sign in to comment.