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

Stop using initialApiVersion annotation #837

Merged
merged 4 commits into from
Oct 9, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,18 @@
- v1.15.x
- v1.14.x

### Improvements

- Stop using initialApiVersion annotation. (https://github.com/pulumi/pulumi-kubernetes/pull/837).

## 1.2.1 (October 8, 2019)

### Supported Kubernetes versions

- v1.16.x
- v1.15.x
- v1.14.x

### Improvements

- Cache the OpenAPI schema to improve performance. (https://github.com/pulumi/pulumi-kubernetes/pull/833, https://github.com/pulumi/pulumi-kubernetes/pull/836).
Expand Down
71 changes: 38 additions & 33 deletions pkg/await/await.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ import (
// --------------------------------------------------------------------------

type ProviderConfig struct {
Context context.Context
Host *pulumiprovider.HostClient
URN resource.URN
Context context.Context
Host *pulumiprovider.HostClient
URN resource.URN
InitialApiVersion string

ClientSet *clients.DynamicClientSet
DedupLogger *logging.DedupLogger
Expand Down Expand Up @@ -176,14 +177,15 @@ func Creation(c CreateConfig) (*unstructured.Unstructured, error) {
} else {
if awaiter.awaitCreation != nil {
conf := createAwaitConfig{
host: c.Host,
ctx: c.Context,
urn: c.URN,
clientSet: c.ClientSet,
currentInputs: c.Inputs,
currentOutputs: outputs,
logger: c.DedupLogger,
timeout: c.Timeout,
host: c.Host,
ctx: c.Context,
urn: c.URN,
initialApiVersion: c.InitialApiVersion,
clientSet: c.ClientSet,
currentInputs: c.Inputs,
currentOutputs: outputs,
logger: c.DedupLogger,
timeout: c.Timeout,
}
waitErr := awaiter.awaitCreation(conf)
if waitErr != nil {
Expand Down Expand Up @@ -230,13 +232,14 @@ func Read(c ReadConfig) (*unstructured.Unstructured, error) {
} else {
if awaiter.awaitRead != nil {
conf := createAwaitConfig{
host: c.Host,
ctx: c.Context,
urn: c.URN,
clientSet: c.ClientSet,
currentInputs: c.Inputs,
currentOutputs: outputs,
logger: c.DedupLogger,
host: c.Host,
ctx: c.Context,
urn: c.URN,
initialApiVersion: c.InitialApiVersion,
clientSet: c.ClientSet,
currentInputs: c.Inputs,
currentOutputs: outputs,
logger: c.DedupLogger,
}
waitErr := awaiter.awaitRead(conf)
if waitErr != nil {
Expand Down Expand Up @@ -351,14 +354,15 @@ func Update(c UpdateConfig) (*unstructured.Unstructured, error) {
if awaiter.awaitUpdate != nil {
conf := updateAwaitConfig{
createAwaitConfig: createAwaitConfig{
host: c.Host,
ctx: c.Context,
urn: c.URN,
clientSet: c.ClientSet,
currentInputs: c.Inputs,
currentOutputs: currentOutputs,
logger: c.DedupLogger,
timeout: c.Timeout,
host: c.Host,
ctx: c.Context,
urn: c.URN,
initialApiVersion: c.InitialApiVersion,
clientSet: c.ClientSet,
currentInputs: c.Inputs,
currentOutputs: currentOutputs,
logger: c.DedupLogger,
timeout: c.Timeout,
},
lastInputs: c.Previous,
lastOutputs: liveOldObj,
Expand Down Expand Up @@ -444,13 +448,14 @@ func Deletion(c DeleteConfig) error {
} else {
waitErr = awaiter.awaitDeletion(deleteAwaitConfig{
createAwaitConfig: createAwaitConfig{
host: c.Host,
ctx: c.Context,
urn: c.URN,
clientSet: c.ClientSet,
currentInputs: c.Inputs,
logger: c.DedupLogger,
timeout: c.Timeout,
host: c.Host,
ctx: c.Context,
urn: c.URN,
initialApiVersion: c.InitialApiVersion,
clientSet: c.ClientSet,
currentInputs: c.Inputs,
logger: c.DedupLogger,
timeout: c.Timeout,
},
clientForResource: client,
})
Expand Down
17 changes: 9 additions & 8 deletions pkg/await/awaiters.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,15 @@ const (
// live number of Pods reaches the minimum liveness threshold. `pool` and `disco` are provided
// typically from a client pool so that polling is reasonably efficient.
type createAwaitConfig struct {
host *provider.HostClient
ctx context.Context
urn resource.URN
logger *logging.DedupLogger
clientSet *clients.DynamicClientSet
currentInputs *unstructured.Unstructured
currentOutputs *unstructured.Unstructured
timeout float64
host *provider.HostClient
ctx context.Context
urn resource.URN
initialApiVersion string
logger *logging.DedupLogger
clientSet *clients.DynamicClientSet
currentInputs *unstructured.Unstructured
currentOutputs *unstructured.Unstructured
timeout float64
}

func (cac *createAwaitConfig) logStatus(sev diag.Severity, message string) {
Expand Down
6 changes: 2 additions & 4 deletions pkg/await/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,7 @@ func (dia *deploymentInitAwaiter) processDeploymentEvent(event watch.Event) {
// Note: We must use the annotated creation apiVersion rather than the API-reported apiVersion, because
// the Progressing status field will not be present if the Deployment was created with the `extensions/v1beta1` API,
// regardless of what the Event apiVersion says.
extensionsV1Beta1API := metadata.GetAnnotationValue(
dia.config.createAwaitConfig.currentInputs, metadata.AnnotationInitialApiVersion) == "extensions/v1beta1"
extensionsV1Beta1API := dia.config.initialApiVersion == "extensions/v1beta1"

// Get generation of the Deployment's ReplicaSet.
dia.replicaSetGeneration = deployment.GetAnnotations()[revision]
Expand Down Expand Up @@ -550,8 +549,7 @@ func (dia *deploymentInitAwaiter) checkReplicaSetStatus() {
// Note: We must use the annotated apiVersion rather than the API-reported apiVersion, because
// the Progressing status field will not be present if the Deployment was created with the `extensions/v1beta1` API,
// regardless of what the Event apiVersion says.
extensionsV1Beta1API := metadata.GetAnnotationValue(
dia.config.createAwaitConfig.currentInputs, metadata.AnnotationInitialApiVersion) == "extensions/v1beta1"
extensionsV1Beta1API := dia.config.initialApiVersion == "extensions/v1beta1"
if extensionsV1Beta1API {
rawReadyReplicas, readyReplicasExists = openapi.Pluck(dia.deployment.Object, "status", "readyReplicas")
readyReplicas, _ = rawReadyReplicas.(int64)
Expand Down
Loading