-
Notifications
You must be signed in to change notification settings - Fork 308
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
RDX: Work with deployment profiles #4655
RDX: Work with deployment profiles #4655
Conversation
Nothing is hooked up to it yet. Signed-off-by: Mark Yen <[email protected]>
This lets administrators supply a list of image references that describe which extensions are allowed to be installed (optionally with a tag). It's possible to set this to an empty list (disallowing any extensions). Signed-off-by: Mark Yen <[email protected]>
Signed-off-by: Mark Yen <[email protected]>
fi | ||
} | ||
|
||
write_allow_list() { # list |
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.
Maybe a test that passes more than one arg to this function, because currently it only handles 0 or 1 values in the list?
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.
It takes a single argument that is the JSON encoded list.
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.
I realized that, but none of the args contain a comma
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.
Ah, I thought I had one. Will fix.
|
||
@test 'when an extension is explicitly allowed, it can be installed' { | ||
write_allow_list '["rd/extension/basic:latest"]' | ||
rdctl extension install rd/extension/basic:latest |
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.
I would also run rdctl extension ls
and check for success and basic:latest
when the extension whitelist is in effect
rdctl extension uninstall rd/extension/basic | ||
} | ||
|
||
@test 'when an extension is not in the allowe list, it cannot be installed' { |
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.
typo: "allowed"
write_allow_list '["rd/extension/basic"]' | ||
ctrctl "${namespace_arg[@]}" tag rd/extension/basic rd/extension/basic:0.0.3 | ||
rdctl extension install rd/extension/basic:0.0.3 | ||
rdctl extension uninstall rd/extension/basic |
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.
Again, I would verify that the extension is actually installed, not just that ext install
didn't fail
@@ -142,9 +143,59 @@ export class ExtensionImpl implements Extension { | |||
return this._iconName as Promise<string>; | |||
} | |||
|
|||
async install(): Promise<boolean> { | |||
/** |
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.
Uncaught typo from an earlier PR: does't
at line 28 of pkg/rancher-desktop/main/extensions/extensions.ts
e2e test failures: On macOS:
|
On a second run, extensions failed at line 131 in test Only one log file seems useful, `extensions.e2e.spec.log1:
|
In a nutshell, the extensions e2e test is still flakey, would be better if that could get nailed down. |
- Typos - When checking allow list, explicitly check that the extensions are installed / not installed, as desired. - Make sure to add test cases with no, and multiple, items in the allow list. Signed-off-by: Mark Yen <[email protected]>
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.
Nothing in your logs are relevant; the only thing is failing to get version (which is unrelated to this PR, and is caught elsewhere).
rdctl.e2e.spec.ts:146:3
is because you had a local change (status: resp.status,xz).
Please attach full logs instead.
(I'm still trying to repro the intermittent failure locally.)
Signed-off-by: Mark Yen <[email protected]>
Eric's logs contains:
This is on an Intel mac (so nothing to do with the new network stack on Windows), using the moby backend. I'm mildly concerned that it's at 2GB RAM/2 vCPUs (for the VM), but that shouldn't matter still. Current best guess is that the container is flapping? Note though this is definitely past build and install testing extension, so that might be a different issue… |
Bats test failure on Linux:
|
I understand now these are getters because they're implementing an interface. Never mind... |
@@ -169,6 +172,7 @@ export const ExtensionErrorMarker = Symbol('extension-error'); | |||
export enum ExtensionErrorCode { |
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.
From a recent commit, @param id
at line 112 should be @param image
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.
Thanks!
@@ -211,6 +211,8 @@ class ExtensionManagerImpl implements ExtensionManager { | |||
|
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.
Another question about an older commit: why is the block through which urgency
is set at line 158 marked as const
when it's a temporary object?
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.
as const
just means "don't try to be smart, and derive the types as I wrote it"; in this case, it means that it becomes {success: string, warning: string, error: string}
, whereas without the as const
it's a Record<string, string>
. The latter doesn't work because <thing>[level]
could end up being undefined
(because it lost the information necessary to detect that <thing>[level]
, where level
is "success" | "warning" | "error"
, would always have a string value).
@@ -221,7 +223,7 @@ class ExtensionManagerImpl implements ExtensionManager { | |||
|
|||
tasks.push((async(id: string) => { | |||
try { | |||
return (await this.getExtension(id)).install(); | |||
return (await this.getExtension(id)).install(allowList); | |||
} catch (ex) { | |||
console.error(`Failed to install extension ${ id }`, 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.
Why is await Promise.all(tasks)
done just before the end of the surrounding for
-block and not after it? I would have expected the code to have this structure:
const tasks: Promise<any>[] = [];
for (...) {
tasks.push((async(id: string) => { ... })(ARGUMENT);
}
await Promise.all(tasks);
Instead the code is like this:
const tasks: Promise<any>[] = [];
for (...) {
tasks.push((async(id: string) => { ... })(ARGUMENT);
await Promise.all(tasks);
}
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.
Good catch; that is a bug.
@@ -221,7 +223,7 @@ class ExtensionManagerImpl implements ExtensionManager { | |||
|
|||
tasks.push((async(id: string) => { | |||
try { | |||
return (await this.getExtension(id)).install(); | |||
return (await this.getExtension(id)).install(allowList); | |||
} catch (ex) { | |||
console.error(`Failed to install extension ${ id }`, 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.
Another earlier-commit comment:
FWICT, tag ??= undefined;
is there just to get typescript to stop complaining that tag
is a let
-var and not a const
? If so, there should be a comment specifying that. But I would prefer putting this line before the let
line:
// eslint-disable-next-line prefer-const
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.
Ah, yeah, that works. (Ideally we could use const
but that breaks repo
.)
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.
Found some concerns in the code. Maybe even an actual bug (the scope thing with running all the async tasks).
I don't have anything specific about runtime issues, except that e2e fails repeatedly on Windows and bats failed on Linux. e2e passes on linux and macos (most of the time).
- extensions/types: Fix parameter name - extensions/manager: Wait for tasks _after_ starting all of them - extensions/manager: remove unnecessary assignment to `tag` Signed-off-by: Mark Yen <[email protected]>
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.
From your failing BATS run:
✗ empty allow list disables extension installs
…
no changes necessary
I don't understand why it would no changes necessary when we're updating the allowed list. My (successful) run says:
✓ empty allow list disables extension installs
settings updated; no restart required
This actually happens for all of the tests (that is, none of the tests managed to change the allow list), which is why they are failing. I believe
(Unrelated: please use bats/bats-core/bin/bats
rather than whatever bats
you have installed.)
@@ -221,7 +223,7 @@ class ExtensionManagerImpl implements ExtensionManager { | |||
|
|||
tasks.push((async(id: string) => { | |||
try { | |||
return (await this.getExtension(id)).install(); | |||
return (await this.getExtension(id)).install(allowList); | |||
} catch (ex) { | |||
console.error(`Failed to install extension ${ id }`, 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.
Good catch; that is a bug.
@@ -221,7 +223,7 @@ class ExtensionManagerImpl implements ExtensionManager { | |||
|
|||
tasks.push((async(id: string) => { | |||
try { | |||
return (await this.getExtension(id)).install(); | |||
return (await this.getExtension(id)).install(allowList); | |||
} catch (ex) { | |||
console.error(`Failed to install extension ${ id }`, 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.
Ah, yeah, that works. (Ideally we could use const
but that breaks repo
.)
@@ -169,6 +172,7 @@ export const ExtensionErrorMarker = Symbol('extension-error'); | |||
export enum ExtensionErrorCode { |
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.
Thanks!
My bats is a symlink to |
I'll retry the bats with the new changes. Everything else is fine now. |
Bats tests are still failing the same way on linux but when I run the commands manually they pass. Thought I was using everything in the Bats tests fail differently on macOS now. Running bats tests:
When I try to do this manually:
|
I don't know if this has been implemented: every allowed extension must internally also be added to the allowed images list, if allowed image checking has been enabled as well. Could this explain the different results? |
We build all the images locally, so the only thing the allowed images list might do is block downloading of the base image; but in that case, it would be a failure in building the image, not actually using it. |
Linux bats problems were caused by a rogue docker daemon running on the host. Stopping and uninstalling it solved the bats problems on linux. |
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.
looks good now
This handles #4341 — we now have a preference that can be used to limit the extensions that can be installed.
See attached BATS test case to see how it works.
rdctl set
intentionally doesn't support this, as it's more meant for use with locked profiles. But (as seen in the tests) it's possible to set it via the API.