Skip to content

Cannot create new stack #4

Open

Description

@3apa3a-b-ta3e

Honestly speaking, it's my first experience with this exact action and with Actions in general, so maybe I'm just doing something wrong.
Reason why I chooses your action among others — it supports both TokenAuth and stack creation with file from GIT address.

So, the situation:
I'm trying to push a set of parameters to my Portainer BE v2.17.1 launched on Synology, to create a new stack based on docker-compose.yml stored in my repo, that Portainer have to retrieve.
Already tried the same operation with Portainer's web interface with same user account — worked fine.
Tried with this config from GitHub Actions:

steps:
      - name: portainer
        uses: LGinC/portainer-stack-deploy@master
        with:
          serverurl: ${{ secrets.SYNOLOGY_PORTAINER_URL }}
          access_token: ${{ secrets.SYNOLOGY_PORTAINER_TOKEN }}
          endpointId: 2
          stackname: test-stack
          docker_compose_path: test-stack/docker-compose.yml
          repo_username: ${{ secrets.COMMON_GIT_USERNAME }}
          repo_password: ${{ secrets.SYNOLOGY_PORTAINER_GIT_ACCESS }}

Receiving this error:

Run LGinC/portainer-stack-deploy@master
with:
serverurl: ***
access_token: ***
endpointId: 2
stackname: test-stack
docker_compose_path: test-stack/docker-compose.yml
repo_username: ***
repo_password: ***
/usr/bin/docker run --name ghcriolgincportainerstackdeploy_436ca4 --label 6c0442 --workdir /github/workspace --rm -e "INPUT_SERVERURL" -e "INPUT_ACCESS_TOKEN" -e "INPUT_ENDPOINTID" -e "INPUT_STACKNAME" -e "INPUT_DOCKER_COMPOSE_PATH" -e "INPUT_REPO_USERNAME" -e "INPUT_REPO_PASSWORD" -e "INPUT_USERNAME" -e "INPUT_PASSWORD" -e "INPUT_IMAGENAMES" -e "INPUT_ENV" -e "INPUT_VARIABLES" -e "INPUT_DOCKER_COMPOSE" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/test-repo/test-repo":"/github/workspace" ghcr.io/lginc/portainer-stack-deploy
create stack failed: Invalid request payload
thread 'main' panicked at 'create stack failed', src/main.rs:284:13
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

Does Invalid request payload means that any of the passing parameters is wrong or missing?

Btw, it works (at least no errors reported) when the stack is already exist on Portainer.

Activity

  1. 3apa3a-b-ta3e commented on Apr 14, 2023

    @3apa3a-b-ta3e
    Author

    Just tested a refreshing of already created stack with edited docker-compose.yml — nope, it doesn't work, despite saying update stack id: 9, update stack success.
    Redeploy wasn't triggered on Portainer side, stack settings are the same as previous.

  2. LGinC commented on Apr 15, 2023

    @LGinC
    Owner

    Just tested a refreshing of already created stack with edited docker-compose.yml — nope, it doesn't work, despite saying update stack id: 9, update stack success. Redeploy wasn't triggered on Portainer side, stack settings are the same as previous.

    fixed it, you can try again

  3. LGinC commented on Apr 15, 2023

    @LGinC
    Owner

    if your repository is public, and you can remove repo_username and repo_password

        steps:
        - name: portainer stack deploy
          uses: LGinC/portainer-stack-deploy@master
          with:
            serverurl: ${{ secrets.SYNOLOGY_PORTAINER_URL }}
            access_token: ${{ secrets.SYNOLOGY_PORTAINER_TOKEN }}
            endpointId: 2
            stackname: test-stack
            docker_compose_path: test.yml
  4. 3apa3a-b-ta3e commented on Apr 15, 2023

    @3apa3a-b-ta3e
    Author

    Thank you, I've tried the latest fix, it works differently, but still unexpectedly, I have to test more.
    Creating stack from scratch is working fine when repo is public (repo_username and repo_password aren't supplied).
    But after changing a file specified at docker_compose_path and second commit a Portaner's stack becomes detached from GIT (and now looks like it was created with Editor option), but no stack settings were updated. Should a stack be deleted first and then redeployed as new one instead?
    Also on one update I've added a complex (long running) compose sequence (2-3 min), deployment step got response '504 Gateway Timeout' for ***/api/stacks/9?endpointId=2 and failed.

  5. LGinC commented on Apr 16, 2023

    @LGinC
    Owner

    Thank you, I've tried the latest fix, it works differently, but still unexpectedly, I have to test more. Creating stack from scratch is working fine when repo is public (repo_username and repo_password aren't supplied). But after changing a file specified at docker_compose_path and second commit a Portaner's stack becomes detached from GIT (and now looks like it was created with Editor option), but no stack settings were updated. Should a stack be deleted first and then redeployed as new one instead? Also on one update I've added a complex (long running) compose sequence (2-3 min), deployment step got response '504 Gateway Timeout' for ***/api/stacks/9?endpointId=2 and failed.

    github action runner node access your server timeout, maybe you can try again later

  6. JoDrm commented on Apr 18, 2023

    @JoDrm

    Hello, i have the same issue, but the only difference is I work on private repository.
    The error display is :

    create stack failed: failed to deploy a stack: Error response from daemon: invalid reference format
    thread 'main' panicked at 'create stack failed', src/main.rs:292:13
     "failed to deploy a stack: Error response from daemon: invalid reference format\n"
    

    My configuration behind :

    
          - name: deploy to portainer
            uses: LGinC/portainer-stack-deploy@1.0
            with:
              serverurl: ******
              access_token: ${{secrets.PORTAINER_ACCESSKEY}}
              repo_username: ${{secrets.DOCKERHUB_USERNAME}}
              repo_password: ${{secrets.DOCKERHUB_PASSWORD}}
              stackname: pr-${{steps.short-sha.outputs.sha}}
              variables: |
                ******
              env: |
               ****:****
              docker_compose: |
                version: "3.4"
                ....
    

    Btw, it works (at least no errors reported) when the stack is already exist on Portainer.

  7. JoDrm commented on Apr 20, 2023

    @JoDrm

    After a lot of trying I managed to deploy new stack (from the private repository) by incorporating the docker_compose field, which makes the created stacks detached from Github.
    When I try this time to create new stacks with the docker_compose_path field with this config:

          - name: deploy to portainer
            uses: LGinC/portainer-stack-deploy@1.0
            with:
              serverurl: ****
              access_token: ${{secrets.PORTAINER_ACCESSKEY}}
              repo_username: ${{secrets.GITHUB_USERNAME}}
              repo_password: ${{secrets.GITHUB_PAT}}
              stackname: ${{needs.format-branch-name.outputs.value}}
              env: |
                .....
              docker_compose_path: docker-compose-pr.yml
    

    I get this error:

    [2023-04-20T12:28:08Z INFO  portainer_deploy] Response { url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("portainer.legal-pilot.dev")), port: None, path: "/api/stacks", query: Some("endpointId=1&method=repository&type=2"), fragment: None }, status: 500, headers: {"content-type": "application/json", "date": "Thu, 20 Apr 2023 12:28:08 GMT", "x-content-type-options": "nosniff", "x-xss-protection": "1; mode=block", "content-length": "188"} }
    create stack failed: unable to clone git repository: failed to clone git repository: object not found "unable to clone git repository: failed to clone git repository: object not found"
    thread 'main' panicked at 'create stack failed', src/main.rs:292:13
    

    So I tried via the API to port directly with Postman with this body:

        "env": [
          ....
        ],
        "name": "pr-4bb4ac9",
        "repositoryAuthentication": true,
        "repositoryPassword": ****,
        "repositoryReferenceName": ****,
        "repositoryURL": ****,
        "repositoryUsername": ***,
        "composeFile": "docker-compose-pr.yml"
    

    I have this time my new stack which is created and which is well linked to Github.

    So what I understand is that if the stack does not exist it cannot be created from a private repository with the docker_compose_path parameter but it can be updated if it exists on Portainer beforehand.

    But also that with the docker_compose parameter followed by the written docker compose we can create and update a stack (which is therefore not subsequently linked to Github).

  8. LGinC commented on Apr 25, 2023

    @LGinC
    Owner

    After a lot of trying I managed to deploy new stack (from the private repository) by incorporating the field, which makes the created stacks detached from Github. When I try this time to create new stacks with the field with this config:docker_compose``docker_compose_path

          - name: deploy to portainer
            uses: LGinC/portainer-stack-deploy@1.0
            with:
              serverurl: ****
              access_token: ${{secrets.PORTAINER_ACCESSKEY}}
              repo_username: ${{secrets.GITHUB_USERNAME}}
              repo_password: ${{secrets.GITHUB_PAT}}
              stackname: ${{needs.format-branch-name.outputs.value}}
              env: |
                .....
              docker_compose_path: docker-compose-pr.yml
    

    I get this error:

    [2023-04-20T12:28:08Z INFO  portainer_deploy] Response { url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("portainer.legal-pilot.dev")), port: None, path: "/api/stacks", query: Some("endpointId=1&method=repository&type=2"), fragment: None }, status: 500, headers: {"content-type": "application/json", "date": "Thu, 20 Apr 2023 12:28:08 GMT", "x-content-type-options": "nosniff", "x-xss-protection": "1; mode=block", "content-length": "188"} }
    create stack failed: unable to clone git repository: failed to clone git repository: object not found "unable to clone git repository: failed to clone git repository: object not found"
    thread 'main' panicked at 'create stack failed', src/main.rs:292:13
    

    So I tried via the API to port directly with Postman with this body:

        "env": [
          ....
        ],
        "name": "pr-4bb4ac9",
        "repositoryAuthentication": true,
        "repositoryPassword": ****,
        "repositoryReferenceName": ****,
        "repositoryURL": ****,
        "repositoryUsername": ***,
        "composeFile": "docker-compose-pr.yml"
    

    I have this time my new stack which is created and which is well linked to Github.

    So what I understand is that if the stack does not exist it cannot be created from a private repository with the parameter but it can be updated if it exists on Portainer beforehand.docker_compose_path

    But also that with the parameter followed by the written docker compose we can create and update a stack (which is therefore not subsequently linked to Github).docker_compose

    some problem occured when create stack in private repo
    image
    image

  9. 3apa3a-b-ta3e commented on May 9, 2023

    @3apa3a-b-ta3e
    Author

    So you say that the problem is in Portainer API itself?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions