Skip to content

Conversation

RedbackThomson
Copy link
Contributor

Description of changes:
Creates a new specification for a metadata.yaml file that resides in the root of the controller repository. The purpose of this file is to provide human-friendly display information about the service (long name, acronym, links) and to provide a source of truth for API versions.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ack-bot ack-bot requested a review from vijtrip2 July 13, 2021 21:51
go.mod Outdated
github.com/spf13/cobra v1.1.1
github.com/stretchr/testify v1.7.0
golang.org/x/mod v0.4.1
golang.org/x/tools v0.0.0-20200616195046-dc31b401abb5
Copy link
Collaborator

Choose a reason for hiding this comment

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

where'd this come from? maybe remove it with go mod tidy?

APIStatusRemoved = "removed"
APIStatusDeprecated = "deprecated"
APIStatusUnknown APIStatus = "unknown"
APIStatusInDevelopment = "in_development"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we call this just development and make it the default instead of unknown?

Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering if we really need a development status for API versions. I think that we should increase the API Version whenever the CRD schema changes.

Copy link
Member

@a-hilaly a-hilaly Jul 14, 2021

Choose a reason for hiding this comment

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

IMO development should be a status for the service controller and not a specific API version. Unless, if development means "not released" with the controller helm chart yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That seems fair. The API version in development will always be the latest available option. "In development" vs. "released" is controlled by our controller release already.

documentation: https://docs.example.com/
versions:
- api_version: v1alpha1
status: development No newline at end of file
Copy link
Collaborator

Choose a reason for hiding this comment

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

It might be useful to have a helper script in the code-generator that will examine a new controller repository and construct a default metadata file given a service name...

Copy link
Member

Choose a reason for hiding this comment

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

I'm curious to know what would happen if we don't have an APIStatusDevelopment

@RedbackThomson RedbackThomson changed the title Service metadata configuration file Add service metadata configuration file Jul 13, 2021
APIStatusRemoved = "removed"
APIStatusDeprecated = "deprecated"
APIStatusUnknown APIStatus = "unknown"
APIStatusInDevelopment = "in_development"
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering if we really need a development status for API versions. I think that we should increase the API Version whenever the CRD schema changes.

APIStatusRemoved = "removed"
APIStatusDeprecated = "deprecated"
APIStatusUnknown APIStatus = "unknown"
APIStatusInDevelopment = "in_development"
Copy link
Member

@a-hilaly a-hilaly Jul 14, 2021

Choose a reason for hiding this comment

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

IMO development should be a status for the service controller and not a specific API version. Unless, if development means "not released" with the controller helm chart yet.

Comment on lines +46 to +49
type ServiceVersion struct {
APIVersion string `json:"api_version"`
Status APIStatus `json:"status"`
}
Copy link
Member

Choose a reason for hiding this comment

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

We could also add a boolean field called IsHub, to be able to override the hub version. In most of the cases the latest Available version is the hub (prefered storage version). However, according to k8s deprecation policy sometimes the hub can be different from the latest version.

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 am quite averse to the idea of the hub being anything other than the latest generated version - we rely on it being the latest for the common runtime elements to match.

Comment on lines 44 to 45
// Metadata for the service
meta *ackmetadata.ServiceMetadata
Copy link
Member

@a-hilaly a-hilaly Jul 14, 2021

Choose a reason for hiding this comment

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

Do we need *ackmetadata.ServiceMetadata in ackmode.Model and multiversion.APIVersionManager? what are the use cases when generating one single api version (ack-generate apis)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True. I had this in before your last PR, I'll remove it again.

apiInfos: apisInfo,
models: models,
}
// TODO(hilalymh): Audit deprecated and removed versions
Copy link
Member

@a-hilaly a-hilaly Jul 14, 2021

Choose a reason for hiding this comment

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

I'm still going to send a PR for API versions examination. Mainly to verify that service controller maintainers didn't violate one of the deprecation/removal policies.

Comment on lines 66 to 69
hubVersion, err := metadata.GetLatestAPIVersion()
if err != nil {
return nil, err
}
Copy link
Member

@a-hilaly a-hilaly Jul 14, 2021

Choose a reason for hiding this comment

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

The hub version is not always the latest version. I would prefer to keep the APIVersionManager flexible in term of choosing a hub version. However we can still enforce "choosing the latest version as hub" in the build script or cmd / pkg/generate/ack

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. Will wait for your changes to cmd - we can load it in there.

// path to a metadata file
func NewServiceMetadata(
metadataPath string,
) (ServiceMetadata, error) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: you can return a *ServiceMetadata to avoid allocating a new ServiceMetadata{} when you return an error

Copy link
Member

@a-hilaly a-hilaly 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 overall! 👍

documentation: https://docs.example.com/
versions:
- api_version: v1alpha1
status: development No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious to know what would happen if we don't have an APIStatusDevelopment

Comment on lines 56 to 76
func (m *ServiceMetadata) GetLatestAPIVersion() (string, error) {
availableVersions := m.GetAvailableAPIVersions()

if len(availableVersions) == 0 {
return "", ErrNoAvailableVersions
}

return availableVersions[len(availableVersions)-1], nil
}

func (m *ServiceMetadata) GetDeprecatedAPIVersions() []string {
return m.getVersionsByStatus(APIStatusDeprecated)
}

func (m *ServiceMetadata) GetRemovedAPIVersions() []string {
return m.getVersionsByStatus(APIStatusRemoved)
}

func (m *ServiceMetadata) GetAvailableAPIVersions() []string {
return m.getVersionsByStatus(APIStatusAvailable)
}
Copy link
Member

Choose a reason for hiding this comment

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

half nit:please add godoc comment, at least for the exported functions

Copy link
Collaborator

@jaypipes jaypipes left a comment

Choose a reason for hiding this comment

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

Nice work on this @RedbackThomson :)

DEFAULT_METADATA_OUTPUT_PATH="$SERVICE_CONTROLLER_SOURCE_PATH/metadata.yaml"
METADATA_OUTPUT_PATH="${METADATA_OUTPUT_PATH:-$DEFAULT_METADATA_OUTPUT_PATH}"

echo "🧙 Welcome to the service metadata setup wizard"
Copy link
Collaborator

Choose a reason for hiding this comment

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

sweet emojis.

@jaypipes
Copy link
Collaborator

/lgtm

@ack-bot ack-bot added the lgtm Indicates that a PR is ready to be merged. label Jul 16, 2021
@a-hilaly
Copy link
Member

/lgtm

@ack-bot
Copy link
Collaborator

ack-bot commented Jul 16, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: A-Hilaly, jaypipes, RedbackThomson

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [A-Hilaly,RedbackThomson,jaypipes]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ack-bot ack-bot merged commit 75e6c92 into aws-controllers-k8s:main Jul 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants