appsody / appsody

Appsody command line tool. This repo will be archived soon.
https://appsody.dev
171 stars 46 forks source link

Appsody deploy always triggers build, even when there are no code changes #980

Open nastacio opened 4 years ago

nastacio commented 4 years ago

Describe the bug If you call appsody build and then appsody deploy in sequence, without any code modifications in between, appsody deploy will rebuild the whole application again before deployment.

To Reproduce Steps to reproduce the behavior:

  1. Create a new application with appsody init incubator/java-openliberty (same result with java-spring-boot2 and nodejs-express)

  2. Deploy the application to a target container with

    kubectl create namespace cloudlab
    appsody deploy -n cloudlab
  3. Start the deployment again:

    appsody deploy -n cloudlab

Expected behavior If no code was modified since the last build, then the code should not be rebuilt.

Actual behavior appsody deploy... triggers a full docker build of the code before initiating the deployment.

Environment Details (please complete the following information):

If applicable please specify:

Screenshots If applicable, add screenshots to help explain your problem.

Additional context I think the problem is the absence of app-deploy.yaml in the .dockerignore file for each stack.

One could argue this is a problem with the stacks, but it is probably best to fix this globally in the appsody cli (maybe appending the app-deploy.yaml to .dockerignore before builds) .

neeraj-laad commented 4 years ago

If you want to do deploy without a build, please use this flag while running appsody deploy:

--no-build Deploys the application without building a new image or modifying the deployment manifest file.

Just to explain the behaviour:

When appsody build is run

Even though the application files haven't changed, they are extracted again and for the build engine, these are new files every time - resulting in not using the previous layer.

To automatically do this would need us to not clean up extracted folder and to somehow track if changes have been made since last extract etc. which could be messy.

neeraj-laad commented 4 years ago

Closing this as working as designed.

@nastacio please feel free to re-open if you believe Appsody could do something better here.

nastacio commented 4 years ago

@neeraj-laad , apparently I cannot reopen the issue (no button for it) .

Users of appsody build have no knowledge of what to put in app-deploy.yaml and somehow I did not realize the build step is what was creating and updating the file with the contents of --pull-url (that information is never available at build stage) .

If you take OKD/OpenShift as an example, the push-url parameter will almost always be different than pull-url because the push URL is the external URL of the registry and the pull URL is the internal URL visible from inside the cluster. Due to that URL difference, one must specify a differentpull-url in appsody deploy, but using --no-build will prevent an update to app-deploy.yaml

In short, this adds to the current design virtually preventing the deployer from using the --no-build flag unless they are lucky enough to have the correct applicationImage value for their environment in app-deploy.yaml.

Best-case scenario, the deployer has permission to push a change applicationImage in app-deploy.yaml, fixing the problem for them and passing it along to the next user of the image.