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

Support CustomTimeouts in Kubernetes #672

Closed
lblackstone opened this issue Jul 30, 2019 · 3 comments · Fixed by #745
Closed

Support CustomTimeouts in Kubernetes #672

lblackstone opened this issue Jul 30, 2019 · 3 comments · Fixed by #745
Assignees
Milestone

Comments

@lblackstone
Copy link
Member

pulumi/pulumi#2885 added an option to set timeouts that is common across all providers. Deprecate the k8s provider timeoutSeconds annotation in favor if the new option, and plumb the changes through the provider.

@lblackstone lblackstone self-assigned this Jul 30, 2019
@lblackstone
Copy link
Member Author

Alternatively, it might make more sense to piggyback on top of the existing annotation, and simply set it based on customTimeouts.

I think the semantics are slightly different; the existing timeoutSeconds annotation applies to any operation rather than offering a granular create/update/delete option.

@lblackstone lblackstone added this to the 0.26 milestone Aug 5, 2019
@lukehoban
Copy link
Member

Let's focus on making sure customTimeouts is implemented for Kubernetes. We can hold off on any deprecations for now and do that later if needed.

@lblackstone
Copy link
Member Author

Chatted with @stack72 about implementing this, and sounds like it should be pretty straightforward.

Here are some links that should be useful for the implementation:

Read the annotation:

func TimeoutSeconds(obj *unstructured.Unstructured, defaultSeconds int) int {

Use the optional override (used in each resource awaiter in pkg/await):

metadata.TimeoutSeconds(pia.config.currentInputs, DefaultPodTimeoutMins*60)) * time.Second

Provider implementation that talks to the engine:
https://github.com/pulumi/pulumi-kubernetes/blob/0a762c7d821c3df66a4d8957180b0949f1894f0e/pkg/provider/provider.go

@lukehoban lukehoban changed the title Deprecate timeoutSeconds annotation in favor of new customTimeouts option Support CustomTimeouts in Kubernetes Aug 21, 2019
stack72 added a commit that referenced this issue Aug 26, 2019
Fixes: #672

This will allow the user to continue to use the timeout annotation or
to pass the CustomTimeouts parameters as part of ResourceOptions

The order of operations will be:

1. Use CustomTimeouts passes in ResourceOpts
2. Use the annotations (which will be deprecated later)
3. Use the defaults specified in code

This means this code will allow us to have a timeout on app creation
of 10s

```
const appName = "my-app";
const appLabels = { appClass: appName };
const deployment = new k8s.apps.v1.Deployment(`${appName}-dep`, {
    metadata: { labels: appLabels },
    spec: {
        replicas: 2,
        selector: { matchLabels: appLabels },
        template: {
            metadata: { labels: appLabels },
            spec: {
                containers: [{
                    name: appName,
                    image: "nginx",
                    ports: [{ name: "http", containerPort: 80 }]
                }],
            }
        }
    },
}, {
    provider: cluster.provider,
    customTimeouts: {
        create: "10s",
    }
});
```

this allows to get an error as
stack72 added a commit that referenced this issue Aug 26, 2019
Fixes: #672

This will allow the user to continue to use the timeout annotation or
to pass the CustomTimeouts parameters as part of ResourceOptions

The order of operations will be:

1. Use CustomTimeouts passes in ResourceOpts
2. Use the annotations (which will be deprecated later)
3. Use the defaults specified in code

This means this code will allow us to have a timeout on app creation
of 10s

```
const appName = "my-app";
const appLabels = { appClass: appName };
const deployment = new k8s.apps.v1.Deployment(`${appName}-dep`, {
    metadata: { labels: appLabels },
    spec: {
        replicas: 2,
        selector: { matchLabels: appLabels },
        template: {
            metadata: { labels: appLabels },
            spec: {
                containers: [{
                    name: appName,
                    image: "nginx",
                    ports: [{ name: "http", containerPort: 80 }]
                }],
            }
        }
    },
}, {
    provider: cluster.provider,
    customTimeouts: {
        create: "10s",
    }
});
```

this allows to get an error as
stack72 added a commit that referenced this issue Aug 26, 2019
Fixes: #672

This will allow the user to continue to use the timeout annotation or
to pass the CustomTimeouts parameters as part of ResourceOptions

The order of operations will be:

1. Use CustomTimeouts passes in ResourceOpts
2. Use the annotations (which will be deprecated later)
3. Use the defaults specified in code

This means this code will allow us to have a timeout on app creation
of 10s

```
const appName = "my-app";
const appLabels = { appClass: appName };
const deployment = new k8s.apps.v1.Deployment(`${appName}-dep`, {
    metadata: { labels: appLabels },
    spec: {
        replicas: 2,
        selector: { matchLabels: appLabels },
        template: {
            metadata: { labels: appLabels },
            spec: {
                containers: [{
                    name: appName,
                    image: "nginx",
                    ports: [{ name: "http", containerPort: 80 }]
                }],
            }
        }
    },
}, {
    provider: cluster.provider,
    customTimeouts: {
        create: "10s",
    }
});
```

this allows to get an error as
stack72 added a commit that referenced this issue Aug 26, 2019
Fixes: #672

This will allow the user to continue to use the timeout annotation or
to pass the CustomTimeouts parameters as part of ResourceOptions

The order of operations will be:

1. Use CustomTimeouts passes in ResourceOpts
2. Use the annotations (which will be deprecated later)
3. Use the defaults specified in code

This means this code will allow us to have a timeout on app creation
of 10s

```
const appName = "my-app";
const appLabels = { appClass: appName };
const deployment = new k8s.apps.v1.Deployment(`${appName}-dep`, {
    metadata: { labels: appLabels },
    spec: {
        replicas: 2,
        selector: { matchLabels: appLabels },
        template: {
            metadata: { labels: appLabels },
            spec: {
                containers: [{
                    name: appName,
                    image: "nginx",
                    ports: [{ name: "http", containerPort: 80 }]
                }],
            }
        }
    },
}, {
    provider: cluster.provider,
    customTimeouts: {
        create: "10s",
    }
});
```

this allows to get an error as
stack72 added a commit that referenced this issue Aug 26, 2019
Fixes: #672

This will allow the user to continue to use the timeout annotation or
to pass the CustomTimeouts parameters as part of ResourceOptions

The order of operations will be:

1. Use CustomTimeouts passes in ResourceOpts
2. Use the annotations (which will be deprecated later)
3. Use the defaults specified in code

This means this code will allow us to have a timeout on app creation
of 10s

```
const appName = "my-app";
const appLabels = { appClass: appName };
const deployment = new k8s.apps.v1.Deployment(`${appName}-dep`, {
    metadata: { labels: appLabels },
    spec: {
        replicas: 2,
        selector: { matchLabels: appLabels },
        template: {
            metadata: { labels: appLabels },
            spec: {
                containers: [{
                    name: appName,
                    image: "nginx",
                    ports: [{ name: "http", containerPort: 80 }]
                }],
            }
        }
    },
}, {
    provider: cluster.provider,
    customTimeouts: {
        create: "10s",
    }
});
```

this allows to get an error as
lblackstone pushed a commit that referenced this issue Aug 26, 2019
Fixes: #672

This will allow the user to continue to use the timeout annotation or
to pass the CustomTimeouts parameters as part of ResourceOptions

The order of operations will be:

1. Use CustomTimeouts passes in ResourceOpts
2. Use the annotations (which will be deprecated later)
3. Use the defaults specified in code

This means this code will allow us to have a timeout on app creation
of 10s

```
const appName = "my-app";
const appLabels = { appClass: appName };
const deployment = new k8s.apps.v1.Deployment(`${appName}-dep`, {
    metadata: { labels: appLabels },
    spec: {
        replicas: 2,
        selector: { matchLabels: appLabels },
        template: {
            metadata: { labels: appLabels },
            spec: {
                containers: [{
                    name: appName,
                    image: "nginx",
                    ports: [{ name: "http", containerPort: 80 }]
                }],
            }
        }
    },
}, {
    provider: cluster.provider,
    customTimeouts: {
        create: "10s",
    }
});
```

this allows to get an error as
lblackstone pushed a commit that referenced this issue Aug 26, 2019
* Allow ResourceOptions customTimeouts options to be respected

Fixes: #672

This will allow the user to continue to use the timeout annotation or
to pass the CustomTimeouts parameters as part of ResourceOptions

The order of operations will be:

1. Use CustomTimeouts passes in ResourceOpts
2. Use the annotations (which will be deprecated later)
3. Use the defaults specified in code

This means this code will allow us to have a timeout on app creation
of 10s

```
const appName = "my-app";
const appLabels = { appClass: appName };
const deployment = new k8s.apps.v1.Deployment(`${appName}-dep`, {
    metadata: { labels: appLabels },
    spec: {
        replicas: 2,
        selector: { matchLabels: appLabels },
        template: {
            metadata: { labels: appLabels },
            spec: {
                containers: [{
                    name: appName,
                    image: "nginx",
                    ports: [{ name: "http", containerPort: 80 }]
                }],
            }
        }
    },
}, {
    provider: cluster.provider,
    customTimeouts: {
        create: "10s",
    }
});
```

this allows to get an error as

* Update comment on overriding resource timeouts
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 a pull request may close this issue.

3 participants