prisma / prisma-admin-feedback

Feedback for Prisma Admin (currently in invite-only preview)
6 stars 1 forks source link

ERROR: No cluster could be found for workspace '*' and cluster 'default' #91

Closed immanuelrosal closed 5 years ago

immanuelrosal commented 5 years ago

Went to slack to find out I'm not the only one experiencing this but Andy Deitler as well: https://prisma.slack.com/archives/CA491RJH0/p1552687055746500

He said:

Every time I run "prisma deploy" I am now getting this error. I had run one prisma instance with 1.29-beta to check out _admin, but now I'm trying to run a completely different instance with 1.28.5 and getting this no matter what I do.

ERROR: No cluster could be found for workspace '*' and cluster 'default'
{
  "data": {
    "generateClusterToken": null
  },
  "errors": [
    {
      "message": "No cluster could be found for workspace '*' and cluster 'default'",
      "locations": [
        {
          "line": 3,
          "column": 9
        }
      ],
      "path": [
        "generateClusterToken"
      ],
      "code": 222
    }
  ],
  "status": 200
}

Same thing happened to me. I came from 1.28, tried the 1.29-beta, and got the exact same error. Tried the following already:

  1. I went back to 1.28 and the error still persists: npm i -g prisma coming from the beta version that I installed using npm i -g prisma@beta. Confirmed that I was able to go back to version 1.28.5 by doing: prisma --version that results to:
    prisma/1.28.5 (windows-x64) node-v11.10.0
  2. Removed prisma completely: npm uninstall -g prisma
  3. Removing the docker containers: docker stop then docker rm
  4. Removing the docker images and re-downloading: docker image rm then docker-compose up -d
  5. Re-starting docker: docker-machine stop then docker-machine start
  6. Restarting my pc
  7. Removed prisma npm uninstall -g prisma then cleared the npm cache npm cache clean --force But to no avail.

I didn't have any issue like this prior to trying out 1.29-beta


docker-compose.yml

version: '3'
services:
  prisma:
    image: prismagraphql/prisma:1.28
    restart: always
    ports:
    - "4466:4466"
    environment:
      PRISMA_CONFIG: |
        port: 4466
        # uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
        # managementApiSecret: my-secret
        databases:
          default:
            connector: postgres
            host: postgres
            user: prisma
            password: prisma
            rawAccess: true
            port: 5432
            migrations: true
  postgres:
    image: postgres
    restart: always
    environment:
      POSTGRES_USER: prisma
      POSTGRES_PASSWORD: prisma
    volumes:
      - postgres:/var/lib/postgresql/data
volumes:
  postgres:

prisma.yml

endpoint: http://192.168.99.100:4466/s5/dev
datamodel: datamodel.prisma

generate:
  - generator: typescript-client
    output: ./generated/prisma-client/

docker info

Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 4
Server Version: 18.09.3
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: e6b3f5632f50dbc4e9cb6288d911bf4f5e95b18e
runc version: 6635b4f0c6af3810594d2770f662f34ddc15b40d
init version: fec3683
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.14.104-boot2docker
Operating System: Boot2Docker 18.09.3 (TCL 8.2.1)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 989.4MiB
Name: default
ID: UDMO:2FDG:XM4E:RPKA:ANB3:NGER:BSWH:S3EL:SZJN:2BGF:Y4B3:FIRF
Docker Root Dir: /mnt/sda1/var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Username: immanuelrosal
Registry: https://index.docker.io/v1/
Labels:
 provider=virtualbox
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
immanuelrosal commented 5 years ago

Update: It seems to be forcing me to login when I try to deploy in v1.28.5 which wasn't the case before I tried the beta; I didn't need to be Authenticated to deploy locally before. Maybe it's somewhere there?

dietler commented 5 years ago

I'll also add that I can't run anything in 1.29-beta again either. It seems this error continues now no matter what I remove or reset.

immanuelrosal commented 5 years ago

@dietler Tried removing my Internet connection via wifi and did prisma deploy:

 !    'ENOTFOUND': request to https://api.cloud.prisma.sh/ failed, reason: getaddrinfo ENOTFOUND api.cloud.prisma.sh api.cloud.prisma.sh:443

It look like it is, indeed, forcing a deploy on the cloud despite us pointing the endpoint on our local machine.

Checking the prisma-cli-core library if I could tweak something to fix it.

immanuelrosal commented 5 years ago

@dietler Found the culprit. So in the deploy script: There's this:

  if (
        workspace &&
        !workspace.startsWith('public-') &&
        !process.env.PRISMA_MANAGEMENT_API_SECRET &&
        (!this.env.cloudSessionKey || this.env.cloudSessionKey === '')
      ) {
        await this.client.login()
        cluster.clusterSecret = this.env.cloudSessionKey
  }

The solution for me was to add a .env file with the following key:

# inside .env file
PRISMA_MANAGEMENT_API_SECRET=<insert-any-value-here>

This is for v1.28.5

Let me know if it works for you.

immanuelrosal commented 5 years ago

So basically, I was still able to run Prisma Admin by setting the prisma image to v1.29-beta in the docker-compose.yml file but had a downgraded prisma-cli version of v1.28.5

version: '3'
services:
  prisma:
    image: prismagraphql/prisma:1.29-beta
    restart: always
    ports:
    - "4466:4466"
    environment:
      PRISMA_CONFIG: |
        port: 4466
        # uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
        managementApiSecret: my-secret
        databases:
          default:
            connector: postgres
            host: postgres
            user: prisma
            password: prisma
            rawAccess: true
            port: 5432
            migrations: true
  postgres:
    image: postgres
    restart: always
    environment:
      POSTGRES_USER: prisma
      POSTGRES_PASSWORD: prisma
    volumes:
      - postgres:/var/lib/postgresql/data
volumes:
  postgres:

prisma --version

prisma/1.28.5 (windows-x64) node-v11.12.0

image

huv1k commented 5 years ago

Hey, sorry but this is not related to prisma-admin, this is related to CLI.

pantharshit00 commented 5 years ago

Hi,

This seems to be related to the missing services bug fix that we have done which is currently in beta. https://github.com/prisma/prisma/pull/4194

Thanks, for catching this, we will investigate and fix this issue. We might need to transfer this issue to the main repository as well.

immanuelrosal commented 5 years ago

@Huvik I originally thought that it was. It was only after investigating that I saw it was a cli problem. My sincerest apologies.

@pantharshit00 Thanks!

dietler commented 5 years ago
# inside .env file
PRISMA_MANAGEMENT_API_SECRET=<insert-any-value-here>

@immanuelrosal That worked for me. Thanks!

petchpool commented 5 years ago
# inside .env file
PRISMA_MANAGEMENT_API_SECRET=<insert-any-value-here>

@immanuelrosal That worked for me. Thanks!

It worked for me too.

And don't forget to uncomment managementApiSecret and add your ApiSecret as well.

pantharshit00 commented 5 years ago

https://github.com/prisma/prisma/issues/4215