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

Pass additional information to downward API (k8s version, kc version, k8s g/v) #846

Merged
merged 8 commits into from
Sep 7, 2022

Conversation

neil-hickey
Copy link
Contributor

@neil-hickey neil-hickey commented Aug 25, 2022

Signed-off-by: Neil Hickey [email protected]

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #781

Does this PR introduce a user-facing change?

Templating stages (ytt, helm, cue) now have the kubernetes version, available group/version APIs and kapp-controller version passed to them via data values, and enabled capabilites in helm.

Additional Notes for your reviewer:

Review Checklist:
  • Follows the developer guidelines
  • Relevant tests are added or updated
  • Code is at least as readable and maintainable as it was before this
    change
  • Relevant docs in this repo added or updated
  • Relevant carvel.dev docs added or updated in a separate PR and there's
    a link to that PR

Additional documentation e.g., Proposal, usage docs, etc.:


@neil-hickey neil-hickey force-pushed the nh-versions-downward-api-expansion branch 2 times, most recently from 0483769 to e49b956 Compare August 25, 2022 19:07
pkg/app/app.go Outdated Show resolved Hide resolved
@neil-hickey neil-hickey force-pushed the nh-versions-downward-api-expansion branch 6 times, most recently from e5dd634 to 48c5c5c Compare August 25, 2022 22:43
@neil-hickey neil-hickey changed the title WIP: Retrieve version information prior to fet,temp,deploy steps Pass additional information to downward API (k8s version, kc version, k8s g/v) Aug 25, 2022
@neil-hickey neil-hickey force-pushed the nh-versions-downward-api-expansion branch 2 times, most recently from 9180374 to d91178f Compare August 26, 2022 20:13
@neil-hickey neil-hickey force-pushed the nh-versions-downward-api-expansion branch from d91178f to 084e920 Compare August 26, 2022 21:00
@neil-hickey neil-hickey marked this pull request as ready for review August 29, 2022 16:08
Copy link
Contributor

@joe-kimmel-vmw joe-kimmel-vmw left a comment

Choose a reason for hiding this comment

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

I have some comments and questions but i wouldn't argue with merging this as-is. we can catch up real quick tomorrow AM about whether it's worth addressing any of these in this iteration.

cmd/controller/run.go Outdated Show resolved Hide resolved
pkg/componentInfo/component_info.go Outdated Show resolved Hide resolved
pkg/componentInfo/component_info.go Outdated Show resolved Hide resolved
pkg/componentInfo/component_info.go Outdated Show resolved Hide resolved
pkg/deploy/factory.go Show resolved Hide resolved
pkg/componentInfo/component_info.go Outdated Show resolved Hide resolved
pkg/componentInfo/component_info.go Outdated Show resolved Hide resolved
pkg/packageinstall/packageinstall.go Show resolved Hide resolved
pkg/template/downward_api_values.go Show resolved Hide resolved
pkg/template/values_factory.go Outdated Show resolved Hide resolved
Copy link
Member

@joaopapereira joaopapereira left a comment

Choose a reason for hiding this comment

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

Added some comments

cmd/controller/run.go Outdated Show resolved Hide resolved
pkg/componentInfo/component_info.go Outdated Show resolved Hide resolved
pkg/deploy/kapp.go Outdated Show resolved Hide resolved
}

// NewComponentInfo returns a ComponentInfo
func NewComponentInfo(coreClient kubernetes.Interface, clusterAccess *kubeconfig.Kubeconfig, kappControllerVersion string) *ComponentInfo {
Copy link
Member

Choose a reason for hiding this comment

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

The clusterAccess parameter could also be an interface.

pkg/template/helm_template.go Outdated Show resolved Hide resolved
pkg/template/helm_template.go Outdated Show resolved Hide resolved
coreClient kubernetes.Interface
appContext AppContext
coreClient kubernetes.Interface
additionalDownwardAPIValues AdditionalDownwardAPIValues
}

func (t Values) AsPaths(dirPath string) ([]string, func(), error) {
Copy link
Member

Choose a reason for hiding this comment

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

Just a comment about this function and maybe not be actionable in this PR.
This signature feels strange, the main reason for that is the return of that func() that you need to read the code to understand that it is the removal of the created folders.
It is the responsibility of the creator of dirPath to delete that folder, while this function is only responsible for creating the folders it needs inside the dirPath.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not going to action on this one in this PR

@neil-hickey neil-hickey force-pushed the nh-versions-downward-api-expansion branch 2 times, most recently from 4714056 to 69e9c3b Compare August 30, 2022 23:52
- renaming some things
- moved away from a values factory back to values struct
- minor fixups

Signed-off-by: Neil Hickey <[email protected]>
@neil-hickey neil-hickey force-pushed the nh-versions-downward-api-expansion branch from 69e9c3b to e2dc9c7 Compare August 31, 2022 20:50
pkg/app/app_template.go Outdated Show resolved Hide resolved
pkg/app/app_template.go Outdated Show resolved Hide resolved
Comment on lines +249 to +250
v.Pre = semver.PRVersion{}
v.Build = semver.BuildMeta{}
Copy link
Contributor

Choose a reason for hiding this comment

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

should this move into ComponentInfo? seems its more related to version parsing rather than package matching

Copy link
Contributor Author

@neil-hickey neil-hickey Sep 1, 2022

Choose a reason for hiding this comment

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

The constraint matching is specific to packageinstall (i.e the choice to drop the pre and build fields of KC version), so I think it makes more sense here. The kapp-controller version should always be as it is in the cluster, regardless of how / why we manipulate it in kapp-controller.

Copy link
Contributor

@joe-kimmel-vmw joe-kimmel-vmw Sep 2, 2022

Choose a reason for hiding this comment

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

I understand the point that it's not entirely semantically in-scope for the reader of PackageInstall to know about the effects of resetting the members of the version, v struct. However it's less obvious to me where to move that logic, and i think it'll be a similar number of lines of code, just maybe a little faster to read packageinstall.go until your concern is this logic specifically. To the extent the concern is just readability, it feels like a refactor or an explanatory comment would have similar benefits.

Signed-off-by: Neil Hickey <[email protected]>
@neil-hickey neil-hickey force-pushed the nh-versions-downward-api-expansion branch 3 times, most recently from ba3e515 to 46cacc6 Compare September 2, 2022 17:26
- Add template() test to validate memoizing works

Signed-off-by: Neil Hickey <[email protected]>
@neil-hickey neil-hickey force-pushed the nh-versions-downward-api-expansion branch from 46cacc6 to 7f0abc2 Compare September 2, 2022 19:04
Dmitriy Kalinin added 2 commits September 6, 2022 18:50
- memoizing within packageinstall didnt actually memoize
- memoizing within componentinfo was too aggressive so controller would not receive updated version after cluster is updated
@cppforlife cppforlife force-pushed the nh-versions-downward-api-expansion branch from 2e50459 to 43408dc Compare September 7, 2022 14:23
@cppforlife cppforlife force-pushed the nh-versions-downward-api-expansion branch from 43408dc to 5969595 Compare September 7, 2022 17:23
@cppforlife cppforlife merged commit 870f5a1 into develop Sep 7, 2022
@cppforlife cppforlife deleted the nh-versions-downward-api-expansion branch September 7, 2022 18:24
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.

Expose cluster versions and capabilities to templating steps
5 participants