-
Notifications
You must be signed in to change notification settings - Fork 91
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
Generalize REST/client API for multiple users #1989
base: main
Are you sure you want to change the base?
Conversation
96e6c60
to
89c7bd8
Compare
This comment was marked as resolved.
This comment was marked as resolved.
89c7bd8
to
d00421a
Compare
Replacing an array variable with its first entry rightfully gives us the type check finger wagging.
Change `connnect()` and `call()` to accept a `uid` parameter instead of an address/superuser pair. Compute the Unix address within rest.js, move `getAddress()` from client for that. For now, just accept `0` for root and `null` for "current cockpit user", until we actually use that. Drop the `system` argument from `debug()`, and let the caller specify an appropriate string. We were only calling `debug()` from rest.js so far anyway, so that isn't very intrusive. Keep `isSystem` for the client.js API for the time being. That will be the next step, but let's not change everything at once.
Yay -- that was a hard piece of work, so let's record d00421a as a milestone where everything is green. I'll commit fixups from now on. There is still some things which I don't like, such as the repeated |
277d09e
to
d1f4652
Compare
Similarly to the previous commit for rest.js, change the API to accept an user id instead of an `isSystem` boolean. Change the Container, Pod, and Image properties accordingly. However, keep the UI logic and higher-level `isSystem` flags/helpers as-is for now, as this is intrusive enough. Clean up the often repeated "id + isSystem" index key calculation for the app's containers/images/pods states, and centralize it into a `makeKey()` helper. Put the uid in front, so that they have more natural sorting (in the UI we sort by owner first), and add a `-` in between so that they are easier to read.
d1f4652
to
bac14d1
Compare
@@ -607,7 +607,7 @@ class Containers extends React.Component { | |||
const lcf = this.props.textFilter.toLowerCase(); | |||
filtered = filtered.filter(id => this.props.containers[id].Name.toLowerCase().indexOf(lcf) >= 0 || | |||
(this.props.containers[id].Pod && | |||
this.props.pods[this.props.containers[id].Pod + this.props.containers[id].isSystem.toString()].Name.toLowerCase().indexOf(lcf) >= 0) || | |||
this.props.pods[utils.makeKey(this.props.containers[id].uid, this.props.containers[id].Pod)].Name.toLowerCase().indexOf(lcf) >= 0) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This added line is not executed by any test.
@@ -641,7 +641,7 @@ class Containers extends React.Component { | |||
filtered.forEach(id => { | |||
const container = this.props.containers[id]; | |||
if (container) | |||
(partitionedContainers[container.Pod ? (container.Pod + container.isSystem.toString()) : 'no-pod'] || []).push(container); | |||
(partitionedContainers[container.Pod ? utils.makeKey(container.uid, container.Pod) : 'no-pod'] || []).push(container); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This added line is not executed by any test.
((this.props.ownerFilter === "system" && !pod.isSystem) || | ||
(this.props.ownerFilter !== "system" && pod.isSystem)))) | ||
((this.props.ownerFilter === "system" && pod.uid !== 0) || | ||
(this.props.ownerFilter !== "system" && pod.uid === 0)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This added line is not executed by any test.
if (this.props.pods[a].isSystem !== this.props.pods[b].isSystem) | ||
return this.props.pods[a].isSystem ? 1 : -1; | ||
if (this.props.pods[a].uid !== this.props.pods[b].uid) | ||
return this.props.pods[a].uid === 0 ? 1 : -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This added line is not executed by any test.
@@ -667,7 +668,7 @@ export class ImageRunModal extends React.Component { | |||
|
|||
async validateContainerName(containerName) { | |||
try { | |||
await client.containerExists(this.isSystem(), containerName); | |||
await client.containerExists(this.isSystem() ? 0 : null, containerName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This added line is not executed by any test.
} | ||
}) | ||
.catch(ex => { | ||
console.warn("Failed to do Update Pod:", JSON.stringify(ex)); | ||
console.warn("Failed to do updatePod for uid", uid, ":", JSON.stringify(ex)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This added line is not executed by any test.
console.warn("$XDG_RUNTIME_DIR is not present. Cannot use user service."); | ||
return { path: "", superuser: null }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These 2 added lines are not executed by any test.
if (uid === 0) | ||
return { path: PODMAN_SYSTEM_ADDRESS, superuser: "require" }; | ||
|
||
throw new Error(`getAddress: uid ${uid} not supported`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This added line is not executed by any test.
const connection = {}; | ||
const decoder = new TextDecoder(); | ||
const user_str = (uid === null) ? "user" : (uid === 0) ? "root" : `uid ${uid}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This added line is not executed by any test.
if (window.debugging === "all" || window.debugging?.includes("podman")) | ||
console.debug("podman", system ? "system" : "user", ...args); | ||
console.debug("podman", ...args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This added line is not executed by any test.
Preparation and heavy lifting for https://issues.redhat.com/browse/COCKPIT-1086 . But this PR does not yet change visible behaviour or pixels.