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

validated bad container image URL #4283

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,23 @@ export class Deployment {

disposables.push(inputBox.onDidHide(() => resolve(null)));

disposables.push(inputBox.onDidChangeValue((e) => {
disposables.push(inputBox.onDidChangeValue(async (e) => {
if (validator.isURL(inputBox.value)) {
inputBox.validationMessage = undefined;
} else {
inputBox.validationMessage = 'Please enter a valid URL';
}

//check the mentioned url has image referece
inputBox.validationMessage = 'Checking the image info'
inputBox.enabled = false;
if (! await Oc.Instance.hasImageInfo(inputBox.value)) {
vrubezhny marked this conversation as resolved.
Show resolved Hide resolved
inputBox.validationMessage = 'Image referece is not valid'
} else {
inputBox.validationMessage = undefined;
}
inputBox.enabled = true;

}));

disposables.push(inputBox.onDidAccept((e) => {
Expand Down Expand Up @@ -218,7 +229,7 @@ export class Deployment {
inputBox.validationMessage = undefined;
} else {
inputBox.validationMessage = validateRFC1123DNSLabel('Must be a valid Kubernetes name', inputBox.value);
if (inputBox.validationMessage.length === 0) {
if (!inputBox.validationMessage) {
inputBox.validationMessage = undefined;
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/oc/ocWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,13 @@ export class Oc {
.catch((error) => namespaces);
}

public async hasImageInfo(url: string): Promise<boolean> {
const result = await CliChannel.getInstance().executeTool(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try this with docker.io/library/mongo. For me at least, it fails, so I can't deploy mongodb

Copy link
Contributor

@vrubezhny vrubezhny Jul 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

I could successfully deploy mongodb using URL docker.io/library/mongo. Some temporary/network problem?

PS: The only problem is that it has gone into CrashLoopBackOff immediately

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What version of the mongo DB image do you have? I have a31b196b207d which should be the latest image, since I recently deleted all my container images to free some space. Maybe this affects it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll double check on windows

Copy link
Contributor

@vrubezhny vrubezhny Jul 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I check it with OS Tools somehow?

Docker says the mongo:latest is a31b196b207d...

$ docker images --no-trunc
REPOSITORY                           TAG       IMAGE ID                                                                  CREATED         SIZE
mongo                                latest    sha256:a31b196b207d768e78f2af331869e91d13443f691080d3b93e8009a53391eeaa   2 weeks ago     796MB

However, the Pod's config says:

...
"containerStatuses": [
            {
                "containerID": "cri-o://4080a87a588b22b75135f996350ffe331dc13b6a4423d07f550450bb9d929f43",
                "image": "docker.io/library/mongo:latest",
                "imageID": "docker.io/library/mongo@sha256:1cd3951000020c1cb1757868e6cfd82667f57d80bb31fed8b585e26a8a1d960f",
...

which actually doesn't look like the same image... Does it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to reproduce the same error on Windows. I guess you can check the status of running the command that's listed here. I don't really know what's going on

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command result is an error for me, since it detects windows and linux versions of the docker image

Copy link
Contributor

@vrubezhny vrubezhny Jul 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command result is an error for me, since it detects windows and linux versions of the docker image

I didn't get this... So, you have the same error result while deploying the same image on Windows and *nix?
And what does it give to us?

... And yes, I think if you hit the docker pull rate limit, you'll probably won't be able to deploy any image till the counter is dropped. Not 100% sure though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be working now for me. Does it work for you, Victor?

new CommandText('oc', `image info ${url}`), undefined, false
);
return result.error && result.stderr.length > 0 ? false : true;
}

/**
* Returns the oc command to list all resources of the given type in the given (or current) namespace
*
Expand Down
Loading