Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does this support OpenBalena v4.1.x? #42

Open
alekbless opened this issue Oct 4, 2024 · 17 comments
Open

Does this support OpenBalena v4.1.x? #42

alekbless opened this issue Oct 4, 2024 · 17 comments

Comments

@alekbless
Copy link

I just tried setting up open-balena-admin to test this nice looking, and helpful software.

When accessing :8080 after all containers started, connected to PostgreSQL DB, i'am returned with: Not Found

Blank page with Not Found.

Using latest OpenBalena. Any suggestions on where to start debugging?

@brydenver2
Copy link

I am hoping the dev replies, but I have found that the issue with the NotFound has to do with the REACT_APP_BANNER_IMAGE env variable. I added an image but I believe the resolution is wrong as I just get a blank screen. I think, the banner image that is in the container was some how corrupted or missing for a default.

@brydenver2
Copy link

Actually after digging into the UI docker image I believe it is looking for the API version tag but it does not exist for API v30. I'm looking into the coding for the versions to see if any changes need to be made or if we can just you the last listed version.

@giuseppe443
Copy link
Contributor

giuseppe443 commented Nov 6, 2024

I am hoping the dev replies, but I have found that the issue with the NotFound has to do with the REACT_APP_BANNER_IMAGE env variable. I added an image but I believe the resolution is wrong as I just get a blank screen. I think, the banner image that is in the container was some how corrupted or missing for a default.

I think i have been able to fix that issue by adding
REACT_APP_BANNER_IMAGE: ./banner_illustration.svg
to the ui container in compose/services.yml right under the other values in environment:.

But i am pretty sure open-balena-admin has further problems with the new open balena update

@brydenver2
Copy link

I believe your right, i tried that and setting the API version to 0.185.0 and still no UI. Have you been able to get a version of open-balena working with Admin?

@giuseppe443
Copy link
Contributor

I believe your right, i tried that and setting the API version to 0.185.0 and still no UI. Have you been able to get a version of open-balena working with Admin?

Kinda, not 100% functionality but some of it. If i remeber right the only fixes i needed to do was the banner image thing, and further down in the services.yml was give the postgrest container the docker IP of the db container from openbalena.
So instead of
@db.${OPENBALENA_HOST_NAME}
i had to replace that with the docker IP openbalena_db.

Although this worked to give somewhat functionality, thev ssh from the web portal wouldnt work. I assume there have been some changes to how openbalena manages users .
I have since decided to revert to old openbalena version and just wait and see if this will get any updates

@dcaputo-harmoni
Copy link
Owner

@giuseppe443 @alekbless apologies for the delay in jumping in here - there have been a lot of updates to the open-balena-admin app since those docker scripts were built. The primary method of deploying it is in kubernetes via helm, and I've been keeping those up to date. If you look at the commit logs of the various open-balena-admin components (ui, postgres, remote) you should see the environment variables / other configuration items that have been added, and I would welcome any PR's to keep those docker scripts updated. Otherwise I'm sure I'll get around to this at some point, it's just not a focus at the moment.

@giuseppe443
Copy link
Contributor

giuseppe443 commented Feb 4, 2025

@giuseppe443 @alekbless apologies for the delay in jumping in here - there have been a lot of updates to the open-balena-admin app since those docker scripts were built. The primary method of deploying it is in kubernetes via helm, and I've been keeping those up to date. If you look at the commit logs of the various open-balena-admin components (ui, postgres, remote) you should see the environment variables / other configuration items that have been added, and I would welcome any PR's to keep those docker scripts updated. Otherwise I'm sure I'll get around to this at some point, it's just not a focus at the moment.

I finnally got around again to trying to upgrade. It does look like my issue might be unrelated?
When trying the ssh window to the container i am getting

DeviceConnect.js:76 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'id')
    at eval (DeviceConnect.js:76:1)

I am assuming there might be a difference how openbalena 2024 manages users, but honestly not sure.

Edit: and looking hrough the helms commits, i cant see anything related to the issue

@dcaputo-harmoni
Copy link
Owner

@giuseppe443 thanks for the notes, I am planning to upgrade openbalena to latest in the next few weeks, will post any changes to these repos necessary to support it after that process is complete.

@andreatondelli
Copy link

After fixing the database connection (above and here) and addressing the "Not Found" message (environment variable REACT_APP_BANNER_IMAGE), I now see a blank page.

Based on the previous messages, it looks like the dashboard is visible, although with reduced functionality. Is that correct, or did I misunderstand something?

Just to be able to use the tool while waiting for a permanent solution.

In case it can be useful, my console message under the blank page

index.js:76 Uncaught TypeError: Cannot read properties of undefined (reading 'resources')
    at Object.resource (index.js:76:1)
    at eval (deviceType.js:5:1)
    at 5130 (main.e70a06462544a7c8714d.js:1:194)
    at u (runtime.2a73d18749b01e5d3491.js:1:153)
    at main.e70a06462544a7c8714d.js:1:760535
    at u.O (runtime.2a73d18749b01e5d3491.js:1:476)
    at main.e70a06462544a7c8714d.js:1:760552
    at n (runtime.2a73d18749b01e5d3491.js:1:2000)
    at main.e70a06462544a7c8714d.js:1:71
74: const resource = (resource, version) => {
75:   const targetVer = semver.maxSatisfying(Object.keys(versions), `<=${version.split('v')[1]}`);
76:   return versions[targetVer].resources[resource];   // <=============[error here]===============
77: };

Thanks!

@giuseppe443
Copy link
Contributor

giuseppe443 commented Feb 5, 2025

After fixing the database connection (above and here) and addressing the "Not Found" message (environment variable REACT_APP_BANNER_IMAGE), I now see a blank page.

Based on the previous messages, it looks like the dashboard is visible, although with reduced functionality. Is that correct, or did I misunderstand something?

Just to be able to use the tool while waiting for a permanent solution.

In case it can be useful, my console message under the blank page

index.js:76 Uncaught TypeError: Cannot read properties of undefined (reading 'resources')
    at Object.resource (index.js:76:1)
    at eval (deviceType.js:5:1)
    at 5130 (main.e70a06462544a7c8714d.js:1:194)
    at u (runtime.2a73d18749b01e5d3491.js:1:153)
    at main.e70a06462544a7c8714d.js:1:760535
    at u.O (runtime.2a73d18749b01e5d3491.js:1:476)
    at main.e70a06462544a7c8714d.js:1:760552
    at n (runtime.2a73d18749b01e5d3491.js:1:2000)
    at main.e70a06462544a7c8714d.js:1:71
74: const resource = (resource, version) => {
75:   const targetVer = semver.maxSatisfying(Object.keys(versions), `<=${version.split('v')[1]}`);
76:   return versions[targetVer].resources[resource];   // <=============[error here]===============
77: };

Thanks!

alright i might have been able to reproduce this error, did you by any chance forget to add the v in config/activate?
Its suppost to be
export OPENBALENA_API_VERSION_TAG=v34.3.26

and not

export OPENBALENA_API_VERSION_TAG=34.3.26

(not sure if thats your api version)

@brydenver2

@andreatondelli
Copy link

andreatondelli commented Feb 5, 2025

Hi @giuseppe443, thanks to quick reply.

You're right, I have 34.3.17 instead of v34.3.17.

With the correct notation (including v), the login page is displayed.

Now I can see the dashboard pages, but they have no content, and I always get a "fetch failed" toast message. Is this correct, or is there another issue I can fix on my own to at least view the status of the devices or services while waiting for a proper version of Open-Balena-Admin?

UPDATE: In chrome console i show error related to resolution of name http://postgrest.mydomain.local:8000/device?limit=10&offset=0&order=id.asc net::ERR_NAME_NOT_RESOLVED

So probably i misconfigure something.

Thank you so much!

@giuseppe443
Copy link
Contributor

Hi @giuseppe443, thanks to quick reply.

You're right, I have 34.3.17 instead of v34.3.17.

With the correct notation (including v), the login page is displayed.

Now I can see the dashboard pages, but they have no content, and I always get a "fetch failed" toast message. Is this correct, or is there another issue I can fix on my own to at least view the status of the devices or services while waiting for a proper version of Open-Balena-Admin?

UPDATE: In chrome console i show error related to resolution of name http://postgrest.mydomain.local:8000/device?limit=10&offset=0&order=id.asc net::ERR_NAME_NOT_RESOLVED

So probably i misconfigure something.

Thank you so much!

check the logs of the postgrest container to see if its able to connect to the openbalena-db container.
If it isnt go to
docker network inspect <name of your openbalena docker network>
and copy down the name of the db container displayed there (in my case its open-balena-db-1)

then go to compose/service.yml and change everywhere the name of the network to the one openbalena is now using (the name has changed since v4)
and change the value of the env variable @db.${OPENBALENA_HOST_NAME}: too @open-balena-db-1: (or the name that you found with the docker network inspect command)

Then restart openbalena-admin and it should now work

@andreatondelli
Copy link

Hi @giuseppe443
i have already changed the hostname of the db and also the network according to my comments on other issue.

I realized later that it was the browser that couldn't resolve that address, so I had to add it to the client's hosts file.

Now I'm getting another error: a toast with message role "anon" does not exist.

Looking inside the container (docker logs -f open-balena-db-1), the more detailed error is

2025-02-05 13:33:42.711 UTC [238918] ERROR:  role "anon" does not exist
2025-02-05 13:33:42.711 UTC [238918] STATEMENT:  select set_config('search_path', $1, true), set_config('role', $2, true), set_config('request.jwt.claims', $3, true), set_config('request.method', $4, true), set_config('request.path', $5, true), set_config('request.headers', $6, true), set_config('request.cookies', $7, true)

Thank you

@giuseppe443
Copy link
Contributor

Hi @giuseppe443 i have already changed the hostname of the db and also the network according to my comments on other issue.

I realized later that it was the browser that couldn't resolve that address, so I had to add it to the client's hosts file.

Now I'm getting another error: a toast with message role "anon" does not exist.

Looking inside the container (docker logs -f open-balena-db-1), the more detailed error is

2025-02-05 13:33:42.711 UTC [238918] ERROR:  role "anon" does not exist
2025-02-05 13:33:42.711 UTC [238918] STATEMENT:  select set_config('search_path', $1, true), set_config('role', $2, true), set_config('request.jwt.claims', $3, true), set_config('request.method', $4, true), set_config('request.path', $5, true), set_config('request.headers', $6, true), set_config('request.cookies', $7, true)

Thank you

Cant say i have seen this problem before. Did you do a fresh install of openbalena v4.* or an update from an older version?

@giuseppe443 thanks for the notes, I am planning to upgrade openbalena to latest in the next few weeks, will post any changes to these repos necessary to support it after that process is complete.

I have found the problem and the solution. I havent created a PR because i am not sure if this is a problem of my own creation or not.
But the problem i had was that in open-balena-ui DeviceConnect.js was trying to set the username by getting it from session.object.username, but username wasnt available in the object.

i did a quick and dirty modification and it works like this

const userId = session.object.id;

      dataProvider.getList('user', {
        pagination: { page: 1, perPage: 1000 },
        sort: { field: 'id', order: 'ASC' },
        filter: { id: userId },
      })
      .then((user) => {
        const username = user.data[0].username;
        setUsername(username);
        return username;
      });

@andreatondelli
Copy link

Cant say i have seen this problem before. Did you do a fresh install of openbalena v4.* or an update from an older version?

I installed openbalena first time last month with version 4.1.311

@giuseppe443 thanks for the notes, I am planning to upgrade openbalena to latest in the next few weeks, will post any changes to these repos necessary to support it after that process is complete.

I have found the problem and the solution. I havent created a PR because i am not sure if this is a problem of my own creation or not. But the problem i had was that in open-balena-ui DeviceConnect.js was trying to set the username by getting it from session.object.username, but username wasnt available in the object.

i did a quick and dirty modification and it works like this

const userId = session.object.id;

      dataProvider.getList('user', {
        pagination: { page: 1, perPage: 1000 },
        sort: { field: 'id', order: 'ASC' },
        filter: { id: userId },
      })
      .then((user) => {
        const username = user.data[0].username;
        setUsername(username);
        return username;
      });

I don't find your pull request so i don't understand how to fix (quick and dirty :-D ) this piece of code

  const upsertUserPublicKey = (publicKeySsh) => {
    const keyTitle = 'open-balena-remote';
    return dataProvider
      .getList('user', {
        pagination: { page: 1, perPage: 1000 },
        sort: { field: 'id', order: 'ASC' },
        filter: { username: username },
      })
      .then((user) => {
        return dataProvider
          .getList('user-has-public key', {
            pagination: { page: 1, perPage: 1000 },
            sort: { field: 'id', order: 'ASC' },
            filter: { user: user.data[0].id, title: keyTitle },
          })
          .then((remoteKey) => {
            if (remoteKey.data.length > 0) {
              return dataProvider.update('user-has-public key', {
                id: remoteKey.data[0].id,
                data: { 'user': user.data[0].id, 'title': keyTitle, 'public key': publicKeySsh },
              });
            } else {
              return dataProvider.create('user-has-public key', {
                data: { 'user': user.data[0].id, 'title': keyTitle, 'public key': publicKeySsh },
              });
            }
          });
      });
  };

I try this without success

const userId = session.object.id;
  const upsertUserPublicKey = (publicKeySsh) => {
    const keyTitle = 'open-balena-remote';
    return dataProvider
      .getList('user', {
        pagination: { page: 1, perPage: 1000 },
        sort: { field: 'id', order: 'ASC' },
        filter: { id: userId },
      })
      .then((user) => {
        const username = user.data[0].username;
        setUsername(username);
        return username;
      });
  };

Thanks.

@giuseppe443
Copy link
Contributor

Cant say i have seen this problem before. Did you do a fresh install of openbalena v4.* or an update from an older version?

I installed openbalena first time last month with version 4.1.311

@giuseppe443 thanks for the notes, I am planning to upgrade openbalena to latest in the next few weeks, will post any changes to these repos necessary to support it after that process is complete.

I have found the problem and the solution. I havent created a PR because i am not sure if this is a problem of my own creation or not. But the problem i had was that in open-balena-ui DeviceConnect.js was trying to set the username by getting it from session.object.username, but username wasnt available in the object.
i did a quick and dirty modification and it works like this

const userId = session.object.id;

      dataProvider.getList('user', {
        pagination: { page: 1, perPage: 1000 },
        sort: { field: 'id', order: 'ASC' },
        filter: { id: userId },
      })
      .then((user) => {
        const username = user.data[0].username;
        setUsername(username);
        return username;
      });

I don't find your pull request so i don't understand how to fix (quick and dirty :-D ) this piece of code

  const upsertUserPublicKey = (publicKeySsh) => {
    const keyTitle = 'open-balena-remote';
    return dataProvider
      .getList('user', {
        pagination: { page: 1, perPage: 1000 },
        sort: { field: 'id', order: 'ASC' },
        filter: { username: username },
      })
      .then((user) => {
        return dataProvider
          .getList('user-has-public key', {
            pagination: { page: 1, perPage: 1000 },
            sort: { field: 'id', order: 'ASC' },
            filter: { user: user.data[0].id, title: keyTitle },
          })
          .then((remoteKey) => {
            if (remoteKey.data.length > 0) {
              return dataProvider.update('user-has-public key', {
                id: remoteKey.data[0].id,
                data: { 'user': user.data[0].id, 'title': keyTitle, 'public key': publicKeySsh },
              });
            } else {
              return dataProvider.create('user-has-public key', {
                data: { 'user': user.data[0].id, 'title': keyTitle, 'public key': publicKeySsh },
              });
            }
          });
      });
  };

I try this without success

const userId = session.object.id;
  const upsertUserPublicKey = (publicKeySsh) => {
    const keyTitle = 'open-balena-remote';
    return dataProvider
      .getList('user', {
        pagination: { page: 1, perPage: 1000 },
        sort: { field: 'id', order: 'ASC' },
        filter: { id: userId },
      })
      .then((user) => {
        const username = user.data[0].username;
        setUsername(username);
        return username;
      });
  };

Thanks.

ah sorry, that part of the comment was a different topic. not sure if it will help with your problem. But you can sure try it, its suppost to replace line 110

@andreatondelli
Copy link

Hi @giuseppe443

I don't think I quite understand what change I should try. Could you be more specific by telling me exactly where I need to make the modification and what I need to change? Maybe you could post the original piece of code and the modified one, just like I did.

Thanks!
Andrea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants