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

✨ Run task pod as AnyUser. (#755) #756

Closed
wants to merge 15 commits into from

Conversation

konveyor-ci-bot[bot]
Copy link

To support running the task pods as AnyUser instead of root:

  • The task manager needs to no longer RunAs user root.
  • The /addon directory needs to be an EmptyDir. This is because the
    addon-analyzer Dockerfile cannot create the /addon directory as owned by
    the AnyUser.

Signed-off-by: Jeff Ortel [email protected]
Signed-off-by: Cherry Picker [email protected]

@jortel jortel added cherry-pick/release-0.5 This PR should be cherry-picked to release-0.4 branch. and removed cherry-pick/release-0.5 This PR should be cherry-picked to release-0.4 branch. labels Oct 10, 2024
@aufi
Copy link
Member

aufi commented Oct 11, 2024

The change in PR/backport looks good, but it is probably needed update golang.org/x/tools/cmd/goimports@latest version to something else than latest or update golang version in scripts to make the Hub build-able.

From a quick look, I'd suspect https://github.com/konveyor/tackle2-hub/blob/release-0.5/.github/workflows/main.yml#L24-L26 (go version, that is different to main branch)

@dymurray dymurray force-pushed the cherry-pick-pr755-release-0.5 branch from 6e7f1dd to 72fd8df Compare October 11, 2024 11:56
jortel and others added 15 commits October 11, 2024 07:59
When inserting a new record, GORM will also attempt to insert records
into tables refered to by many-to-many relationships on the inserted
record. This commit attempts to ensure that associations are omitted
when inserting records, and then the associations are added to the join
tables separately.

Also fixes some spots where the Transaction handler was in the wrong
spot in the chain or missing entirely.

Fixes #727

---------

Signed-off-by: Sam Lucidi <[email protected]>
Extends the use of the JSON serializer to the rest of the models.

Signed-off-by: Sam Lucidi <[email protected]>
Support multiple DB connections.
Using a custom sqlite driver that is a wrapper around the
[_standard_](https://pkg.go.dev/github.com/mattn/go-sqlite3) driver but
with a mutex around driver.TX and driver.Stmt as needed.

---------

Signed-off-by: Jeff Ortel <[email protected]>
Support pod retention settings.

The current policy is to delete pods as soon as completed (succeed or
failed).
Tackle users and support are used to troubleshooting by `oc debug` of
the task pods.
To support this, the task manager can terminate containers in pods as
needed and defer to the reaper to delete the pods. This would be
controlled new settings. By default succeeded tasks would be retained
their pods for 1 minute; failed tasks for 72 hours.
In all cases, failure to terminate running container will fallback to
deleting the pod immediately. The retention is best effort.

Running containers are terminated by `kill -p 1` This will only work for
linux containers.

---------

Signed-off-by: Jeff Ortel <[email protected]>
Seems the underlying sqlite driver keeps the lock until the connection
is closed.
The `Conn` acquires the mutex and holds it until the connection is
closed. The `Tx` and `Stmt` are no longer necessary.

---------

Signed-off-by: Jeff Ortel <[email protected]>
Generate primary keys instead of GORM.
This fixes the issue of GORM reusing the highest key after the model
with that ID is deleted.
When the PK is 0, GORM assigns the next (highest) ID.

This approach is to assign the ID ahead of time using a pool managed by
tackle.

---------

Signed-off-by: Jeff Ortel <[email protected]>
Add `/services/` endpoint.
Add `/services/kai/*` endpoint reverse-proxy to route defined in
KAI_URL.
Add auth scopes.

Related: konveyor/operator#376

---------

Signed-off-by: Jeff Ortel <[email protected]>
Post a _manifest_ file instead of separate multi-part form files.
Much simpler and more easily supports the addon staging the issues and
deps files on disk rather than streaming. The more atomic approach will
prevent transaction deadlock which can more easily occur when the
addon-analyzer builder reported an error (which it should never do).

The uploaded file contains markers used to delimited the documents.
`^]` = `\x1D` = GS (group separator).

```
^]BEGIN-MAIN^]
---
commit: 1234
^]END-MAIN^]
^]BEGIN-ISSUES^]
---
ruleset: ruleset-1
rule: rule-1
incidents:
...
^]END-ISSUES^]
^]BEGIN-DEPS^]
---
name: github.com/jboss
version: 4.0
labels:
- konveyor.io/language=java
- konveyor.io/otherA=dog
^]END-DEPS^]
```

Flow:
1. post (upload) manifest.yaml file.
2. post `ref` to the manifest file.
3. delete manifest file.

Orphaned files will be reaped.

---

The binding client needed to be updated to handle different file
encoding (MIME).

---------

Signed-off-by: Jeff Ortel <[email protected]>
To support running the task pods as _AnyUser_ instead of root:
- The task manager needs to no longer RunAs user root.
- The /addon directory needs to be an _EmptyDir_. This is because the
addon-analyzer Dockerfile cannot create the /addon directory as owned by
the _AnyUser_.

Signed-off-by: Jeff Ortel <[email protected]>
@dymurray dymurray force-pushed the cherry-pick-pr755-release-0.5 branch from 72fd8df to 29deafe Compare October 11, 2024 11:59
@dymurray dymurray closed this Oct 11, 2024
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

Successfully merging this pull request may close these issues.

5 participants