#[Solved] Error: Appwrite-executor with status code 0

145 messages · Page 1 of 1 (latest)

mighty beacon
#

Hi 👋

After deploy a function, got this error:
Could not resolve host: appwrite-executor with status code 0.

analog token
#

Where you getting this error exactly?

mighty beacon
#

In dashboard...

analog token
#

👍

#

Can you share this part of your code

const client = new Client()
    .setEndpoint('https://cloud.appwrite.io/v1') 

mighty beacon
#

OK

#

Hmm..

#
import * as sdk from "node-appwrite";

type AppwriteVariables =
  | "APPWRITE_FUNCTION_ENDPOINT"
  | "APPWRITE_FUNCTION_API_KEY"
  | "APPWRITE_FUNCTION_ID"
  | "APPWRITE_FUNCTION_PROJECT_ID"
  | "APPWRITE_FUNCTION_API_KEY";

type AppwriteRequest = {
  headers: { [name: string]: string };
  payload: string;
  variables: { [key in AppwriteVariables]: string };
};

interface AppwriteResponse {
  send: (data: string, status?: number) => {};
  json: (data: object, status?: number) => {};
}

module.exports = async function (req: AppwriteRequest, res: AppwriteResponse) {
  const client = new sdk.Client();
  const users = new sdk.Users(client);

  if (
    !req.variables["APPWRITE_FUNCTION_ENDPOINT"] ||
    !req.variables["APPWRITE_FUNCTION_API_KEY"]
  ) {
    throw Error(
      "Environment variables are not set. Function cannot use Appwrite SDK."
    );
  } else {
    client
      .setEndpoint(req.variables["APPWRITE_FUNCTION_ENDPOINT"])
      .setProject(req.variables["APPWRITE_FUNCTION_PROJECT_ID"])
      .setKey(req.variables["APPWRITE_FUNCTION_API_KEY"])
      .setSelfSigned(true);
  }

  const getAllUsers = await users.list();

  res.json({ message: getAllUsers.users });
};
#

I have set variables in functions settings (dashboad)

analog token
#

That seems good

#

And what value you've put inside this variable? APPWRITE_FUNCTION_ENDPOINT

mighty beacon
#

https://example_endpoint.com/v1

#

When try activate i got this error

analog token
#

Is this a self-hosted Appwrite?

mighty beacon
#

Yes

analog token
#

Can you run

docker ps -a

And share the results?

mighty beacon
#

ok

#

Up 2 minutes ago beacuse updated .env file, added a dart runtimes

analog token
#

Okay so it seems like the appwrite-executor has just been created
Can you try to execute your function now

#

It seems like it should work

mighty beacon
#

Don’t work

#

Before this didn’t work, I changed the .env file because I had forgotten to add the runtime, but I tell you that it was no longer working.

analog token
#

Ohh so now the appwrite-executor is on or off?

analog token
mighty beacon
analog token
mighty beacon
#

Ye

#

Sorry for delay to response

mighty beacon
#

Anyone can help?

analog token
#

As the executor wasn't available at start
I'll first try to run

docker compose down && docker compose up -d

To let the infrastructure restart

mighty beacon
#

ok

#

started!

analog token
#

Good.
Now what you get when executing the function

mighty beacon
#

OK

#

Failed

analog token
#

What is the error?

mighty beacon
#

The same

analog token
#

And the Appwrite logs?

mighty beacon
#

Could not resolve host: appwrite-executor with status code 0

#

🤯

analog token
#

Where you see that error?

mighty beacon
#

In Dashboard...

#

Functions > Function name > Options > Output > Errors

analog token
#

Maybe you've changed this value

OPEN_RUNTIMES_NETWORK=?
#

In the .env file?

mighty beacon
#

Don't changes...

analog token
#

Can you run

 docker network inspect appwrite_runtimes
#

And share the results

mighty beacon
#
[
    {
        "Name": "appwrite_runtimes",
        "Id": "05cbe3e51f357a74c3638ae939925c97f5b07a578d7037c0e8327946bd0cce90",
        "Created": "2023-07-20T15:00:24.558536332Z",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.21.0.0/16",
                    "Gateway": "172.21.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "a9bf5817acb21849d6c1099a7d86416a711f1badfd268d9642f88c8635b12783": {
                "Name": "appwrite-executor",
                "EndpointID": "1fa419f95e364e052c2635c8f199962e0e23c863999efdd15bda06ff2968ca95",
                "MacAddress": "02:42:ac:15:00:02",
                "IPv4Address": "172.21.0.2/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {
            "com.docker.compose.network": "runtimes",
            "com.docker.compose.project": "appwrite",
            "com.docker.compose.version": "2.19.1"
        }
    }
]
analog token
analog token
#

As you don't have the function in the network

#

What it the output of

docker network ls
mighty beacon
#
NETWORK ID     NAME                DRIVER    SCOPE
bc57358c6cd2   appwrite_appwrite   bridge    local
40187ebe9870   appwrite_gateway    bridge    local
05cbe3e51f35   appwrite_runtimes   bridge    local
827dbb8bc08d   bridge              bridge    local
62edf67b02e3   host                host      local
a3b5419aaa62   none                null      local
analog token
#

Okay can you share the networks part of your appwrite-executor service inside the docker-compose.yml like so:

  appwrite-executor:
    image: appwrite/appwrite:1.3.7
    entrypoint: executor
    <<: *x-logging
    container_name: appwrite-executor
    restart: unless-stopped
    stop_signal: SIGINT
    networks:
       ...
mighty beacon
#

ok

#
appwrite-executor:
    image: appwrite/appwrite:1.3.7
    entrypoint: executor
    <<: *x-logging
    container_name: appwrite-executor
    restart: unless-stopped
    stop_signal: SIGINT
    networks:
      appwrite:
      runtimes:
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - appwrite-functions:/storage/functions:rw
      - appwrite-builds:/storage/builds:rw
      - /tmp:/tmp:rw
    depends_on:
      - redis
      - mariadb
      - appwrite
    environment:
      - _APP_ENV
      - _APP_VERSION
      - _APP_FUNCTIONS_TIMEOUT
      - _APP_FUNCTIONS_BUILD_TIMEOUT
      - _APP_FUNCTIONS_CONTAINERS
      - _APP_FUNCTIONS_RUNTIMES
      - _APP_FUNCTIONS_CPUS
      - _APP_FUNCTIONS_MEMORY
      - _APP_FUNCTIONS_MEMORY_SWAP
      - _APP_FUNCTIONS_INACTIVE_THRESHOLD
      - _APP_EXECUTOR_SECRET
      - OPEN_RUNTIMES_NETWORK
      - _APP_LOGGING_PROVIDER
      - _APP_LOGGING_CONFIG
      - _APP_STORAGE_DEVICE
      - _APP_STORAGE_S3_ACCESS_KEY
      - _APP_STORAGE_S3_SECRET
      - _APP_STORAGE_S3_REGION
      - _APP_STORAGE_S3_BUCKET
      - _APP_STORAGE_DO_SPACES_ACCESS_KEY
      - _APP_STORAGE_DO_SPACES_SECRET
      - _APP_STORAGE_DO_SPACES_REGION
      - _APP_STORAGE_DO_SPACES_BUCKET
      - _APP_STORAGE_BACKBLAZE_ACCESS_KEY
      - _APP_STORAGE_BACKBLAZE_SECRET
      - _APP_STORAGE_BACKBLAZE_REGION
      - _APP_STORAGE_BACKBLAZE_BUCKET
      - _APP_STORAGE_LINODE_ACCESS_KEY
      - _APP_STORAGE_LINODE_SECRET
      - _APP_STORAGE_LINODE_REGION
      - _APP_STORAGE_LINODE_BUCKET
      - _APP_STORAGE_WASABI_ACCESS_KEY
      - _APP_STORAGE_WASABI_SECRET
      - _APP_STORAGE_WASABI_REGION
      - _APP_STORAGE_WASABI_BUCKET
      - DOCKERHUB_PULL_USERNAME
      - DOCKERHUB_PULL_PASSWORD

analog token
#

It's weird as the containers are on the same network

#

What is the value of _APP_EXECUTOR_HOST inside the .env file?

mighty beacon
analog token
#

Then everything in order and it should work

I guess will need to wait for Steven diagnostic on this matter.

mighty beacon
#

Hmm

#

Ok

#

Hmmm

#

The _APP_EXECUTOR_SECRET= needs a key?

analog token
#

Yes

#

It's empty?

mighty beacon
#

No no

analog token
#

Let's say you run

 docker exec -it appwrite sh

To enter the Appwrite container
And then you run

ping appwrite-executor
#

Do you get an answer?

#

Ohhhhh

#

Sorry

#

Can you redeploy the function again?

#

From the CLI

#

In the first deployment the appwrite-executor wasn't available, but now it is so it should work.

mighty beacon
#

Ok, I’ll try now.

mighty beacon
analog token
#

Interesting
It means there aren't connected to each other.

#

Redeploy solved anything?

mighty beacon
#

Building... failed

#

Same error

analog token
#

So, there is a real trouble between the connection of the main container to the executor one.
As the ping didn't work
And both of the containers are up and running.

mighty beacon
#

Hmm

#

I don't know what to do... I've never had so many problems with Appwrite as I do now, I've been using it since the first version, then going back to using it with the launch of database relationships, so since then I've been having headaches.

#

😥

analog token
#

Yes, that's a bummer

Have you run the migrate script after each upgrade?

mighty beacon
analog token
#

So let's try to retrack the steps
What values you have changes, if any in thes files

  • docker-compose.yml
  • .env
mighty beacon
#

Then I create a new instance, create the server in manual mode.

mighty beacon
#

Env file only changes all field related how email, host secret-key

#

Ahh... and force to use HTTPS

analog token
#

Something is not right with the docker networks
We can try one more thing that will reload the whole docker infrastructure

  1. Reboot the server
  2. Run docker ps to see that all the services are up and running
  3. Redeploying the function
mighty beacon
#
  1. the instance?
analog token
#

Yes

mighty beacon
#

made

#

failed

#

Same error

analog token
#

What are the results of this command

docker network inspect appwrite_appwrite --format '{{range .Containers}}{{println .Name .IPv4Address println }}{{end}}'
mighty beacon
analog token
#

Opps

#

Sorry I've removed the | grep part

#

Run it without it

mighty beacon
#

ok

#
appwrite 172.23.0.20/16 

appwrite-redis 172.23.0.4/16 

appwrite-schedule 172.23.0.13/16 

appwrite-worker-audits 172.23.0.7/16 

appwrite-influxdb 172.23.0.6/16 

appwrite-worker-databases 172.23.0.17/16 

appwrite-telegraf 172.23.0.3/16 

appwrite-worker-certificates 172.23.0.9/16 

appwrite-maintenance 172.23.0.18/16 

appwrite-worker-webhooks 172.23.0.10/16 

appwrite-worker-messaging 172.23.0.14/16 

appwrite-worker-mails 172.23.0.19/16 

appwrite-realtime 172.23.0.11/16 

appwrite-worker-deletes 172.23.0.8/16 

appwrite-mariadb 172.23.0.5/16 

appwrite-worker-builds 172.23.0.16/16 

appwrite-usage 172.23.0.15/16 

appwrite-worker-functions 172.23.0.12/16 

appwrite-traefik 172.23.0.2/16 
analog token
#

The executor is not connected to that network 🤔

mighty beacon
#

That’s what I was watching, he doesn’t appear on the list.

analog token
#

The docker-compose file isn't really matter
Maybe it's worth a try to rerun it

$# docker compose down
$# mv docker-compose.yml docker-compose.yml.old
$# curl https://appwrite.io/install/compose -o docker-compose.yml
$# docker compose up -d

$# docker network inspect appwrite_appwrite --format '{{range .Containers}}{{println .Name .IPv4Address }}{{end}}' | grep executor
mighty beacon
#

ok

#

Here execute docker commands with "sudo"

mighty beacon
analog token
#

Good

#

Now try to deploy the function

mighty beacon
#

OK

#

🙌

analog token
#

You can, download these two versions of docker-compose.yml file and compere to see what change caused the issue.

analog token
#

Let us know

mighty beacon
#

It has the same number of lines, 674 both

analog token
#

Maybe some extra space?

mighty beacon
#

Checking...

#

Downloading old docker-compose file from server

#

Hmmm

#

Doing an improved audit... I found differences.

analog token
#

Good
What are they

mighty beacon
#

The compose file from appwrite url have:
18799 characteres and 674 lines..

#

The old compose file from me server have:
18127 characteres and 675 lines

#

Hmm

#

At the end of the file there is an extra line

#

An extra space.

#

This is cause te problem?

analog token
#

not really

mighty beacon
#

[Solved] Error: Appwrite-executor with status code 0

mighty beacon
#

Now it’s working, thank you again @analog token 😊

#

Ops kkkk need change a language