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

Fixes in how the provider handles CRDs and CRs #271

Merged
merged 3 commits into from
Nov 14, 2018
Merged

Conversation

hausdorff
Copy link
Contributor

See commit messages for a more detailed discussion.

Copy link
Member

@lukehoban lukehoban left a comment

Choose a reason for hiding this comment

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

LGTM

pkg/await/await.go Outdated Show resolved Hide resolved
pkg/await/await.go Outdated Show resolved Hide resolved
deleteOpts := metav1.DeleteOptions{}
if version.Compare(1, 6) < 0 {
// 1.5.x option.
boolFalse := false
// nolint
deleteOpts.OrphanDependents = &boolFalse
} else {
} else if version.Compare(1, 7) < 0 {
// 1.6.x option. (NOTE: Background delete propagation is broken in k8s v1.6, and maybe later.)

This comment was marked as resolved.

pkg/provider/provider.go Outdated Show resolved Hide resolved
pkg/await/await.go Outdated Show resolved Hide resolved
pkg/provider/provider.go Outdated Show resolved Hide resolved
Currently, if a CRD is created after the CRs that depend on it, the CRs
will fail. The main reason for this is that our caching discovery client
does not refresh after a CRD is created, so when asked about a G/V/K, it
will fail because it thinks the server does not know about it.

To fix this, this commit will cause us to mark the cache as invalid
any time a CRD is created. This means that the CR, when a create
operation is retried, will update its view of the server before
creation.
Currently, if a CRD is deleted before we have a chance to delete
dependent CRs, we could fail because the the G/V/K is no longer
registered with the API server.

This commit corrects this by considering `NotFound` to be equivalent to
a successful delete. The rationale behind this is that we must have
previously successfully created the resource; hence, if the G/V/K is
missing, it was successfully deleted.

Importantly, if the user accidentally switches active contexts, a
`pulumi up -r` will register all of these as deletes. We will be working
on this scenario in the future.
Background deletion was broken for much of Kubernetes 1.6, and our code
accordingly manually sets deletion to "foreground" after 1.6. This
causes pain when deleting CRDs with finalizers, which will hang until
the GC has a chance to delete them and all their dependencies, which is
quite likely to be a time longer than our timeout period.

This assumption is outdated for newer verions of Kubernetes, so this
commit will default to whatever the user has set for all versions > 1.7.
@hausdorff
Copy link
Contributor Author

Ok I think we're ready for another spin on this @lblackstone. I refactored the isNotFound stuff into one place and then addressed all the other comments.

pkg/await/await.go Show resolved Hide resolved
@hausdorff hausdorff merged commit 9f4317d into master Nov 14, 2018
@pulumi-bot pulumi-bot deleted the hausdorff/istio branch November 14, 2018 23:21
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.

None yet

3 participants