-
Notifications
You must be signed in to change notification settings - Fork 324
Issue 1296 fix cf labels not working #1306
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
Conversation
|
This is the relevant issue describing the problem this PR tries to fix: #1296 |
theghost5800
left a comment
There was a problem hiding this 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. @Kehrlann Could you please take a look at this PR and run integration tests with this change, thanks!
|
Got it. I'm away this week. Will pick this up on Monday. |
integration-test/src/test/java/org/cloudfoundry/operations/ApplicationsTest.java
Outdated
Show resolved
Hide resolved
...perations/src/main/java/org/cloudfoundry/operations/applications/_ManifestV3Application.java
Outdated
Show resolved
Hide resolved
|
@xiaocongli Please update the verification for the test, for example something like: this.cloudFoundryOperations
.applications()
.pushManifestV3(PushManifestV3Request.builder().manifest(manifest).build())
.then(
this.cloudFoundryOperations
.applications()
.get(GetApplicationRequest.builder().name(applicationName).build())
)
.map(ApplicationDetail::getId)
.flatMap(id ->
this.client
.applicationsV3()
.get(
org.cloudfoundry.client.v3.applications.GetApplicationRequest.builder()
.applicationId(id)
.build()
)
)
.as(StepVerifier::create)
.expectNextMatches(createdApp -> labels.equals(createdApp.getMetadata().getLabels()) && annotations.equals(createdApp.getMetadata().getAnnotations()))
.expectComplete()
.verify(Duration.ofMinutes(5));Feel free to write your own verification. |
...perations/src/main/java/org/cloudfoundry/operations/applications/_ManifestV3Application.java
Show resolved
Hide resolved
|
Hi @Kehrlann, Here is my understanding:
My points:
If V3 metadata have to be verified in operations layer, I guess the only way is to introduce a cross-layer read-back by injecting CloudFoundryClient into the operations test and calling I've also done a local test with help from @JNKielmann via a small app ManifestV3 manifest = ApplicationManifestUtilsV3.read(input)Input yaml: ---
applications:
- name: demo-app
memory: 256M
instances: 1
buildpacks:
- java_buildpack
env:
JAVA_OPTS: "-Xss512k"
metadata:
labels:
owner: team-a
feature: manifest-labels
example.com/component: web
app.kubernetes.io/name: demo-app
annotations:
description: "Sample app to reproduce manifest metadata behavior"Depending on latest 5.14.0.RELEASE, i got manifest as below: ---
applications:
- buildpacks:
- java_buildpack
env:
JAVA_OPTS: -Xss512k
instances: 1
memory: 256M
name: demo-app
version: 1With my local generated 4 cloudfoundry-xxx-5.15.0.BUILD-SNAPSHOT.jar, the output manifest was below(the different order of annotations and labels should not be a problem): ---
applications:
- buildpacks:
- java_buildpack
env:
JAVA_OPTS: -Xss512k
instances: 1
memory: 256M
metadata:
annotations:
description: Sample app to reproduce manifest metadata behavior
labels:
owner: team-a
feature: manifest-labels
app.kubernetes.io/name: demo-app
example.com/component: web
name: demo-app
version: 1Please correct me if anything is wrong. :) |
|
Like some of the other tests, what I am not sure is the version number in |
|
Hey @xiaocongli ! Thanks for the detailed answer.
Ideally, that would be true, and we would only be testing black-box style. That's what we would strive for if we started from scratch and had more bandwidth to work on this. But that's not the case, and not all APIs are implemented using the Operations abstraction. Currently, it's inconvenient to test the full behavior at that layer. So either we implement what we need to test it (probably too much work), or we accept that there is some mixing of concerns in our integration tests. You'll notice that the client is already injected in operations tests multiple times:
Given the shape of the project, "mixing layers" is a tradeoff I'll make gladly.
Yes, some metadata tests exist in
Ah, that's a remnant from older times from this project. I don't think it's super relevant anymore. The name mentions That's not great, now that this project is maintained beyond just Pivotal/... we should probably rename these PCF numbers to And, ideally, for v3 tests we'd have an annotation that checks for a specific v3 API, version but that's not implemented. Currently we use the v2 |
…anefest metadata after pushing
|
Hi @Kehrlann, I added the integration test code accordingly :) |
|
Thank you for your contribution, and your patience! |
According to the Cloud Foundry documentation on manifest metadata,
labelsandannotationsmust be nested under themetadatasection. In the current cf-java-client, they are placed directly under the application node, which is incorrect. As a result, attribute values are lost when using CF labels to identify extra component attributes.