Skip to content

Commit

Permalink
feat: CancellationToken support and a lot of async improvements (#725)
Browse files Browse the repository at this point in the history
This PR adds the ability to cancel (almost) all asynchronous operations
with the built-in `CancellationToken`. Due to the nature of interfaces,
almost all of those changes are breaking the existing API.

It also adds an `WatchAsync` method to the `IKubernetesClient`, which is
making use of the newer asynchronous enumerables.

BREAKING CHANGE: Some methods do now feature the cancellation
token which changed the method signature.
  • Loading branch information
nachtjasmin committed Mar 7, 2024
1 parent 8a6cfe1 commit 2d17bff
Show file tree
Hide file tree
Showing 197 changed files with 12,222 additions and 11,602 deletions.
802 changes: 401 additions & 401 deletions .editorconfig

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Normalize line endings in Git: https://www.aleksandrhovhannisyan.com/blog/crlf-vs-lf-normalizing-line-endings-in-git/
* text=auto
*.cs text eol=crlf
88 changes: 44 additions & 44 deletions .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
name: Bug Report
description: "Create a report to help fix a problem."
title: "[bug]: "
labels: ["bug"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
- type: textarea
id: description
attributes:
label: Describe the bug
description: A clear and concise description of what the bug is.
validations:
required: true
- type: textarea
id: reproduce
attributes:
label: To reproduce
description: Steps to reproduce the behaviour
placeholder: |
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
validations:
required: true
- type: textarea
id: expected
attributes:
label: Expected behavior
description: A clear and concise description of what you expected to happen.
- type: textarea
id: screenshots
attributes:
label: Screenshots
description: If applicable, add screenshots to help explain your problem.
- type: textarea
id: additional
attributes:
label: Additional Context
description: Please add any other infos that could be useful.
name: Bug Report
description: "Create a report to help fix a problem."
title: "[bug]: "
labels: ["bug"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
- type: textarea
id: description
attributes:
label: Describe the bug
description: A clear and concise description of what the bug is.
validations:
required: true
- type: textarea
id: reproduce
attributes:
label: To reproduce
description: Steps to reproduce the behaviour
placeholder: |
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
validations:
required: true
- type: textarea
id: expected
attributes:
label: Expected behavior
description: A clear and concise description of what you expected to happen.
- type: textarea
id: screenshots
attributes:
label: Screenshots
description: If applicable, add screenshots to help explain your problem.
- type: textarea
id: additional
attributes:
label: Additional Context
description: Please add any other infos that could be useful.
24 changes: 12 additions & 12 deletions .github/ISSUE_TEMPLATE/documentation.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: Documentation
description: "Suggest a topic that is not correctly documented (or not documented at all)"
title: "[docs]: "
labels: ["documentation"]
body:
- type: textarea
id: description
attributes:
label: Describe the missing piece of documentation
description: Describe what you miss in the docs (or what is wrong).
validations:
required: true
name: Documentation
description: "Suggest a topic that is not correctly documented (or not documented at all)"
title: "[docs]: "
labels: ["documentation"]
body:
- type: textarea
id: description
attributes:
label: Describe the missing piece of documentation
description: Describe what you miss in the docs (or what is wrong).
validations:
required: true
52 changes: 26 additions & 26 deletions .github/ISSUE_TEMPLATE/feature_request.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
name: Feature Request
description: "Suggest a new feature for this project."
title: "[feature]: "
labels: ["enhancement"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this feature request!
- type: textarea
id: description
attributes:
label: Is your feature request related to a problem? Please describe.
description: A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
- type: textarea
id: solution
attributes:
label: Describe the solution you would like
description: A clear and concise description of what you want to happen.
validations:
required: true
- type: textarea
id: additional
attributes:
label: Additional Context
description: Please add any other infos that could be useful.
name: Feature Request
description: "Suggest a new feature for this project."
title: "[feature]: "
labels: ["enhancement"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this feature request!
- type: textarea
id: description
attributes:
label: Is your feature request related to a problem? Please describe.
description: A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
- type: textarea
id: solution
attributes:
label: Describe the solution you would like
description: A clear and concise description of what you want to happen.
validations:
required: true
- type: textarea
id: additional
attributes:
label: Additional Context
description: Please add any other infos that could be useful.
126 changes: 63 additions & 63 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,63 +1,63 @@
# Contributing to KubeOps

First of all, thank you for considering contributing to KubeOps.
This is an open souce project and shall be driven by the community.

This document describes how contributions may be done and what is required
to develop on KubeOps.

## Creating/Reporting Issues

Feel free to open an issue in the [issues section](https://github.com/buehler/dotnet-operator-sdk/issues).
There are three issue templates:
- Bug: to report an issue/bug that prevents usage or is an inconvenience of KubeOps
- Feature request: to report a new feature that would enhance KubeOps
- Documentation: to report missing / wrong documentation

Please search through the already created issues to find similarities.

## Creating Pull Requests

To directly contribute to the solution, create a fork of the repository
and implement your addition. Please keep in mind that reviewing takes some
time and is not done instantly.

Please adhere to the linting rules and the general code style in the repository.
Also, add tests for your changes to ensure that the system works well
when other changes happen.

The PR can have any name, but it would be nice if you adhere to
the repositories standard naming. Please name your PR
with [Convential Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary).

**NOTE for breaking changes**: please state breaking changes
in the PR description. The review process will be faster when
breaking changes are well documented.

A few examples:
- "fix: Null exception during watcher process"
- "feat(core): Add new functionality"
- "feat(testing): expose kubernetes client for testing"
- "refactor: changed this and that"
- "docs: Add docs about KubeOps core"

The PR will be squashed and merged into the default branch.

## Local Development

To setup a local development environment, you'll need to perform the follwing steps:

- Check out the repository (or your fork)
- If you want to run the Operator locally, you'll need some Kubernetes instance.
This can be any Kubernetes instance you'd like:
- Local Kubernetes in Docker for Mac/Windows
- minikube / any other local Kubernetes
- Deployed Kubernetes (e.g. GCP Kubernetes instance)
- You can now code your stuff.
- `tests/KubeOps.TestOperator` is a developed small operator that can be run
locally to test your implementations.
- Write tests for your changes
- Build the whole solution and check for linting errors / warnings.
**NOTE** that any warning will result in an error when building
with `Release` configuration.
- Do not change the linting rules without creating a discussion/issue first.
# Contributing to KubeOps

First of all, thank you for considering contributing to KubeOps.
This is an open souce project and shall be driven by the community.

This document describes how contributions may be done and what is required
to develop on KubeOps.

## Creating/Reporting Issues

Feel free to open an issue in the [issues section](https://github.com/buehler/dotnet-operator-sdk/issues).
There are three issue templates:
- Bug: to report an issue/bug that prevents usage or is an inconvenience of KubeOps
- Feature request: to report a new feature that would enhance KubeOps
- Documentation: to report missing / wrong documentation

Please search through the already created issues to find similarities.

## Creating Pull Requests

To directly contribute to the solution, create a fork of the repository
and implement your addition. Please keep in mind that reviewing takes some
time and is not done instantly.

Please adhere to the linting rules and the general code style in the repository.
Also, add tests for your changes to ensure that the system works well
when other changes happen.

The PR can have any name, but it would be nice if you adhere to
the repositories standard naming. Please name your PR
with [Convential Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary).

**NOTE for breaking changes**: please state breaking changes
in the PR description. The review process will be faster when
breaking changes are well documented.

A few examples:
- "fix: Null exception during watcher process"
- "feat(core): Add new functionality"
- "feat(testing): expose kubernetes client for testing"
- "refactor: changed this and that"
- "docs: Add docs about KubeOps core"

The PR will be squashed and merged into the default branch.

## Local Development

To setup a local development environment, you'll need to perform the follwing steps:

- Check out the repository (or your fork)
- If you want to run the Operator locally, you'll need some Kubernetes instance.
This can be any Kubernetes instance you'd like:
- Local Kubernetes in Docker for Mac/Windows
- minikube / any other local Kubernetes
- Deployed Kubernetes (e.g. GCP Kubernetes instance)
- You can now code your stuff.
- `tests/KubeOps.TestOperator` is a developed small operator that can be run
locally to test your implementations.
- Write tests for your changes
- Build the whole solution and check for linting errors / warnings.
**NOTE** that any warning will result in an error when building
with `Release` configuration.
- Do not change the linting rules without creating a discussion/issue first.
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
using ConversionWebhookOperator.Entities;

using KubeOps.Abstractions.Controller;
using KubeOps.Abstractions.Rbac;

namespace ConversionWebhookOperator.Controller;

[EntityRbac(typeof(V1TestEntity), Verbs = RbacVerb.All)]
public class V1TestEntityController(ILogger<V1TestEntityController> logger) : IEntityController<V1TestEntity>
{
public Task ReconcileAsync(V1TestEntity entity)
{
logger.LogInformation("Reconciling entity {Entity}.", entity);
return Task.CompletedTask;
}

public Task DeletedAsync(V1TestEntity entity)
{
logger.LogInformation("Deleted entity {Entity}.", entity);
return Task.CompletedTask;
}
}
using ConversionWebhookOperator.Entities;

using KubeOps.Abstractions.Controller;
using KubeOps.Abstractions.Rbac;

namespace ConversionWebhookOperator.Controller;

[EntityRbac(typeof(V1TestEntity), Verbs = RbacVerb.All)]
public class V1TestEntityController(ILogger<V1TestEntityController> logger) : IEntityController<V1TestEntity>
{
public Task ReconcileAsync(V1TestEntity entity, CancellationToken cancellationToken)
{
logger.LogInformation("Reconciling entity {Entity}.", entity);
return Task.CompletedTask;
}

public Task DeletedAsync(V1TestEntity entity, CancellationToken cancellationToken)
{
logger.LogInformation("Deleted entity {Entity}.", entity);
return Task.CompletedTask;
}
}
32 changes: 16 additions & 16 deletions examples/ConversionWebhookOperator/Entities/V1TestEntity.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using k8s.Models;

using KubeOps.Abstractions.Entities;

namespace ConversionWebhookOperator.Entities;

[KubernetesEntity(Group = "conversionwebhook.dev", ApiVersion = "v1", Kind = "TestEntity")]
public partial class V1TestEntity : CustomKubernetesEntity<V1TestEntity.EntitySpec>
{
public override string ToString() => $"Test Entity v1 ({Metadata.Name}): {Spec.Name}";

public class EntitySpec
{
public string Name { get; set; } = string.Empty;
}
}
using k8s.Models;

using KubeOps.Abstractions.Entities;

namespace ConversionWebhookOperator.Entities;

[KubernetesEntity(Group = "conversionwebhook.dev", ApiVersion = "v1", Kind = "TestEntity")]
public partial class V1TestEntity : CustomKubernetesEntity<V1TestEntity.EntitySpec>
{
public override string ToString() => $"Test Entity v1 ({Metadata.Name}): {Spec.Name}";

public class EntitySpec
{
public string Name { get; set; } = string.Empty;
}
}
Loading

0 comments on commit 2d17bff

Please sign in to comment.