Repository navigation
uapi: add new package - #30752
uapi: add new package#30752raspbeguy wants to merge 1 commit into
Conversation
feckert
left a comment
There was a problem hiding this comment.
I'm afraid I don't quite understand why this has to be compiled at startup. Can't that happen during the build process?
Or am I missing something here?
Regardless of my comments, Thanks for building the RESET API—nice work 👍
I'll give it a try right away.
|
The compile cannot happen in the build. uhttpd does it, at its own startup. When uhttpd starts, the plugin uhttpd-mod-ucode reads the handler source file and compiles it inside the uhttpd process (
This is also why the postinst restarts uhttpd. On an upgrade, the |
|
Updated to 3.3.0, released today: the version, the ucode-mod-io dependency (a request body that has not arrived in full 10 s after the request answers 400, instead of holding the request process until the script timeout of uhttpd), and the token-store template at /usr/share/uapi/config.template instead of the shipped /etc/config/uapi, which an upgrade always wrote back as .apk-new. The postinst and prerm guards stay as they are. |
|
Also, I'm currently working on v4 of uapi, which will be breaking and not compatible with the future old stable (and v3 won't work with new stable), because of the changes that will be part of next openwrt stable (netifd changes mostly). v4 is currently built and checked against the main branch. I wish the v4 release to be included in next openwrt stable, do you think there is a chance it happens? |
|
I'm evaluating it right now. But first I need to get an overview. I don't see any problem at the moment unless there's one I'm missing. |
|
@raspbeguy My initial tests with this version have been successful so far. I haven't tried everything yet, but what I've seen looks What does your timeline look like now. Should we still wait for version 3.4.0? Just a side note:
|
|
About the description that are too longs and the line wraps, do you suggest to fix it for future work or also the existing ? I can update my PR to 3.4.0 for sure, but as I explained I am planning to make the 4.0.0 for next openwrt major. Do you think I should release it earlier so we're sure it will be included then? |
| $(INSTALL_BIN) $(PKG_BUILD_DIR)/cli/uapi-token $(1)/usr/bin/ | ||
|
|
||
| $(INSTALL_DIR) $(1)/etc/config | ||
| $(INSTALL_CONF) $(PKG_BUILD_DIR)/files/etc/config/uapi $(1)/etc/config/ |
There was a problem hiding this comment.
The default UCI config comes from the upstream source archive; CONTRIBUTING.md asks for OpenWrt integration files to live in admin/uapi/files/ and be installed from there, since openwrt-iac/uapi is not hosted by OpenWrt. The same applies to 99-uapi on line 67.
Generated by Claude Code
There was a problem hiding this comment.
@raspbeguy That's an important point that was added recently. I almost overlooked it.
The current versions have already been released. So that was just a suggestion on my part that this could perhaps be improved in future UAPI versions. In my editor, I always see
This naturally raises a question about the future. Shouldn't we support multiple versions for example v2, v3, or the upcoming v4? Maybe there will even be a v5 at some point? I'm thinking about the API users. . They'll have to adapt their APIs every time, too. I've been experimenting with v3. If I use this version now, I'll have to adapt my code again when v4 comes out. Therefore, you should consider whether it might make sense to install the different versions side by side. You'll just have to decide on a case-by-case basis which version you need. |
|
v3 only runs on the current OpenWrt major and v4 only on the next one (the netifd changes), so one firmware never runs both. Each OpenWrt release should ship the one uapi major that matches it, mounted at its versioned path (/api/v3 today, /api/v4 with the next major), and clients pin that path. I write a migration guide between all major. So I do not plan side-by-side installs because this is literally impossible (at least between v3 and v4). I know this might be tedious but that's the same for all programs that are upgraded with breaking changes when upgrading openwrt major. |
|
Thanks for the explanation! Do I understand correctly that v3 no longer works with newer OpenWrt versions, so v4 is the only option? That doesn’t quite add up for me, so please correct me if I’m missing something. We could build both packages: if v4 needs new features from netifd master, it would only run on the latest OpenWrt, but v3 should keep working there too. Which netifd changes are we talking about? Installing both at once doesn’t need to be possible; users would just pick one. I understand the effort of maintaining several versions in parallel, and every version reaches EOL eventually. But as long as nothing technical speaks against it, I’d like to keep v3 usable for now, because this version would then also run on openwert-25.12, which is the current stable release. Downstream projects using the old API would otherwise have to switch immediately, even though v3 still works fine. A gradual move to v4 would make things much easier for the community. I'm not concerned with this first phase of integration. I'm thinking further ahead into the future. |
|
Hello @feckert, sorry for the delay. It was an intense week. I was certain that V4 couldn't work on 25.12. Turns out, it can. I just tested it. That changes my plans, sorry for the confusion. I'll release V4 very soon, which still has breaking changes. That way, v3 won't be included in official repos so we don't need to package it. The first officially packaged uapi will be V4. From there, I'll maintain the major uapi versions that are included in the major openwrt releases that are still supported. Does that sound like a plan for you? |
No problem; that happens to me, too.
That sounds good
We'd be happy to do it that way.
There's just one thing you need to clarify. When a new version is released for example v5, do you want to overwrite the old v4 one right away so that we only have one UAPI version in the system, or do you want to create a new package v5 and then delete the old v4 one after a migration period? |
|
I'd rather not have multiple packages. An OpenWrt major will keep the uapi major release it was shipped with. That's why I'll still support this major and periodically release patches, and if OpenWrt package policy enables it, minor releases with new non-breaking features. So an OpenWrt user can rest assured that there won't be any breaking change on uapi when staying in an OpenWrt major. I consider that, if a user switches to a newer OpenWrt major, they will do the work of preparing their migration path through all the packages they are using. That includes uapi, if a new uapi major has been released in the meantime. If they need time to adapt their use after the OpenWrt release, that's fine but they will need to stay on the old stable until they are ready. uapi announces in patches and minor releases most of the breaking changes and obsolete features that will happen in the next major, or at least in the main branch, so users can totally get ready even before the major release. Also I am confident that uapi has reached a cruise feature velocity and won't need as frequent major updates as it used to. Does that make sense to you? |
|
Ok so I knew there was something about v4 requiring a new netifd behaviour. I found it when cleaning my issue tracker and just implemented it. so yeah V4 will be only running on the new openwrt release. Which makes me wonder: if a package gets accepted, will it be added in current stable feed ? If so then I should start by packaging v3 or wait for next openwrt major to package v4. EDIT: got my answer by reading the doc. So as I understand it the package will not be included until next stable which is good news for me. |
|
From my perspective, there's no reason not to switch to v4 right away 👍. Are you done with v4 yet? Because the way I see it, it won't be long before a new stable branch of OpenWRT comes out. We don't have months anymore. Just to clarify: v3 still works in the master branch with the new FYI: The netifd version is occasionally updated to a new version in a stable release too. But you shouldn’t count on that. |
|
I'm not sure if v3 will work with main but that doesn't matter, I'm done working on it, I will hopefully release V4 tonight and correct the package PR right after. And also I will open another package PR for a facultative companion package for uapi, which enables uci to encode an additional unbound config file (which is sourced in the vanilla openwrt config but only editable by hand by default). EDIT: nevermind, I've already created it: #30753 |
|
For information here is the solved issue that leads to the netifd change (witch I contributed myself) that V4 takes advantage of: openwrt-iac/uapi#370 If netifd is updated within a stable and brings changes that breaks uapi, I guess it will need a uapi patch release. Which is acceptable I think. |
3110198 to
8a8acd5
Compare
|
@feckert v4 is now released. I updated the PR. So here is the list of the related PRs: |
|
Since I announced 4.0 and the good chance of uapi being in the next OpenWrt release, I received a feature contribution and made a few changes of my own, all already merged in main. Only then did I realize that I needed a new git workflow, with a maintenance branch for the minor that an OpenWrt release ships: that minor gets bug and security fixes for as long as the release is supported. I also decided on a minor cadence of one month. So I will probably do an exceptional 4.1.0 release at the start of December to settle this, and update this PR to it. I'll post a call for contributions on the forum, to include as many features as possible before the next OpenWrt release branches. If it's too late and only 4.0 is included, that's ok, I'll figure out something else. |
We'd be happy to do it that way
That means I'm holding off on merging
We can wait a little longer. Just let me know when you're ready for the merge. To keep better track of all the PRs, you can also mark the PR as a draft. |
|
Yes, that is right, with one nuance: a bug fix goes to the latest minor. Once 4.1.0 is out, a fix ships as 4.1.1, and 4.0.x gets no more releases. An older minor keeps getting fixes only when an OpenWrt release ships it. About branches, there is not one per major, but one per release line:
I will update it to 4.1.0 probably tonight, as we are now in December and I want to stick to my schedule. |
uapi is an HTTP REST API for OpenWrt, written in ucode. It runs inside uhttpd as a ucode handler and translates REST calls into uci and ubus operations, as a backend for Infrastructure-as-Code tools. The postinst restarts uhttpd, because uhttpd-mod-ucode compiles the handler only at startup. The uci-defaults script and the template of the token store are in files/. The OpenAPI document is installed without whitespace. uapi 4.x needs netifd e97e36f, so the package depends on a netifd version from that commit date or later. Release notes: https://github.com/openwrt-iac/uapi/releases/tag/v4.1.0 Signed-off-by: Guy Godfroy <guy.godfroy@gugod.fr>
|
@feckert I released 4.1.0. Next minor next month. From my side it good to go. If you merge it and OpenWrt issues a release candidate with this version it'll become a "LTS" version. |
📦 Package Details
Maintainer: @raspbeguy
Description:
uapi is an HTTP REST API for OpenWrt, written in ucode. It runs inside uhttpd as a ucode handler, with no daemon of its own, and translates REST calls into uci and ubus operations, as a backend for Infrastructure-as-Code tools such as Terraform. It serves curated endpoints under
/api/v4/, a raw uci passthrough, and an OpenAPI document that describes them.This PR now packages 4.1.0, as discussed above. uapi 4.x needs netifd e97e36f (openwrt-iac/uapi#370), so the package depends on
netifd (>=2026.07.17), the date of that commit. OpenWrt 25.12 does not carry it.The uci-defaults script and the template of the token store are in
files/. The postinst restarts uhttpd, because uhttpd-mod-ucode compiles the handler only at startup. The build installs the OpenAPI document without whitespace, withtools/compact_json.pyfrom the source archive.Companion PRs: unbound-uci-ext in #30753, and the LuCI app in openwrt/luci#9128.
The Makefile, the files, the commit message and this description were drafted with an LLM. I reviewed them and ran the tests below.
🔬 Run Testing Details
Built in the x86_64 SDK of 25.12.4 from the
v4.0.0tag archive. The APK holds the same files, with the same modes and contents, as the project's 4.0.0 APK. On the device:/api/v4and created/etc/config/uapiwith mode 0600.GET /api/v4/healthzanswered 4.0.0.test.shandtest-version.shpassed, and an authenticatedGET /api/v4/systemanswered./api/v3mount left only the/api/v4mount.apk del uapiremoved the mount and kept/etc/config/uapi.4.1.0 changes only the version of the sources.
PKG_HASHmatches the codeload tarball of thev4.1.0tag (sha256 checked twice, same content as the tag). It builds in the same SDK from thev4.1.0archive, and its APK holds the same files, with the same modes and contents, as the project's 4.1.0 APK. On the same device, the APK of this PR installed afterapk del uapi, which kept/etc/config/uapi.test.shandtest-version.shpassed,GET /api/v4/healthzanswered 4.1.0, and authenticated reads of/api/v4/systemand/api/v4/dhcp/cnamesanswered 200.✅ Formalities
messages, and the description says what it was used for.
If your PR contains a patch:
Not applicable: the package carries no patches.