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

Child resource cannot be registered by Chart v4 (Java SDK) #3119

Merged
merged 3 commits into from
Jul 30, 2024

Conversation

EronWright
Copy link
Contributor

@EronWright EronWright commented Jul 23, 2024

Proposed changes

Blocked on: pulumi/pulumi-java#1394

Updated Java SDK with better support for resource hydration, per pulumi/pulumi-java#1393.

Related issues (optional)

Closes #3057

@EronWright EronWright changed the title [WIP] Unable to rehydrate a resource that has required inputs Child resource cannot be registered by Chart v4 (Java SDK) Jul 23, 2024
Copy link

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

Copy link

codecov bot commented Jul 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 36.59%. Comparing base (c2a4d73) to head (88a2f6f).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3119      +/-   ##
==========================================
- Coverage   36.60%   36.59%   -0.02%     
==========================================
  Files          71       71              
  Lines        9275     9275              
==========================================
- Hits         3395     3394       -1     
- Misses       5541     5542       +1     
  Partials      339      339              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@EronWright EronWright self-assigned this Jul 23, 2024
EronWright added a commit to pulumi/pulumi-java that referenced this pull request Jul 25, 2024
<!--- 
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->

# Description

<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->

This PR makes a change to the code generator, to avoid any attempt to
validate the `args` in the "read" case (e.g. rehydration of a resource
reference) vs "register" case. This case is distinguished by the
presence of the URN option, as evidenced
[here](https://github.com/pulumi/pulumi-java/blob/59a8569adf5c1338cd1f869065c82bad3740530d/sdk/java/pulumi/src/main/java/com/pulumi/deployment/internal/DeploymentImpl.java#L1236-L1256).
Note that the args aren't used in the "read" case.

See also, the impact on pulumi-kubernetes:
pulumi/pulumi-kubernetes#3119

Fixes #1393 

## Examples
There's two variants to consider: resources with consts and resources
without consts; the latter didn't need a `makeArgs` function (until
now).

### Variant 1 (with consts)
Before:
```java
    public ConfigMap(String name, @nullable ConfigMapArgs args, @nullable com.pulumi.resources.CustomResourceOptions options) {
        super("kubernetes:core/v1:ConfigMap", name, makeArgs(args), makeResourceOptions(options, Codegen.empty()));
    }

    private ConfigMap(String name, Output<String> id, @nullable com.pulumi.resources.CustomResourceOptions options) {
        super("kubernetes:core/v1:ConfigMap", name, null, makeResourceOptions(options, id));
    }

    private static ConfigMapArgs makeArgs(@nullable ConfigMapArgs args) {
        var builder = args == null ? ConfigMapArgs.builder() : ConfigMapArgs.builder(args);
        return builder
            .apiVersion("v1")
            .kind("ConfigMap")
            .build();  // exception thrown here if the resource has any required inputs
    }
```

After:
```java
    public ConfigMap(String name, @nullable ConfigMapArgs args, @nullable com.pulumi.resources.CustomResourceOptions options) {
        super("kubernetes:core/v1:ConfigMap", name, makeArgs(args, options), makeResourceOptions(options, Codegen.empty()));
    }

    private ConfigMap(String name, Output<String> id, @nullable com.pulumi.resources.CustomResourceOptions options) {
        super("kubernetes:core/v1:ConfigMap", name, null, makeResourceOptions(options, id));
    }

    private static ConfigMapArgs makeArgs(@nullable ConfigMapArgs args, @nullable com.pulumi.resources.CustomResourceOptions options) {
        if (options != null && options.getUrn().isPresent()) {
            return null;
        }
        var builder = args == null ? ConfigMapArgs.builder() : ConfigMapArgs.builder(args);
        return builder
            .apiVersion("v1")
            .kind("ConfigMap")
            .build();
    }
```

### Variant 2 (without consts)

Before: 
```java
    public Provider(String name, @nullable ProviderArgs args, @nullable com.pulumi.resources.CustomResourceOptions options) {
        super("kubernetes", name, args == null ? ProviderArgs.Empty : args, makeResourceOptions(options, Codegen.empty()));
    }
```

After:
```java
    public Provider(String name, @nullable ProviderArgs args, @nullable com.pulumi.resources.CustomResourceOptions options) {
        super("kubernetes", name, makeArgs(args, options), makeResourceOptions(options, Codegen.empty()));
    }

    private static ProviderArgs makeArgs(@nullable ProviderArgs args, @nullable com.pulumi.resources.CustomResourceOptions options) {
        if (options != null && options.getUrn().isPresent()) {
            return null;
        }
        return args == null ? ProviderArgs.Empty : args;
    }

```

## Checklist

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have updated the
[CHANGELOG-PENDING](https://github.com/pulumi/pulumi/blob/master/CHANGELOG_PENDING.md)
file with my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Service,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Service API version
<!-- @pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
@EronWright
Copy link
Contributor Author

This PR will be ready once a new version (.13) of pulumi-java-gen becomes available.

@EronWright EronWright requested review from blampe and rquitales July 29, 2024 22:33
@EronWright EronWright marked this pull request as ready for review July 29, 2024 22:33
@EronWright EronWright enabled auto-merge (squash) July 29, 2024 23:18
@EronWright EronWright merged commit 93b4649 into master Jul 30, 2024
17 checks passed
@EronWright EronWright deleted the issue-3057 branch July 30, 2024 17:04
blampe added a commit that referenced this pull request Aug 7, 2024
### Added

- `clusterIdentifier` configuration can now be used to manually control
the replacement behavior of a provider resource.
(#3068)

- Pod errors now include the pod's last termination state, as well as
the pod's termination message if available.
(#3091)

The pod's termination message can be helpful in `CrashLoopBackOff`
situations but will only be reported if it was correctly configured.

By default, the pod's termination message is read from
`/dev/termination-log`. This location can be configured with
`terminationMessagePath`.

Use `terminationMessagePolicy: FallbackToLogsOnError` to use the pod's
logs as its termination message.

- Documentation is now generated for all languages supported by overlay
types. (#3107)

### Fixed

- Updated logic to accurately detect if a resource is a Patch variant.
(#3102)
- Added Java as a supported language for `CustomResource` overlays.
(#3120)
- Status messages reported during updates are now more accurately scoped
to the
affected resource.
(#3128)
- `PersistentVolumeClaims` with a bind mode of `WaitForFirstConsumer`
will no
longer hang indefinitely.
(#3130)
- [java] Fixed an issue where child resources could not be registered by
Chart v4. (#3119)
lumiere-bot bot referenced this pull request in coolguy1771/home-ops Aug 8, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@pulumi/kubernetes](https://pulumi.com)
([source](https://github.com/pulumi/pulumi-kubernetes)) | dependencies
| minor | [`4.15.0` ->
`4.16.0`](https://renovatebot.com/diffs/npm/@pulumi%2fkubernetes/4.15.0/4.16.0)
|

---

### Release Notes

<details>
<summary>pulumi/pulumi-kubernetes (@&#8203;pulumi/kubernetes)</summary>

###
[`v4.16.0`](https://github.com/pulumi/pulumi-kubernetes/blob/HEAD/CHANGELOG.md#4160-August-7-2024)

[Compare
Source](https://github.com/pulumi/pulumi-kubernetes/compare/v4.15.0...v4.16.0)

##### Added

- `clusterIdentifier` configuration can now be used to manually control
the
replacement behavior of a provider
resourc[https://github.com/pulumi/pulumi-kubernetes/pull/3068](https://github.com/pulumi/pulumi-kubernetes/pull/3068)ull/3068)

- Pod errors now include the pod's last termination state, as well as
the pod's
termination message if
availabl[https://github.com/pulumi/pulumi-kubernetes/pull/3091](https://github.com/pulumi/pulumi-kubernetes/pull/3091)ull/3091)

The pod's termination message can be helpful in `CrashLoopBackOff`
situations but
    will only be reported if it was correctly configured.

    By default, the pod's termination message is read from
    `/dev/termination-log`. This location can be configured with
    `terminationMessagePath`.

Use `terminationMessagePolicy: FallbackToLogsOnError` to use the pod's
logs
    as its termination message.

- Documentation is now generated for all languages supported by overlay
types.

[https://github.com/pulumi/pulumi-kubernetes/pull/3107](https://github.com/pulumi/pulumi-kubernetes/pull/3107)3107)

##### Fixed

- Updated logic to accurately detect if a resource is a Patch variant.
([https://github.com/pulumi/pulumi-kubernetes/pull/3102](https://github.com/pulumi/pulumi-kubernetes/pull/3102))
- Added Java as a supported language for `CustomResource` overlays.
([https://github.com/pulumi/pulumi-kubernetes/pull/3120](https://github.com/pulumi/pulumi-kubernetes/pull/3120))
- Status messages reported during updates are now more accurately scoped
to the
affected
resourc[https://github.com/pulumi/pulumi-kubernetes/pull/3128](https://github.com/pulumi/pulumi-kubernetes/pull/3128)3128)
- `PersistentVolumeClaims` with a bind mode of `WaitForFirstConsumer`
will no
longer hang
indefinitel[https://github.com/pulumi/pulumi-kubernetes/pull/3130](https://github.com/pulumi/pulumi-kubernetes/pull/3130)3130)
- \[java] Fixed an issue where child resources could not be registered
by Chart v4.
[https://github.com/pulumi/pulumi-kubernetes/pull/3119](https://github.com/pulumi/pulumi-kubernetes/pull/3119)9)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://github.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4yMS4zIiwidXBkYXRlZEluVmVyIjoiMzguMjEuMyIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsidHlwZS9taW5vciJdfQ==-->

Co-authored-by: lumiere-bot[bot] <98047013+lumiere-bot[bot]@users.noreply.github.com>
@mjeffryes mjeffryes added this to the 0.108 milestone Aug 16, 2024
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.

Child resource cannot be registered by Chart v4 (Java SDK)
3 participants