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

Use the configured kubernetes dev service flavor instead of trying to detect it from the image #38154

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Tanemahuta
Copy link

@Tanemahuta Tanemahuta commented Jan 12, 2024

Fixes #38152

Copy link

quarkus-bot bot commented Jan 12, 2024

Thanks for your pull request!

The title of your pull request does not follow our editorial rules. Could you have a look?

  • title should not contain an issue number (use Fix #1234 in the description instead)

This message is automatically generated by a bot.

@Tanemahuta Tanemahuta changed the title Fix #38152 Use the configured kubernetes dev service flavor instead of trying to detect it from the image Jan 12, 2024
Comment on lines 328 to 363
public Map<String, String> getKubeconfig() {
var image = getContainerInfo().getConfig().getImage();
if (image.contains("rancher/k3s")) {
return getKubernetesClientConfigFromKubeConfig(
return switch (flavor) {
case k3s -> getKubernetesClientConfigFromKubeConfig(
KubeConfigUtils.parseKubeConfig(KubeConfigUtils.replaceServerInKubeconfig(containerAddress.getUrl(),
getFileContentFromContainer(K3S_KUBECONFIG))));
} else if (image.contains("kindest/node")) {
return getKubernetesClientConfigFromKubeConfig(
case kind -> getKubernetesClientConfigFromKubeConfig(
KubeConfigUtils.parseKubeConfig(KubeConfigUtils.replaceServerInKubeconfig(containerAddress.getUrl(),
getFileContentFromContainer(KIND_KUBECONFIG))));
} else if (image.contains("k8s.gcr.io/kube-apiserver") ||
image.contains("registry.k8s.io/kube-apiserver")) {
return getKubernetesClientConfigFromKubeConfig(getKubeconfigFromApiContainer(containerAddress.getUrl()));
}

// this can happen only if the user manually start
// a DEV_SERVICE_LABEL labeled container with an invalid image name
throw new RuntimeException("The container with the label '" + DEV_SERVICE_LABEL
+ "' is not compatible with Dev Services for Kubernetes. Stop it or disable Dev Services for Kubernetes.");
case api_only ->
getKubernetesClientConfigFromKubeConfig(getKubeconfigFromApiContainer(containerAddress.getUrl()));
default -> throw new RuntimeException("The container with the label '" + DEV_SERVICE_LABEL
+ "' is not compatible with Dev Services for Kubernetes. Stop it or disable Dev Services for Kubernetes.");
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't use Java 17 language flavors in existing code, as it makes backports hard

Copy link
Member

Choose a reason for hiding this comment

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

Time has passed and I think we are now fine with it as I don't expect us to backport this to 3.2.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense

@geoand
Copy link
Contributor

geoand commented Jan 15, 2024

Thanks a lot for the contribution!

I added some small comments

@geoand
Copy link
Contributor

geoand commented Jan 16, 2024

I should also note that when the issues are addressed, we'll need the commits to be squashed

@geoand
Copy link
Contributor

geoand commented Feb 12, 2024

Can you please squash the commits and rebase onto the latest main?

Thanks

Instead of trying to detect it from the image.
Fixes quarkusio#38152
@gsmet
Copy link
Member

gsmet commented Jun 7, 2024

@geoand I rebased/squashed and fixed the formatting. I let you review if things are all good for you as I haven't checked the rationale of this patch.

@geoand
Copy link
Contributor

geoand commented Jun 7, 2024

I have to admit I am struggling to understand the change.

@metacosm you know more about this so maybe you can chime in

Copy link

quarkus-bot bot commented Jun 7, 2024

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit 9caf8c3.

✅ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

You can consult the Develocity build scans.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kubernetes Dev-Service using "api-only" will not work, if using "image.substitutor" for TestContainers
3 participants