<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>The Wombelix Post - HackWeek</title><link href="https://dominik.wombacher.cc/" rel="alternate"/><link href="/feeds/tag_hackweek.atom.xml" rel="self"/><id>https://dominik.wombacher.cc/</id><updated>2025-12-08T00:00:00+01:00</updated><entry><title>Hack Week 25: VM Import UI flow for SUSE Virtualization (Harvester)</title><link href="https://dominik.wombacher.cc/posts/hack-week-25-vm-import-ui-flow-harvester.html" rel="alternate"/><published>2025-12-08T00:00:00+01:00</published><updated>2025-12-08T00:00:00+01:00</updated><author><name>Dominik Wombacher</name></author><id>tag:dominik.wombacher.cc,2025-12-08:/posts/hack-week-25-vm-import-ui-flow-harvester.html</id><summary type="html">&lt;!-- SPDX-FileCopyrightText: 2025 Dominik Wombacher &lt;dominik@wombacher.cc&gt; --&gt;
&lt;!--  --&gt;
&lt;!-- SPDX-License-Identifier: CC-BY-SA-4.0 --&gt;
&lt;p&gt;I finished my Hack Week 25 project last night, with just two days delay ;)
&lt;a class="reference external" href="https://hackweek.opensuse.org/projects/suse-virtualization-harvester-vm-import-ui-flow"&gt;SUSE Virtualization (Harvester): VM Import UI flow&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;But what exactly was it about and why did  ... &lt;a class="read-more" href="/posts/hack-week-25-vm-import-ui-flow-harvester.html"&gt; [read more]&lt;/a&gt;&lt;/p&gt;</summary><content type="html">&lt;!-- SPDX-FileCopyrightText: 2025 Dominik Wombacher &lt;dominik@wombacher.cc&gt; --&gt;
&lt;!--  --&gt;
&lt;!-- SPDX-License-Identifier: CC-BY-SA-4.0 --&gt;
&lt;p&gt;I finished my Hack Week 25 project last night, with just two days delay ;)
&lt;a class="reference external" href="https://hackweek.opensuse.org/projects/suse-virtualization-harvester-vm-import-ui-flow"&gt;SUSE Virtualization (Harvester): VM Import UI flow&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;But what exactly was it about and why did I pick that topic this year?
Some Background: SUSE Virtualization (Harvester) includes a
&lt;a class="reference external" href="https://docs.harvesterhci.io/v1.7/advanced/addons/vmimport"&gt;vm-import-controller addon&lt;/a&gt;
that allows migrating VMs from VMware and OpenStack. Currently, users need to write
manifest files and apply them with &lt;code&gt;kubectl&lt;/code&gt;. VMware and OpenStack admins might
not have deep Kubernetes knowledge yet. I wanted to integrate this feature directly
into the Harvester UI. This makes it accessible without writing YAML manually.&lt;/p&gt;
&lt;p&gt;The project was also a good opportunity to improve my Vue.js skills and
dive deeper into the Rancher Extensions and their architecture.&lt;/p&gt;
&lt;p&gt;Now it becomes a bit more nerdy and techy. Background knowledge in Harvester, reading
through the hack week project description and comments as well as the code in
&lt;a class="reference external" href="https://github.com/harvester/harvester-ui-extension/compare/main...wombelix:fork_harvester_harvester-ui-extension:suse-hack-week-25"&gt;my feature branch&lt;/a&gt;
should help you to easier follow along.&lt;/p&gt;
&lt;p&gt;The biggest technical challenge for me was the side navigation. I wanted
the new &lt;strong&gt;VM Import&lt;/strong&gt; menu group to appear only when the
&lt;a class="reference external" href="https://github.com/harvester/vm-import-controller"&gt;vm-import-controller&lt;/a&gt;
addon is enabled. Harvester behaves differently in standalone mode compared
to a normal Rancher environment. The usual &lt;cite&gt;ifHaveType&lt;/cite&gt; allowlist logic
for extensions did not work as I expected.&lt;/p&gt;
&lt;p&gt;I solved this by writing a helper function, &lt;code&gt;registerAddonSideNav&lt;/code&gt;.
It watches the specific addon resource in the cluster. If the addon is active,
the function adds the relevant menu items to the allowlist, which un-hides it.
If the addon is disabled, it removes / hides them again. The UI always reflects
the actual state of the cluster features, which I like very much.&lt;/p&gt;
&lt;p&gt;I implemented the custom create/edit forms for &lt;code&gt;VmwareSource&lt;/code&gt;, &lt;code&gt;OpenstackSource&lt;/code&gt;
and the &lt;code&gt;VirtualMachineImport&lt;/code&gt; resource. I also added support for the new
&lt;code&gt;OvaSource&lt;/code&gt; resource (included in the upcoming version 1.7.0). Users can enter
credentials directly in the form, which creates a new Kubernetes Secret. Or they can
alternatively select an existing secret if they want. The UI also validates inputs,
for example if the VM name follows RFC-1123 which is required by Kubernetes.&lt;/p&gt;
&lt;p&gt;The result is a decent UI flow that allows users to configure import sources and track
the status directly in the browser. I submitted the outcome of my hack week project
as Pull Request to the
&lt;a class="reference external" href="https://github.com/harvester/harvester-ui-extension"&gt;harvester-ui-extension repository&lt;/a&gt;.
Let's see if other people like it and I can help to bring in this, or a comparable feature,
into one of the next Harvester releases.&lt;/p&gt;
&lt;p&gt;GitHub Pull Request, you can also see it in action including a brief walkthrough here:
&lt;a class="reference external" href="https://github.com/harvester/harvester-ui-extension/pull/642"&gt;[feat] Introduce VM Import UI flow and ability to hide/unhide navi groups when addons are enabled/disabled&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This work picks up on a feature request from the community:
&lt;a class="reference external" href="https://github.com/harvester/harvester/issues/4663"&gt;[FEATURE] VM Migration Controller UI Flow&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;And completes the UI part that was outlined 2022 in the
&lt;a class="reference external" href="https://github.com/harvester/harvester/blob/master/enhancements/20220726-vm-migration.md#user-experience-in-detail"&gt;VM Controller - Harvester Enhancement Proposal (HEP)&lt;/a&gt;&lt;/p&gt;
&lt;dl class="docutils"&gt;
&lt;dt&gt;Highly recommended learning resources for Rancher Development and Extensions:&lt;/dt&gt;
&lt;dd&gt;&lt;ul class="first last simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="https://extensions.rancher.io/extensions/next/home"&gt;Rancher Extension&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="https://extensions.rancher.io/internal/docs"&gt;Rancher Developer Documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;/dl&gt;
</content><category term="Code"/><category term="SUSE"/><category term="HackWeek"/><category term="Harvester"/><category term="Virtualization"/><category term="VueJS"/><category term="Rancher"/><category term="OpenSource"/></entry><entry><title>SUSE Hack Week 2024 - Day 5</title><link href="https://dominik.wombacher.cc/posts/suse-hack-week-2024-day-5.html" rel="alternate"/><published>2024-11-22T00:00:00+01:00</published><updated>2024-11-22T00:00:00+01:00</updated><author><name>Dominik Wombacher</name></author><id>tag:dominik.wombacher.cc,2024-11-22:/posts/suse-hack-week-2024-day-5.html</id><summary type="html">&lt;!-- SPDX-FileCopyrightText: 2024 Dominik Wombacher &lt;dominik@wombacher.cc&gt; --&gt;
&lt;!--  --&gt;
&lt;!-- SPDX-License-Identifier: CC-BY-SA-4.0 --&gt;
&lt;p&gt;The problem with a failing test was driving me nuts &lt;a class="reference external" href="https://dominik.wombacher.cc/posts/suse-hack-week-2024-day-4.html"&gt;yesterday&lt;/a&gt;.
And I made a classic Engineer mistake, I didn't take a step back to clear my head and recharge  ... &lt;a class="read-more" href="/posts/suse-hack-week-2024-day-5.html"&gt; [read more]&lt;/a&gt;&lt;/p&gt;</summary><content type="html">&lt;!-- SPDX-FileCopyrightText: 2024 Dominik Wombacher &lt;dominik@wombacher.cc&gt; --&gt;
&lt;!--  --&gt;
&lt;!-- SPDX-License-Identifier: CC-BY-SA-4.0 --&gt;
&lt;p&gt;The problem with a failing test was driving me nuts &lt;a class="reference external" href="https://dominik.wombacher.cc/posts/suse-hack-week-2024-day-4.html"&gt;yesterday&lt;/a&gt;.
And I made a classic Engineer mistake, I didn't take a step back to clear my head and recharge. I continued to work
on the same problem till 1 AM, of course without a result, before I gave up. After some sleep and getting back to
work with a structured approach, it took me less than 15 minutes today to validate my theory and figure out what
the problem was... Damn, I'm happy I found it but all the time I wasted last night... Whatever, chasing the
white rabbit and getting a bit lost happens to the best sometimes.&lt;/p&gt;
&lt;p&gt;So, what was the issue? I want to know if a method was called with a specific set of args by using
&lt;code&gt;assert_called_once_with&lt;/code&gt;. Visually, the expected and actual values match. But I pass an object of
&lt;code&gt;model.Project&lt;/code&gt; and Mock checks if it's the same instance of the object, not if the content matches.
I create a &lt;code&gt;project&lt;/code&gt; object in my tests, and &lt;code&gt;pagure.lib.tasks_services.trigger_ci_build()&lt;/code&gt; does
the same. Even though the keys and values look identical, there are two different objects and the assertion fails.&lt;/p&gt;
&lt;p&gt;To solve it, I have to Mock &lt;code&gt;pagure.lib.query.get_authorized_project()&lt;/code&gt; and inject the &lt;code&gt;project&lt;/code&gt; object
that's created in the test. Then the whole thing works as I want it. Next step: Refactoring to use &lt;code&gt;model.PullRequest&lt;/code&gt;
object with access to all pull request related information instead of &lt;code&gt;pull_request_id&lt;/code&gt; and &lt;code&gt;pull_request_uid&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;That worked pretty well, writing the tests before the actual code feels weird at first but today that was a productivity
booster. It's much easier to focus on the next feature or refactoring, while I don't have to worry that silently
breaks something else. As long the other tests continue to pass, I'm still on track. I tried Test-Driven-Development
before, but I guess bad habits came back and I never went all-in with it for a longer session.&lt;/p&gt;
&lt;p&gt;This &lt;a class="reference external" href="https://pagure.io/pagure/pull-request/5511"&gt;Pull Request&lt;/a&gt; contains the current state and the outcome of my
Hack Week project. I finished around 2/3 of what was planned, I hope to get the rest done in the next week or two.&lt;/p&gt;
&lt;p&gt;I wrote a lot Python code before, including tests, but a couple days with an intensive focus helped a lot to
brush up my knowledge. Good chances that I not waste time with such a stupid problem next time ;) This week
re-affirmed that my passion is solving problems and writing code. I hope I can do that more regularly in future
and have the opportunity to free up time and attend SUSE Hack Week 25 as well.&lt;/p&gt;
</content><category term="Code"/><category term="SUSE"/><category term="openSUSE"/><category term="pagure"/><category term="HackWeek"/><category term="AWS"/><category term="CodePipeline"/><category term="Coding"/><category term="OpenSource"/></entry><entry><title>SUSE Hack Week 2024 - Day 4</title><link href="https://dominik.wombacher.cc/posts/suse-hack-week-2024-day-4.html" rel="alternate"/><published>2024-11-21T00:00:00+01:00</published><updated>2024-11-21T00:00:00+01:00</updated><author><name>Dominik Wombacher</name></author><id>tag:dominik.wombacher.cc,2024-11-21:/posts/suse-hack-week-2024-day-4.html</id><summary type="html">&lt;!-- SPDX-FileCopyrightText: 2024 Dominik Wombacher &lt;dominik@wombacher.cc&gt; --&gt;
&lt;!--  --&gt;
&lt;!-- SPDX-License-Identifier: CC-BY-SA-4.0 --&gt;
&lt;p&gt;Today was the focus on writing the pagure ci plugin and fine-tune my design and architecture assumptions on the way.
Basically transferring the outcome of &lt;a class="reference external" href="https://dominik.wombacher.cc/posts/suse-hack-week-2024-day-3.html"&gt;day 3&lt;/a&gt; into some code  ... &lt;a class="read-more" href="/posts/suse-hack-week-2024-day-4.html"&gt; [read more]&lt;/a&gt;&lt;/p&gt;</summary><content type="html">&lt;!-- SPDX-FileCopyrightText: 2024 Dominik Wombacher &lt;dominik@wombacher.cc&gt; --&gt;
&lt;!--  --&gt;
&lt;!-- SPDX-License-Identifier: CC-BY-SA-4.0 --&gt;
&lt;p&gt;Today was the focus on writing the pagure ci plugin and fine-tune my design and architecture assumptions on the way.
Basically transferring the outcome of &lt;a class="reference external" href="https://dominik.wombacher.cc/posts/suse-hack-week-2024-day-3.html"&gt;day 3&lt;/a&gt; into some code.
I decided to use a Test-Driven approach and to keep a close eye on existing pagure ci related tests while
I have to refactor some existing code too.&lt;/p&gt;
&lt;p&gt;Before I started to write tests, I wanted to validate a couple of assumptions on my pagure dev instance.
Unfortunately I had to fix a couple errors over there (file permissions, pagure_worker runs as apache and
not git user, db scheme forgotten to upgrade...) before I finally could start. It's always a good opportunity,
you learn most when things are broken. But I lost quite some coding time that way...&lt;/p&gt;
&lt;p&gt;Speaking of coding, the main challenge was that some information I want/need in my generic plugin are currently not passed.&lt;/p&gt;
&lt;p&gt;What we currently have doesn't leaves much room for the plugin to get additional data:&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="pygments-k"&gt;def&lt;/span&gt;&lt;span class="pygments-w"&gt; &lt;/span&gt;&lt;span class="pygments-nf"&gt;trigger_build&lt;/span&gt;&lt;span class="pygments-p"&gt;(&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;    &lt;span class="pygments-n"&gt;project_path&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;    &lt;span class="pygments-n"&gt;url&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;    &lt;span class="pygments-n"&gt;job&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;    &lt;span class="pygments-n"&gt;token&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;    &lt;span class="pygments-n"&gt;branch&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;    &lt;span class="pygments-n"&gt;branch_to&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;    &lt;span class="pygments-n"&gt;cause&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;    &lt;span class="pygments-n"&gt;ci_username&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;    &lt;span class="pygments-n"&gt;ci_password&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-p"&gt;):&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;What I want in future to make things more flexible:&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="pygments-k"&gt;def&lt;/span&gt;&lt;span class="pygments-w"&gt; &lt;/span&gt;&lt;span class="pygments-nf"&gt;trigger_build&lt;/span&gt;&lt;span class="pygments-p"&gt;(&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;        &lt;span class="pygments-n"&gt;project&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt; &lt;span class="pygments-n"&gt;model&lt;/span&gt;&lt;span class="pygments-o"&gt;.&lt;/span&gt;&lt;span class="pygments-n"&gt;Project&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;        &lt;span class="pygments-n"&gt;ci_url&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt; &lt;span class="pygments-nb"&gt;str&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;        &lt;span class="pygments-n"&gt;ci_job&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt; &lt;span class="pygments-nb"&gt;str&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;        &lt;span class="pygments-n"&gt;ci_token&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt; &lt;span class="pygments-nb"&gt;str&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;        &lt;span class="pygments-n"&gt;branch&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt; &lt;span class="pygments-nb"&gt;str&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;        &lt;span class="pygments-n"&gt;branch_to&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt; &lt;span class="pygments-nb"&gt;str&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;        &lt;span class="pygments-n"&gt;is_pull_request&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt; &lt;span class="pygments-nb"&gt;bool&lt;/span&gt; &lt;span class="pygments-o"&gt;=&lt;/span&gt; &lt;span class="pygments-kc"&gt;False&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;        &lt;span class="pygments-n"&gt;is_commit&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt; &lt;span class="pygments-nb"&gt;bool&lt;/span&gt; &lt;span class="pygments-o"&gt;=&lt;/span&gt; &lt;span class="pygments-kc"&gt;False&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;        &lt;span class="pygments-n"&gt;commit_hash&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt; &lt;span class="pygments-nb"&gt;str&lt;/span&gt; &lt;span class="pygments-o"&gt;=&lt;/span&gt; &lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;        &lt;span class="pygments-n"&gt;pull_request_id&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt; &lt;span class="pygments-nb"&gt;str&lt;/span&gt; &lt;span class="pygments-o"&gt;=&lt;/span&gt; &lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;        &lt;span class="pygments-n"&gt;pull_request_uid&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt; &lt;span class="pygments-nb"&gt;str&lt;/span&gt; &lt;span class="pygments-o"&gt;=&lt;/span&gt; &lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;        &lt;span class="pygments-n"&gt;ci_username&lt;/span&gt; &lt;span class="pygments-o"&gt;=&lt;/span&gt; &lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;        &lt;span class="pygments-n"&gt;ci_password&lt;/span&gt; &lt;span class="pygments-o"&gt;=&lt;/span&gt; &lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-p"&gt;)&lt;/span&gt; &lt;span class="pygments-o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;This could be further improved by passing &lt;code&gt;model.PullRequest&lt;/code&gt; instead of &lt;code&gt;pull_request_id&lt;/code&gt; and &lt;code&gt;pull_request_uid&lt;/code&gt;.
Then it's up to the pagure ci plugin to decide what data are needed, similar as with &lt;code&gt;project&lt;/code&gt;.
When I'm done with the &lt;code&gt;generic&lt;/code&gt; plugin then the existing &lt;code&gt;jenkins&lt;/code&gt; need some refactoring to work with the new parameters.&lt;/p&gt;
&lt;p&gt;I started to write the tests and iterate through the different plugin functionality.
All that went well until I hit a problem that still drives me crazy.
It shouldn't be hard to verify that a method was called with the expected args by using &lt;code&gt;assert_called_once_with&lt;/code&gt;.
But it throws a nice &lt;code&gt;AssertionError: expected call not found.&lt;/code&gt; even though &lt;code&gt;Expected&lt;/code&gt; and &lt;code&gt;Actual&lt;/code&gt; match:&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="pygments-n"&gt;E&lt;/span&gt;           &lt;span class="pygments-ne"&gt;AssertionError&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt; &lt;span class="pygments-n"&gt;expected&lt;/span&gt; &lt;span class="pygments-n"&gt;call&lt;/span&gt; &lt;span class="pygments-ow"&gt;not&lt;/span&gt; &lt;span class="pygments-n"&gt;found&lt;/span&gt;&lt;span class="pygments-o"&gt;.&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-n"&gt;E&lt;/span&gt;           &lt;span class="pygments-n"&gt;Expected&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt; &lt;span class="pygments-n"&gt;trigger_build&lt;/span&gt;&lt;span class="pygments-p"&gt;(&lt;/span&gt;&lt;span class="pygments-n"&gt;project&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-n"&gt;Project&lt;/span&gt;&lt;span class="pygments-p"&gt;(&lt;/span&gt;&lt;span class="pygments-mi"&gt;1&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;name&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt;&lt;span class="pygments-n"&gt;test&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;namespace&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt;&lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;url&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt;&lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;is_fork&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt;&lt;span class="pygments-kc"&gt;False&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;parent_id&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt;&lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;),&lt;/span&gt; &lt;span class="pygments-n"&gt;ci_url&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-s1"&gt;'https://ci.example.com/'&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;ci_job&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-s1"&gt;'pagure'&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;ci_token&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-s1"&gt;'random_token'&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;branch&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-s1"&gt;'feature'&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;branch_to&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-s1"&gt;'main'&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;is_pull_request&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-kc"&gt;True&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;is_commit&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-kc"&gt;False&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;commit_hash&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;pull_request_id&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-s1"&gt;'1'&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;pull_request_uid&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-s1"&gt;'720a0568c1274e74966e54b433b2003e'&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;ci_username&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;ci_password&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;)&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-n"&gt;E&lt;/span&gt;           &lt;span class="pygments-n"&gt;Actual&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt;   &lt;span class="pygments-n"&gt;trigger_build&lt;/span&gt;&lt;span class="pygments-p"&gt;(&lt;/span&gt;&lt;span class="pygments-n"&gt;project&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-n"&gt;Project&lt;/span&gt;&lt;span class="pygments-p"&gt;(&lt;/span&gt;&lt;span class="pygments-mi"&gt;1&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;name&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt;&lt;span class="pygments-n"&gt;test&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;namespace&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt;&lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;url&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt;&lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;is_fork&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt;&lt;span class="pygments-kc"&gt;False&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;parent_id&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt;&lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;),&lt;/span&gt; &lt;span class="pygments-n"&gt;ci_url&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-s1"&gt;'https://ci.example.com/'&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;ci_job&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-s1"&gt;'pagure'&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;ci_token&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-s1"&gt;'random_token'&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;branch&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-s1"&gt;'feature'&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;branch_to&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-s1"&gt;'main'&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;is_pull_request&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-kc"&gt;True&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;is_commit&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-kc"&gt;False&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;commit_hash&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;pull_request_id&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-s1"&gt;'1'&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;pull_request_uid&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-s1"&gt;'720a0568c1274e74966e54b433b2003e'&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;ci_username&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;ci_password&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;)&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;I take a break and try it again tomorrow after some sleep. Maybe I'm tired and missing something obvious.
But for me both look the same and there shouldn't be an assertion error.&lt;/p&gt;
&lt;p&gt;Let's hope I can figure out tomorrow what's going wrong here...&lt;/p&gt;
</content><category term="Code"/><category term="SUSE"/><category term="openSUSE"/><category term="pagure"/><category term="HackWeek"/><category term="AWS"/><category term="CodePipeline"/><category term="Coding"/><category term="OpenSource"/></entry><entry><title>SUSE Hack Week 2024 - Day 3</title><link href="https://dominik.wombacher.cc/posts/suse-hack-week-2024-day-3.html" rel="alternate"/><published>2024-11-20T00:00:00+01:00</published><updated>2024-11-20T00:00:00+01:00</updated><author><name>Dominik Wombacher</name></author><id>tag:dominik.wombacher.cc,2024-11-20:/posts/suse-hack-week-2024-day-3.html</id><summary type="html">&lt;!-- SPDX-FileCopyrightText: 2024 Dominik Wombacher &lt;dominik@wombacher.cc&gt; --&gt;
&lt;!--  --&gt;
&lt;!-- SPDX-License-Identifier: CC-BY-SA-4.0 --&gt;
&lt;p&gt;I continued where I left off on the &lt;a class="reference external" href="https://dominik.wombacher.cc/posts/suse-hack-week-2024-day-2.html"&gt;second day&lt;/a&gt;,
I was thinking about my architecture last night. AWS CodePipeline requires a bit of a custom implementation
within the AWS  ... &lt;a class="read-more" href="/posts/suse-hack-week-2024-day-3.html"&gt; [read more]&lt;/a&gt;&lt;/p&gt;</summary><content type="html">&lt;!-- SPDX-FileCopyrightText: 2024 Dominik Wombacher &lt;dominik@wombacher.cc&gt; --&gt;
&lt;!--  --&gt;
&lt;!-- SPDX-License-Identifier: CC-BY-SA-4.0 --&gt;
&lt;p&gt;I continued where I left off on the &lt;a class="reference external" href="https://dominik.wombacher.cc/posts/suse-hack-week-2024-day-2.html"&gt;second day&lt;/a&gt;,
I was thinking about my architecture last night. AWS CodePipeline requires a bit of a custom implementation
within the AWS Account, for example with AWS Lambda, to handle third party repos that are not GitHub, Gitlab or Bitbucket.
Maybe the pagure ci plugin should then a generic webhook style implementation. It defines the payload that is send and the expected
answer to update the PR status. But leaves the actual implementation up to the target system. That way, the plugin isn't
limited to one single service. I can use it to interact with AWS CodePipeline, or directly AWS CodeBuild, or any other system
were I can implement the server side logic myself.&lt;/p&gt;
&lt;p&gt;This shifts the scope of &lt;a class="reference external" href="https://hackweek.opensuse.org/projects/aws-codepipeline-ci-plugin-for-pagure-on-code-dot-opensuse-dot-org"&gt;my project&lt;/a&gt;
a little, but the outcome stays the same. I probably need two AWS Lambda functions, one to receive the webhook and trigger the build.
Another to receive status updates from CodeBuild phases and send them back to pagure. The AWS credentials for pagure need
permission to trigger the Lambda function for incoming requests. The function has permissions to interact with S3 and
CodePipeline / Codebuild. The outgoing Lambda uses the pagure ci token and gets it from a Env Var or AWS Secrets Manager.
Every component follows the least privilege principle.&lt;/p&gt;
&lt;p&gt;The pagure ci &lt;a class="reference external" href="https://pagure.io/pagure/blob/master/f/pagure/api/ci/jenkins.py#_33"&gt;jenkins plugin routes&lt;/a&gt; expect a &lt;code&gt;POST&lt;/code&gt;
request but the token is part of the URL. My plugin will use routes like &lt;code&gt;/ci/webhook/&amp;lt;repo&amp;gt;&lt;/code&gt; instead of
&lt;code&gt;/ci/jenkins/&amp;lt;repo&amp;gt;/&amp;lt;pagure_ci_token&amp;gt;/build-finished&lt;/code&gt;. The token has to be submitted as part of the request.
This keeps the token away from plain text logs, it's still a secret and should be treated like that.&lt;/p&gt;
&lt;p&gt;With the idea of a generic plugin in mind, Authentication becomes a challenge.
Calling an AWS Lambda on its function URL works best with a SIGv4 authentication request.
For any other, basic authentication seems the most common and reasonable way.
I have to figure out how to handle this properly. I don't want to add more fields to
pagure ci and the Web UI. First thing in mind: URI Scheme.
&lt;code&gt;https&lt;/code&gt; means plain request with basic auth based on &lt;code&gt;ci_username&lt;/code&gt; and &lt;code&gt;ci_password&lt;/code&gt;, if set.
&lt;code&gt;https+sigv4&lt;/code&gt; = AWS SIGv4 authentication request, uses &lt;code&gt;ci_username&lt;/code&gt; (Access Key) and &lt;code&gt;ci_password&lt;/code&gt; (Secret Key).&lt;/p&gt;
&lt;p&gt;I'll add the Lambda code and a IaC example (AWS CDK, AWS CloudFormation or OpenTofu/Terraform) to the pagure repo.
That way the end-to-end integration becomes a first-class citizen in pagure, not just the ci plugin.&lt;/p&gt;
&lt;p&gt;The time I could invest today was pretty limited and focused on further Architecture details.
I started with the pagure ci plugin, it is in an early stage but I'm confident that there is more to demonstrate tomorrow.&lt;/p&gt;
</content><category term="Code"/><category term="SUSE"/><category term="openSUSE"/><category term="pagure"/><category term="HackWeek"/><category term="AWS"/><category term="CodePipeline"/><category term="Coding"/><category term="OpenSource"/></entry><entry><title>SUSE Hack Week 2024 - Day 2</title><link href="https://dominik.wombacher.cc/posts/suse-hack-week-2024-day-2.html" rel="alternate"/><published>2024-11-19T00:00:00+01:00</published><updated>2024-11-19T00:00:00+01:00</updated><author><name>Dominik Wombacher</name></author><id>tag:dominik.wombacher.cc,2024-11-19:/posts/suse-hack-week-2024-day-2.html</id><summary type="html">&lt;!-- SPDX-FileCopyrightText: 2024 Dominik Wombacher &lt;dominik@wombacher.cc&gt; --&gt;
&lt;!--  --&gt;
&lt;!-- SPDX-License-Identifier: CC-BY-SA-4.0 --&gt;
&lt;p&gt;Second day, time to continue the work on
&lt;a class="reference external" href="https://hackweek.opensuse.org/projects/aws-codepipeline-ci-plugin-for-pagure-on-code-dot-opensuse-dot-org"&gt;my project&lt;/a&gt;
after a successful &lt;a class="reference external" href="https://dominik.wombacher.cc/posts/suse-hack-week-2024-day-1.html"&gt;first day&lt;/a&gt;.
The focus was on research, tests and design decisions for the AWS CodePipeline pagure ci  ... &lt;a class="read-more" href="/posts/suse-hack-week-2024-day-2.html"&gt; [read more]&lt;/a&gt;&lt;/p&gt;</summary><content type="html">&lt;!-- SPDX-FileCopyrightText: 2024 Dominik Wombacher &lt;dominik@wombacher.cc&gt; --&gt;
&lt;!--  --&gt;
&lt;!-- SPDX-License-Identifier: CC-BY-SA-4.0 --&gt;
&lt;p&gt;Second day, time to continue the work on
&lt;a class="reference external" href="https://hackweek.opensuse.org/projects/aws-codepipeline-ci-plugin-for-pagure-on-code-dot-opensuse-dot-org"&gt;my project&lt;/a&gt;
after a successful &lt;a class="reference external" href="https://dominik.wombacher.cc/posts/suse-hack-week-2024-day-1.html"&gt;first day&lt;/a&gt;.
The focus was on research, tests and design decisions for the AWS CodePipeline pagure ci plugin.
I want to make the set up on the AWS side as easy and maintenance free as possible.
But keep the code and customization logic in pagure lightweight too.&lt;/p&gt;
&lt;p&gt;The &lt;a class="reference external" href="https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html"&gt;Buildspec&lt;/a&gt;
that CodeBuild uses to run a build should be in the git repository and managed independently.
The current design and workflow I have in mind looks like this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;ol class="arabic"&gt;
&lt;li&gt;&lt;p class="first"&gt;User performs Git push to repository on pagure&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;pagure ci triggers AWS Lambda through function URL&lt;/p&gt;
&lt;blockquote&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;On commits and / or on pull-requests&lt;/li&gt;
&lt;li&gt;Payload contains: cause, repo, branch, branch_to&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;AWS Lambda gets buildspec from default branch and performs Git clone&lt;/p&gt;
&lt;blockquote&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Clone branch depends on received payload&lt;/li&gt;
&lt;li&gt;Buildspec is used from default branch to reduce risk of untrusted Pull Requests&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;AWS Lambda inject payload data into buildspec, generates zip archive and uploads it to S3&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;AWS CodePipeline detects changed file on S3&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;AWS CodePipeline retrieves archive and triggers AWS CodeBuild&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;AWS CodeBuild gets pagure ci token from AWS Secrets Manager&lt;/p&gt;
&lt;blockquote&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Injected as Environment Variable&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;AWS CodeBuild executes phases and reports status back to pagure ci&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;
&lt;p&gt;I still have to work out some details but I can start the implementation tomorrow.&lt;/p&gt;
&lt;p&gt;Another thing I stumbled across, interesting: The pagure ci code contains a &lt;code&gt;ci_username&lt;/code&gt;
and &lt;code&gt;ci_password&lt;/code&gt; field &lt;a class="reference external" href="https://pagure.io/pagure/c/9c6dee24463fdbfe88c21cfa4a6d7d3af87a5b7c?branch=master"&gt;since 5 years&lt;/a&gt;.
But for whatever reason, they were never added to the &lt;a class="reference external" href="https://pagure.io/pagure/blob/master/f/pagure/hooks/pagure_ci.py#_177"&gt;fields that are rendered in the Web UI&lt;/a&gt;.
Also, the WTForms field type for &lt;code&gt;ci_password&lt;/code&gt; was &lt;code&gt;StringField&lt;/code&gt;, it should be &lt;code&gt;PasswordField&lt;/code&gt; instead.&lt;/p&gt;
&lt;pre class="code diff literal-block"&gt;
&lt;span class="pygments-gh"&gt;diff --git a/pagure/hooks/pagure_ci.py b/pagure/hooks/pagure_ci.py&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gh"&gt;index 819b2a1b..38702a72 100644&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gd"&gt;--- a/pagure/hooks/pagure_ci.py&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gi"&gt;+++ b/pagure/hooks/pagure_ci.py&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gu"&gt;&amp;#64;&amp;#64; -121,7 +121,7 &amp;#64;&amp;#64; class PagureCiForm(FlaskForm):&lt;/span&gt;&lt;span class="pygments-w"&gt;
 &lt;/span&gt;       [wtforms.validators.Optional(), wtforms.validators.Length(max=255)],&lt;span class="pygments-w"&gt;
 &lt;/span&gt;   )&lt;span class="pygments-w"&gt;

&lt;/span&gt;&lt;span class="pygments-gd"&gt;-    ci_password = wtforms.StringField(&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gi"&gt;+    ci_password = wtforms.PasswordField(&lt;/span&gt;&lt;span class="pygments-w"&gt;
 &lt;/span&gt;       &amp;quot;Password to authenticate with if needed&amp;quot;,&lt;span class="pygments-w"&gt;
 &lt;/span&gt;       [wtforms.validators.Optional(), wtforms.validators.Length(max=255)],&lt;span class="pygments-w"&gt;
 &lt;/span&gt;   )&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gu"&gt;&amp;#64;&amp;#64; -174,7 +174,7 &amp;#64;&amp;#64; class PagureCi(BaseHook):&lt;/span&gt;&lt;span class="pygments-w"&gt;
 &lt;/span&gt;   form = PagureCiForm&lt;span class="pygments-w"&gt;
 &lt;/span&gt;   db_object = PagureCITable&lt;span class="pygments-w"&gt;
 &lt;/span&gt;   backref = &amp;quot;ci_hook&amp;quot;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gd"&gt;-    form_fields = [&amp;quot;ci_type&amp;quot;, &amp;quot;ci_url&amp;quot;, &amp;quot;ci_job&amp;quot;, &amp;quot;active_commit&amp;quot;, &amp;quot;active_pr&amp;quot;]&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gi"&gt;+    form_fields = [&amp;quot;ci_type&amp;quot;, &amp;quot;ci_url&amp;quot;, &amp;quot;ci_job&amp;quot;, &amp;quot;ci_username&amp;quot;, &amp;quot;ci_password&amp;quot;, &amp;quot;active_commit&amp;quot;, &amp;quot;active_pr&amp;quot;]&lt;/span&gt;&lt;span class="pygments-w"&gt;
 &lt;/span&gt;   runner = PagureCIRunner&lt;span class="pygments-w"&gt;

 &lt;/span&gt;   &amp;#64;classmethod&lt;span class="pygments-w"&gt;
&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;Last but not least, when I &lt;a class="reference external" href="https://pagure.io/pagure/pull-request/5491"&gt;refactored the pagure ci code 5 months ago&lt;/a&gt;
one problem stayed unnoticed: To add routes to a Flask Blueprint, the modules need to be imported before the Blueprint is registered with the app.
This was the case before the refactoring, but now the import to add the routes didn't happen and at the time the pagure ci plugin is activated, it's too late.
I doubt that I came up with the most elegant solution, but at least a functional ;)&lt;/p&gt;
&lt;pre class="code diff literal-block"&gt;
&lt;span class="pygments-gh"&gt;diff --git a/pagure/flask_app.py b/pagure/flask_app.py&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gh"&gt;index e9baa507..c22ea72c 100644&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gd"&gt;--- a/pagure/flask_app.py&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gi"&gt;+++ b/pagure/flask_app.py&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gu"&gt;&amp;#64;&amp;#64; -11,6 +11,8 &amp;#64;&amp;#64;&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;from __future__ import absolute_import, unicode_literals&lt;span class="pygments-w"&gt;

&lt;/span&gt;import datetime&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gi"&gt;+import importlib&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gi"&gt;+&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;import gc&lt;span class="pygments-w"&gt;
&lt;/span&gt;import logging&lt;span class="pygments-w"&gt;
&lt;/span&gt;import os&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gu"&gt;&amp;#64;&amp;#64; -135,6 +137,14 &amp;#64;&amp;#64; def create_app(config=None):&lt;/span&gt;&lt;span class="pygments-w"&gt;

 &lt;/span&gt;   from pagure.api import API  # noqa: E402&lt;span class="pygments-w"&gt;

&lt;/span&gt;&lt;span class="pygments-gi"&gt;+    # Load all configured pagure ci plugins once to initiate routes&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gi"&gt;+    # Required before Blueprint registration&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gi"&gt;+    ci_plugins = {}&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gi"&gt;+    for ci_type in pagure_config[&amp;quot;PAGURE_CI_SERVICES&amp;quot;]:&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gi"&gt;+        ci_plugins[ci_type] = importlib.import_module(&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gi"&gt;+            &amp;quot;pagure.api.ci.&amp;quot; + ci_type&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gi"&gt;+        )&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gi"&gt;+&lt;/span&gt;&lt;span class="pygments-w"&gt;
 &lt;/span&gt;   app.register_blueprint(API)&lt;span class="pygments-w"&gt;

 &lt;/span&gt;   from pagure.ui import UI_NS  # noqa: E402&lt;span class="pygments-w"&gt;
&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;I iterate over all configured pagure ci plugins and import them immediately before the API Blueprint is registered.
That way the routes, required to receive status updates, are added, variable &lt;code&gt;ci_plugins&lt;/code&gt; is kind of a dummy and never used.&lt;/p&gt;
&lt;p&gt;I was hoping for a bit more progress today, troubleshooting the route import bug and planning took quite a while.
Three days left, I'm still on track and confident that I have something usable at the end of the week.&lt;/p&gt;
</content><category term="Code"/><category term="SUSE"/><category term="openSUSE"/><category term="pagure"/><category term="HackWeek"/><category term="AWS"/><category term="CodePipeline"/><category term="Coding"/><category term="OpenSource"/></entry><entry><title>SUSE Hack Week 2024 - Day 1</title><link href="https://dominik.wombacher.cc/posts/suse-hack-week-2024-day-1.html" rel="alternate"/><published>2024-11-18T00:00:00+01:00</published><updated>2024-11-18T00:00:00+01:00</updated><author><name>Dominik Wombacher</name></author><id>tag:dominik.wombacher.cc,2024-11-18:/posts/suse-hack-week-2024-day-1.html</id><summary type="html">&lt;!-- SPDX-FileCopyrightText: 2024 Dominik Wombacher &lt;dominik@wombacher.cc&gt; --&gt;
&lt;!--  --&gt;
&lt;!-- SPDX-License-Identifier: CC-BY-SA-4.0 --&gt;
&lt;p&gt;I started the work on my project &lt;a class="reference external" href="https://hackweek.opensuse.org/projects/aws-codepipeline-ci-plugin-for-pagure-on-code-dot-opensuse-dot-org"&gt;AWS CodePipeline CI plugin for pagure on code.opensuse.org&lt;/a&gt;
with my nemesis, the mysterious &lt;code&gt;Unable to find object&lt;/code&gt; Exception that I couldn't  ... &lt;a class="read-more" href="/posts/suse-hack-week-2024-day-1.html"&gt; [read more]&lt;/a&gt;&lt;/p&gt;</summary><content type="html">&lt;!-- SPDX-FileCopyrightText: 2024 Dominik Wombacher &lt;dominik@wombacher.cc&gt; --&gt;
&lt;!--  --&gt;
&lt;!-- SPDX-License-Identifier: CC-BY-SA-4.0 --&gt;
&lt;p&gt;I started the work on my project &lt;a class="reference external" href="https://hackweek.opensuse.org/projects/aws-codepipeline-ci-plugin-for-pagure-on-code-dot-opensuse-dot-org"&gt;AWS CodePipeline CI plugin for pagure on code.opensuse.org&lt;/a&gt;
with my nemesis, the mysterious &lt;code&gt;Unable to find object&lt;/code&gt; Exception that I couldn't solve in the past. This problem blocked my PR to
&lt;a class="reference external" href="https://pagure.io/pagure/pull-request/5508"&gt;Bump test containers to F40, bump pip version pinning to align with rpm versions, address some tech debts in dependencies&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;One observation I've made last time was that the Database Session is rolled back and new created in the middle of the failing test.
I started my troubleshooting there to understand which session was created and re-created during the test.
And which one is actually used by the celery task that throws the exception.&lt;/p&gt;
&lt;p&gt;Before the rollback (&lt;a class="reference external" href="https://pagure.io/pagure/blob/master/f/tests/test_pagure_flask_dump_load_ticket.py#_171"&gt;line 171 in test_pagure_flask_dump_load_ticket.py&lt;/a&gt;)
&lt;code&gt;self.session&lt;/code&gt; and &lt;code&gt;self.db_session&lt;/code&gt; are not identical, afterwards they are.
That was somehow suspicious, but after taking a closer look and playing around with the session and db_session value,
it doesn't seem to make any difference and is a dead end.&lt;/p&gt;
&lt;p&gt;Then I checked the error message and stack trace once more,
the mock patch that injects a lambda function as override for &lt;code&gt;_maybe_wait&lt;/code&gt;
seem to cause the issues, a detail I didn't notice before:&lt;/p&gt;
&lt;pre class="code text literal-block"&gt;
tests/test_pagure_flask_dump_load_ticket.py:203:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pagure/lib/git.py:549: in update_ticket_from_git
    issue = pagure.lib.query.new_issue(
pagure/lib/query.py:1757: in new_issue
    pagure.lib.git.update_git(issue, repo=repo)
pagure/lib/git.py:165: in update_git
    _maybe_wait(queued)
/usr/lib/python3.12/site-packages/mock/mock.py:1100: in __call__
    return _mock_self._mock_call(*args, **kwargs)
/usr/lib/python3.12/site-packages/mock/mock.py:1104: in _mock_call
    return _mock_self._execute_mock_call(*args, **kwargs)
/usr/lib/python3.12/site-packages/mock/mock.py:1167: in _execute_mock_call
    result = effect(*args, **kwargs)
tests/test_pagure_flask_dump_load_ticket.py:43: in &amp;lt;lambda&amp;gt;
    mw.side_effect = lambda result: result.get()
/usr/lib/python3.12/site-packages/celery/result.py:1026: in get
    raise self.result if isinstance(
/usr/lib/python3.12/site-packages/celery/app/trace.py:477: in trace_task
    R = retval = fun(*args, **kwargs)
pagure/lib/tasks_utils.py:36: in decorated_function
    return function(self, session, *args, **kwargs)

&lt;/pre&gt;
&lt;p&gt;I checked older logs, they confirm that this trace came up earlier already...&lt;/p&gt;
&lt;p&gt;So what does &lt;code&gt;_maybe_wait&lt;/code&gt; do? well ...&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="pygments-k"&gt;def&lt;/span&gt;&lt;span class="pygments-w"&gt; &lt;/span&gt;&lt;span class="pygments-nf"&gt;_maybe_wait&lt;/span&gt;&lt;span class="pygments-p"&gt;(&lt;/span&gt;&lt;span class="pygments-n"&gt;result&lt;/span&gt;&lt;span class="pygments-p"&gt;):&lt;/span&gt;&lt;span class="pygments-w"&gt;
    &lt;/span&gt;&lt;span class="pygments-sd"&gt;&amp;quot;&amp;quot;&amp;quot;Function to patch if one wants to wait for finish.

    This function should only ever be overridden by a few tests that depend
    on counting and very precise timing.&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;    &lt;span class="pygments-k"&gt;pass&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;Seem to cover very few edge cases then?! How is it used by other tests?&lt;/p&gt;
&lt;pre class="code text literal-block"&gt;
tests/__init__.py:def create_maybe_waiter(method, getter):
tests/__init__.py:        self.app.get = create_maybe_waiter(self.app.get, self.app.get)
tests/__init__.py:        self.app.post = create_maybe_waiter(self.app.post, self.app.get)
tests/__init__.py:    &amp;quot;&amp;quot;&amp;quot;Helper function for definitely waiting in _maybe_wait.&amp;quot;&amp;quot;&amp;quot;
tests/test_pagure_flask_dump_load_ticket.py:    &amp;#64;patch(&amp;quot;pagure.lib.git._maybe_wait&amp;quot;)
tests/test_pagure_lib_drop_issue.py:    &amp;#64;patch(&amp;quot;pagure.lib.git._maybe_wait&amp;quot;, tests.definitely_wait)
tests/test_pagure_lib_drop_issue.py:    &amp;#64;patch(&amp;quot;pagure.lib.git._maybe_wait&amp;quot;, tests.definitely_wait)
tests/test_pagure_lib_git.py:        with patch(&amp;quot;pagure.lib.git._maybe_wait&amp;quot;, tests.definitely_wait):

&lt;/pre&gt;
&lt;p&gt;Twice in &lt;a class="reference external" href="https://pagure.io/pagure/blob/master/f/tests/test_pagure_lib_drop_issue.py"&gt;tests/test_pagure_lib_drop_issue.py&lt;/a&gt;,
once in &lt;a class="reference external" href="https://pagure.io/pagure/blob/master/f/tests/test_pagure_lib_git.py"&gt;tests/test_pagure_lib_git.py&lt;/a&gt;.
Always with &lt;code&gt;tests.definitely_wait&lt;/code&gt;, never in the way it's used in
&lt;a class="reference external" href="https://pagure.io/pagure/blob/master/f/tests/test_pagure_flask_dump_load_ticket.py"&gt;tests/test_pagure_flask_dump_load_ticket.py&lt;/a&gt;.
A test with &lt;code&gt;&amp;#64;patch(&amp;quot;pagure.lib.git._maybe_wait&amp;quot;, tests.definitely_wait)&lt;/code&gt; ended up in the same &lt;code&gt;Unable to find object&lt;/code&gt; exception.
After dropping the whole patch / mock,
&lt;a class="reference external" href="https://pagure.io/pagure/blob/master/f/tests/test_pagure_flask_dump_load_ticket.py#_40"&gt;tests/test_pagure_flask_dump_load_ticket.py::PagureFlaskDumpLoadTicketTests::test_dumping_reloading_ticket&lt;/a&gt;
is happy after all and passes.&lt;/p&gt;
&lt;p&gt;I have to admit, I still don't fully understand why the test was implemented like that.
My only explanation is, that some Celery behavior must have changed over time in a release.
And after removing / bumping the version pinning and using Fedora 40 it came up as a problem.&lt;/p&gt;
&lt;p&gt;Such tests are there to rely on, and if that one now passes without mocking, I'm fine with that.&lt;/p&gt;
&lt;p&gt;After finally fixing this annoying problem, one of four Goals that I have for the Hack Week is completed.&lt;/p&gt;
&lt;p&gt;Project Goals:&lt;/p&gt;
&lt;blockquote&gt;
&lt;ol class="arabic simple"&gt;
&lt;li&gt;Resolve issues with outdated python dependencies to ensure pagure runs on Python 3.11 and current package versions.
At least Fedora 40 python and python package versions. Fedora 41 would be even better.
This will also satisfy openSUSE Tumbleweed and Leap 15.6 package versions used on code.opensuse.org&lt;/li&gt;
&lt;li&gt;Validate if &lt;a class="reference external" href="https://bugzilla.opensuse.org/show_bug.cgi?id=1229570"&gt;https://bugzilla.opensuse.org/show_bug.cgi?id=1229570&lt;/a&gt; is fixed for code.opensuse.org and that all
required packages / backports landed in openSUSE:infrastructure:pagure&lt;/li&gt;
&lt;li&gt;Develop AWS CodePipeline pagure CI plugin and create an upstream pull request&lt;/li&gt;
&lt;li&gt;Backport Plugin into openSUSE pagure package on OBS till new upstream release&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;
&lt;p&gt;While I was waiting for my pagure PR to be reviewed and merged, I worked on Goal 2.
Based on the Bugzilla Ticket, the problem with the unsatisfied runtime dependency on cffi
is solved for &lt;a class="reference external" href="https://build.opensuse.org/project/show/openSUSE:infrastructure:pagure"&gt;openSUSE:infrastructure:pagure&lt;/a&gt;.
And still pending for openSUSE Leap 15.6 / SLES 15 SP6 in general.
But for know I only care about pagure on &lt;a class="reference external" href="https://code.opensuse.org"&gt;code.opensuse.org&lt;/a&gt;.
The OBS project had two broken packages that I fixed. Nothing else to do, Goal 2 completed.&lt;/p&gt;
&lt;p&gt;In preparation for Day 2, I updated my pagure dev system to the latest master branch version,
including the Patch from my pending PR. This allows me to develop the actual pagure CI plugin
for AWS CodePipeline on the latest build. Avoids running into issues because of old code and
refactoring to get it included into the pagure code base.&lt;/p&gt;
&lt;p&gt;I'm pretty happy with the progress of the first Day, can't wait how things going tomorrow :)&lt;/p&gt;
</content><category term="Code"/><category term="SUSE"/><category term="openSUSE"/><category term="pagure"/><category term="HackWeek"/><category term="AWS"/><category term="CodePipeline"/><category term="Coding"/><category term="OpenSource"/></entry></feed>