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

How to deal with SNAPSHOT dependencies? #3341

Closed
ammachado opened this issue Jun 7, 2022 · 10 comments
Closed

How to deal with SNAPSHOT dependencies? #3341

ammachado opened this issue Jun 7, 2022 · 10 comments
Labels
area/build-operator Related to the internal image build operator kind/question Further information is requested

Comments

@ammachado
Copy link

ammachado commented Jun 7, 2022

I have the following scenario:

// camel-k: dependency=mvn:my.company:my-dependency:1.0.1.5-SNAPSHOT

package my.company.route;

import my.company.route.MainRoute;

public class MainRouteK extends MainRoute {
}

I would like to keep the route code inside the jar file, so I can test it locally using Camel Quarkus runtime instead of camel-k-runtime that is used on kamel local run.

When I first run the route in Camel-K, everything works as expected, during the integration kit build maven downloads the current snapshot of my dependency.

My question is how to deal when I update the maven snapshot dependency. Running kamel rebuild will get the new version of the dependency?

@squakez squakez added the kind/question Further information is requested label Jun 10, 2022
@squakez
Copy link
Contributor

squakez commented Jun 10, 2022

I think it depends on the refresh policy (see https://cwiki.apache.org/confluence/display/MAVENOLD/Repository+-+SNAPSHOT+Handling). I'd say that, if no changes in the maven configuration, we do follow the default policy. You can override it by changing the maven configuration in your IntegrationPlatform: https://camel.apache.org/camel-k/next/configuration/maven.html

@squakez squakez added the area/build-operator Related to the internal image build operator label Jun 10, 2022
@ammachado
Copy link
Author

I think that this behavior is not related to the refresh policy.

Since there's no change on the integration dependency list, it won't trigger the build of a new integration kit, which is when the dependencies are pulled. Yet a SNAPSHOT dependency might have changed.

@squakez
Copy link
Contributor

squakez commented Jun 13, 2022

Yeah, very good point. The fact you're reusing an Integration Kit won't trigger a rebuild. However I am not fully convinced we should change the behavior and rebuild also when a snapshot change. It may be a bit difficult to "calculate" when a snapshot change (I think we just use an hash from GAV now). The idea behind it is to have a very quick choice. If we start looking for other parameters we may create a slower user experience.

@tadayosi
Copy link
Member

It may be possible that if we observe a snapshot in the set of dependencies we mark the kit as snapshot and force rebuild every time. On the other hand, I agree with Pasquale that it would do a bit too much. Right now, you know you are using a snapshot in them and you can manually run kamel rebuild <your-app> to force rebuild, and it'd be enough.

@ammachado
Copy link
Author

By the way, I'm testing here with kamel rebuild and I'm getting the following error:

Error: could not rebuild integration my-route-k in namespace dev: integrations.camel.apache.org "my-route-k" is forbidden: User "ammachado" cannot update resource "integrations/status" in API group "camel.apache.org" in the namespace "dev"

I'm fiddling with cluster permissions here, it is an Openshift cluster. My user has cluster-reader rights and I am admin of the namespace.

Running oc auth can-i * integrations I receive a yes answer and running oc auth can-i * integrations/status I also receive yes as the answer, so I figure I have all the rights needed.

Which permissions are needed to run kamel rebuild?

Also, looking at the source code, it seems that kamel rebuild only delete the status field. I may be wrong, but I think that I can do the same with a oc edit command and setting status: {} and let the operator reconcile it. Doing the latter, the status is recreated with the original kit, since from what I could find, the operator tries to reuse an existing kit based on the traits and the dependencies.

@squakez
Copy link
Contributor

squakez commented Jun 15, 2022

Yes, that's correct. In this case an Integration rebuild needs an IntegrationKit rebuild as well. In order to have a refresh of the dependency you will need to identify the IntegrationKit and delete it as well, to make it sure it won't be reused.

@tadayosi
Copy link
Member

Currently, to really rebuild an integration with a new kit we need to do something like this:

$ kubectl delete ik <kit> # as mostly kits are 'platform' and cannot be removed with `kamel kit delete`
$ kamel rebuild <integration>

maybe should we provide some flag to kamel rebuild that also forces removing a relevant kit?

@johnpoth
Copy link
Member

maybe should we provide some flag to kamel rebuild that also forces removing a relevant kit?

Agreed. Although it would be cool not to have to specify an extra flag to rebuild the integration when using kamel rebuild (i.e kamel rebuild should always rebuild the integration and not reuse an existing integrationkit).

Implementation wise, we could maybe add something to Integration.Status like Integration.Status.ForceRebuild that would be used when checking for existing IntegrationKits.

@ammachado
Copy link
Author

By the way, I'm testing here with kamel rebuild and I'm getting the following error:

Error: could not rebuild integration my-route-k in namespace dev: integrations.camel.apache.org "my-route-k" is forbidden: User "ammachado" cannot update resource "integrations/status" in API group "camel.apache.org" in the namespace "dev"

I'm fiddling with cluster permissions here, it is an Openshift cluster. My user has cluster-reader rights and I am admin of the namespace.

Running oc auth can-i * integrations I receive a yes answer and running oc auth can-i * integrations/status I also receive yes as the answer, so I figure I have all the rights needed.

Which permissions are needed to run kamel rebuild?

@squakez
Copy link
Contributor

squakez commented Jul 13, 2022

The kamel rebuild should need no special permissions as it take care to clean .integration.status. If you can access the Integrations, then it would be enough. About this issue, I was having a deeper look at the rebuild and the original scope of this command was to rebuild an Integration after an operator upgrade. I've tested it and it seems it works as expected. The usage of SNAPSHOT dependency is something we don't recommend as it complicates the way we deliver a fast user experience. I am closing this issue for now, feel free to reach out for more info.

@squakez squakez closed this as completed Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build-operator Related to the internal image build operator kind/question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants