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

feat(plugins): Add remote extensions field to a plugin info release #917

Merged
merged 2 commits into from
Aug 4, 2020

Conversation

jonsie
Copy link
Contributor

@jonsie jonsie commented Aug 4, 2020

In spinnaker/orca#3840 I realized I had the cart before the horse on a few items, specifically the basic remote extension point configuration. This will not only allow me to get away from abusing the PreconfiguredJob stuff even more (by allowing for specific remote stage configuration), but also lay some of the ground work for other types of remote extension points.

Adds a remoteExtensions field to a plugin info release. A plugin that is just a remote extension look like this:

{
  "id": "netflix.remote",
  "description": "A remote plugin",
  "provider": "csmalley",
  "releases": [
    {
      "version": "0.0.1",
      "date": "2020-06-16T02:20:14.889Z",
      "requires": "orca>=1.0.0",
      "url": null,
      "sha512sum": null,
      "preferred": false,
      "lastModified": "2020-06-18T23:08:48.899Z",
      "lastModifiedBy": "csmalley",
      "remoteExtensions": [
        {
          "type": "stage",
          "id": "netflix.remote.remoteWait",
          "transport": {
            "http": {
              "url": "http://service.com/remoteWait",
              "config": {}
            }
          },
          "config": {
            "type": "remoteWait",
            "label": "Wait on a remote service",
            "description": "A stage that waits on a remote service",
            "parameters": {
              "waitTime": 30,
              "message": "done!"
            }
          }
        }
      ]
    }
  ]
}

The idea here is that we use the requires field in-conjunction with the remote extension type to determine which service to configure with the specific remote extension and corresponding remote extension configuration.

use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.EXTERNAL_PROPERTY,
property = "type")
@JsonSubTypes({@JsonSubTypes.Type(value = StageRemoteExtensionConfig.class, name = "stage")})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

stage here corresponds to the RemoteExtension#type field.

@Nonnull private String url;

/** A placeholder for misc. configuration for the underlying HTTP client. */
@Nonnull private Map<String, Object> config = new HashMap<>();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This can be flushed out over time, but for now it's a catch-all for any underlying client configuration we need.

@Nonnull private String description;

/** Map of stage parameter names and default values. */
@Nonnull private Map<String, Object> parameters = new HashMap<>();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think for now a map of the parameter name and the default value will suffice.

@jonsie jonsie requested a review from a team August 4, 2020 04:25
Copy link
Member

@robzienert robzienert left a comment

Choose a reason for hiding this comment

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

Do like.

PluginInfo is @Valid, so I think it'd be worth adding javax.validation annotations to some of these properties (such as @URL on the url property, etc).

public RemoteExtensionConfig config;

/** Root remote extension configuration type. */
public interface RemoteExtensionConfig {}
Copy link
Member

@robzienert robzienert Aug 4, 2020

Choose a reason for hiding this comment

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

Rather than define the extension point config type in front50 (making front50 changes required for most remote extensions), I think we should investigate a shared model or service-exposed schema for extension point configs - personally I favor the schema idea:

For any extension point that has a config, say MyRemoteExtensionConfig, we could convert to JSON Schema (or similar) and expose it from something like /plugins/extension-point-configs/. Each config would have a type, as you have it, but structured like {service}/{configType}[@version?][1], allowing front50 to lookup the correct schema when a remote plugin is being published and we want to do some type / constraint validation. This would let us continue to define, in a single place, everything for an extension point.

I don't think we need to change the PR as it exists today, since this is talking about a lot of work - we can always retrofit what you have here after we've got something working end-to-end. 💯

[1] Not sure if version is needed, but probably? 🤷

One problem with this is that services tend to have dependencies on front50, but not the other way around. I think I'd also be OK with services publishing their schemas into front50 on startup (either via HTTP or pubsub - prefer pubsub). 🤷

Copy link
Contributor Author

@jonsie jonsie Aug 4, 2020

Choose a reason for hiding this comment

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

Super interesting idea.

I think a version would be needed. Each change to the config schema would need to be versioned, and then if there is a new config schema version a new plugin info release version with the new config schema would need to be published into front50. This is because we will be rolling out remote extensions by version, and we can't really swap out the underlying config schema without some corresponding version bump.

Copy link
Contributor

Choose a reason for hiding this comment

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

What would schema validation failures gate? Just publishes of new plugins?

@jonsie jonsie merged commit 5ed028d into spinnaker:master Aug 4, 2020
@jonsie jonsie deleted the plugin-release-remote-extensions branch August 4, 2020 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants