Unable to retrieve auth token: invalid username/password: unauthorized

I am trying to get back to some module creation for NS8.
I started the build of the LogitechMediaServer, but that is almost 1 year ago already.

So i decided to go through the New module tutorial to refresh the basics.
So i followed the steps and create a mymodule1 out of the ns8-kickstart template.
Building works fine as well as pushing the image to ghcr.io after creating a Person Access Token.
Now when i want to instantiate on my test host:
add-module ghcr.io/epetersen-lab/mymodule1:latest 1

What i get is:

Error: initializing source docker://ghcr.io/epetersen-lab/mymodule1:latest: unable to retrieve auth token: invalid username/password: unauthorized

First of all i do not understand why authentication is required as everything in this repo should be publicly available.
I then did a buildah login ghcr.io, but still no change.

What could i possibly have missed?

Full traceback:

root@ns8-test1:~# add-module ghcr.io/epetersen-lab/mymodule1:latest 1
<7>podman-pull-missing ghcr.io/epetersen-lab/mymodule1:latest
Trying to pull ghcr.io/epetersen-lab/mymodule1:latest...
Error: initializing source docker://ghcr.io/epetersen-lab/mymodule1:latest: unable to retrieve auth token: invalid username/password: unauthorized
Traceback (most recent call last):
  File "/usr/local/agent/bin/podman-pull-missing", line 35, in <module>
    subprocess.run(['podman', 'pull', image_url]).check_returncode()
  File "/usr/lib/python3.11/subprocess.py", line 502, in check_returncode
    raise CalledProcessError(self.returncode, self.args, self.stdout,
subprocess.CalledProcessError: Command '['podman', 'pull', 'ghcr.io/epetersen-lab/mymodule1:latest']' returned non-zero exit status 125.
Traceback (most recent call last):
  File "/var/lib/nethserver/cluster/actions/add-module/50update", line 64, in <module>
    agent.run_helper('podman-pull-missing', image_url, progress_callback=agent.get_progress_callback(0,33)).check_returncode()
  File "/usr/lib/python3.11/subprocess.py", line 502, in check_returncode
    raise CalledProcessError(self.returncode, self.args, self.stdout,
subprocess.CalledProcessError: Command '('podman-pull-missing', 'ghcr.io/epetersen-lab/mymodule1:latest')' returned non-zero exit status 1.
1 Like

The module must not end with a number. The first instance of mymodule1 would be mymodule11 which is confusing.

From New module tutorial | NS8 dev manual :

Name your repo with ns8- prefix (e.g. ns8-mymodule). Do not end your module name with a number, like ns8-baaad2!

I recommend to use a good name for the app/module like ns8-nextcloud from the start instead of using example names.

There are other templates available which include mariadb or postgres containers including backup/restore, See postgres, mysql or nodb template.

1 Like

Your are right, indeed i did not pay enough attention to that part.
What a stupid mistake, thanks for the pointer.

However, after starting from scratch this time with a valid name i still get that error. I then tried to pull the image directly with podman and then run the add-module command then i works.

I checked your Github and it seems you didn’t execute point 3 of GitHub - epetersen-lab/ns8-mymodule

It renames everything from kickstart to the name of your module.

Could you please share a link to the right guthub repository that you want to use for creating the new app?

The reason is that is did not push my local changes to the remote git repo, only the resulting image. Did push it now.

I am still fooling around so the link is: push ghcr.io/epetersen-lab/testmodule

1 Like

OK, so the app is at GitHub - epetersen-lab/ns8-testmodule

I found that the package isn’t created correctly, see Repository initialization · epetersen-lab/ns8-testmodule@46103da · GitHub

I’m going to try to reproduce that issue…

Hmm… i did not touch any files in the .github directory. Not sure if that is required to make the automatic stuff going.
So far i did not look into workflows, that is why i published the image manually with ghcr.io/epetersen-lab/testmodule docker://ghcr.io/epetersen-lab/testmodule:latest.

It works here, see GitHub - mrmarkuz/ns8-testmodule to compare.

What I did:

Use the kickstart template and create a new repo:

Add a name: (The name should be ns8-testmodule but I used ns8-testapp in the screenshot as ns8-testmodule wasn’t available anymore)

Clone it locally:

git clone git@github.com:mrmarkuz/ns8-testmodule.git

Change to right directory:

cd ns8-testmodule

Apply the renaming:

modulename=$(basename $(pwd) | sed 's/^ns8-//')
git mv imageroot/systemd/user/kickstart.service imageroot/systemd/user/${modulename}.service
git mv tests/kickstart.robot tests/${modulename}.robot
sed -i "s/kickstart/${modulename}/g" $(find .github/ * -type f)
git commit -a -m "Repository initialization"

Change the repobase from nethserver to mine in build-images.sh

repobase="${REPOBASE:-ghcr.io/mrmarkuz}"

Commit changes:

git commit -a -m "Change repobase"

Push to github:

git push

Wait until the workflows are ready.

Install using add-module:

add-module ghcr.io/mrmarkuz/testmodule:latest
1 Like

Install works straightaway…

1 Like

As you noticed the package could not be created by the workflow actions.
Inspecting the raw log showed an authentication error, which sounds a bit weird as everything is happening on the remote side.

Anyhow, that made me check my PAT token. Turns out i had 2 tokens, both valid. I removed the older one and then it seems everything works.

When publishing images from a local build host, the write:packages scope is required.

Tried to reproduce the issue by creating an additional token, but still everything worked as expected.

@mrmarkuz thanks for your efforts.

2 Likes