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

Allow user to rename app if buildpack is deleted #2321

Merged
merged 4 commits into from
Sep 20, 2022
Merged

Conversation

moleske
Copy link
Member

@moleske moleske commented Sep 16, 2022

cc @reedr3

Thank you for contributing to the CF CLI! Please read the following:

  • Please make sure you have implemented changes in line with the contributing guidelines
  • We're not allowed to accept any PRs without a signed CLA, no matter how small.
    If your contribution falls under a company CLA but your membership is not public, expect delays while we confirm.
  • All new code requires tests to protect against regressions.
  • Contributions must be made against the appropriate branch. See the contributing guidelines
  • Contributions must conform to our style guide. Please reach out to us if you have questions.

Does this PR modify CLI v6, CLI v7, or CLI v8?

Going to default branch, probably will request a backport to v8

Please see the contribution doc above or review Architecture Guide.

Description of the Change

A user had an app that they wanted to rename, but the buildpack the app was using had previously been deleted from the cloud foundry deployment. When the user called cf rename they received an error about the buildpack not being available. CAPI supports only renaming an app, but the cf cli is passing not just the rename on cf rename but the stack and buildpack information. This pr allows only rename by only passing to capi the new name information and not the stack and buildpack information.

We must be able to understand the design of your change from this description.
Keep in mind that the maintainer reviewing this PR may not be familiar with or
have worked with the code here recently, so please walk us through the concepts.

Why Is This PR Valuable?

What benefits will be realized by the code change? What users would want this change? What user need is this change addressing?

CAPI allows the user to only do renames via its API so we should also support this

Why Should This Be In Core?

Explain why this functionality should be in the cf CLI, as opposed to a plugin.
Not new functionality, just fixing existing functionality.

Applicable Issues

List any applicable Github Issues here

How Urgent Is The Change?

Is the change urgent? If so, explain why it is time-sensitive.

Other Relevant Parties

Who else is affected by the change?

reedr3 and others added 4 commits September 15, 2022 15:41
…RenameApplicationByNameAndSpaceGuid to use new UpdateApplicationName function.
- Use annonymous stuct for requestBody that only contains Name since the goal is to only have a name field
  - should we just go declare a real resuable struct or this truely a one off thing?
- Ran go generate ./... to get correct fake_cloud_controller_client
  - go generate ./... also made lots of other updated fakes.  Removed them for this feature but maybe we should make a pr just running a newer counterfeiter?
- Update tests to make sure everything is correctly nested
- Update tests to account for annoynmous struct

- next step is to run integration tests
- when calling `cf rename` on the previous commit, it would error stating "Unknown field Name"
- this was because the field is really name, but wasn't being marshalled due to annoymous struct
- create ApplicationNameOnly struct that marshalls correctly
- another question - should there be an integration test for this?
@moleske
Copy link
Member Author

moleske commented Sep 16, 2022

There's a few questions in the commit messages, but the one I'm most concerned for is should there be an integration test added.

Current Integration tests all passed on a cf-deployment with capi 1.137.0, though I didn't enable some experimental features like route_sharing so didn't test those

Copy link
Contributor

@reedr3 reedr3 left a comment

Choose a reason for hiding this comment

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

looks good to me!


updatedApp, warnings, err := actor.CloudControllerClient.UpdateApplicationName(newAppName, appGUID)
if err != nil {
return resources.Application{}, Warnings(warnings), err
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason why we are returning resources.Application{} instead of nil?

Copy link
Contributor

Choose a reason for hiding this comment

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

seems like the norm here... :)

@jdgonzaleza
Copy link
Contributor

jdgonzaleza commented Sep 20, 2022

There's a few questions in the commit messages, but the one I'm most concerned for is should there be an integration test added.

Current Integration tests all passed on a cf-deployment with capi 1.137.0, though I didn't enable some experimental features like route_sharing so didn't test those

@moleske Our pipelines have experimental features such as route_sharings already enabled :).
Also, I'm wondering if by modifying the current implementation we will be changing the expectation of current clients that are waiting for buildpacks and stacks to change when running cf rename . What do you think about this?
EDIT: Answering your question RE integration tests. It seems like current implementation it's only checking for the app's name change. So if we agree on changing the current behavior, I don't see it necessary to add int tests as we already have a bunch.

@moleske
Copy link
Member Author

moleske commented Sep 20, 2022

Also, I'm wondering if by modifying the current implementation we will be changing the expectation of current clients that are waiting for buildpacks and stacks to change when running cf rename . What do you think about this?

@PeteLevineA and I thought about this. We think it is not changing the expectation of the current clients. This is because cf rename says it will just rename an application. However the current behavior is that it will also attempt to restage with the buildpack and stack, even though the user didn't request those to be changed by cf rename. The support issue we saw was cf rename failed because the buildpack was renamed. If they wanted to change the buildpack or stack, they can use cf push -b <newbuildpack> -s <newstack>

Copy link
Contributor

@jdgonzaleza jdgonzaleza left a comment

Choose a reason for hiding this comment

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

LGTM

@moleske moleske merged commit eb52f6e into master Sep 20, 2022
@moleske moleske deleted the cf-cli-30-rename-app branch September 20, 2022 21:25
moleske added a commit that referenced this pull request Sep 20, 2022
* Add new UpdateApplicationName functions for actor and client. Change RenameApplicationByNameAndSpaceGuid to use new UpdateApplicationName function.
* Add UpdateApplicationName to cloud-controller-client interface.
* create ApplicationNameOnly struct that marshalls correctly

Co-authored-by: Ryker Reed <[email protected]>
moleske added a commit that referenced this pull request Sep 20, 2022
* Add new UpdateApplicationName functions for actor and client. Change RenameApplicationByNameAndSpaceGuid to use new UpdateApplicationName function.
* Add UpdateApplicationName to cloud-controller-client interface.
* create ApplicationNameOnly struct that marshalls correctly

Co-authored-by: Ryker Reed <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants