Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
5 changes: 4 additions & 1 deletion src/crd-controller/HostedServices/V1Alpha2Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ private IDisposable ObserveKamusSecret(CancellationToken token)
ApiVersion,
"kamussecrets",
token)
.Take(1)
.SelectMany(x =>
Observable.FromAsync(async () => await HandleEvent(x.Item1, x.Item2))
)
Expand All @@ -69,13 +70,15 @@ private IDisposable ObserveKamusSecret(CancellationToken token)
Environment.Exit(0);
});
}

public Task StartAsync(CancellationToken token)
{
mSubscription = ObserveKamusSecret(token);
Observable.Interval(TimeSpan.FromSeconds(mReconciliationIntervalInSeconds)).Subscribe((s) =>
{
mSubscription.Dispose();
var oldSubscription = mSubscription;
mSubscription = ObserveKamusSecret(token);
oldSubscription.Dispose();
});

mLogger.Information("Starting watch for KamusSecret V1Alpha2 events");
Expand Down
2 changes: 1 addition & 1 deletion src/crd-controller/crd-controller.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<PropertyGroup>
<Version>0.9.0.7</Version>
<Version>0.9.0.8</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
26 changes: 14 additions & 12 deletions src/crd-controller/utils/KubernetesExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,24 @@ public static class KubernetesExtensions
string version,
string plural,
CancellationToken cancellationToken
) where TCRD : class
) where TCRD : class
{
Watcher<TCRD> watcher = null;
return Observable.FromAsync(async () =>
{
var subject = new System.Reactive.Subjects.Subject<(WatchEventType, TCRD)>();
var path = $"apis/{group}/{version}/watch/{plural}";
await kubernetes.WatchObjectAsync<TCRD>(path,
timeoutSeconds: int.MaxValue,
onEvent: (@type, @event) => subject.OnNext((@type, @event)),
onError: e => subject.OnError(e),
onClosed: () => subject.OnCompleted(), cancellationToken: cancellationToken);
return subject;
})
{
var subject = new System.Reactive.Subjects.Subject<(WatchEventType, TCRD)>();
var path = $"apis/{group}/{version}/watch/{plural}";
watcher = await kubernetes.WatchObjectAsync<TCRD>(path,
timeoutSeconds: int.MaxValue,
onEvent: (@type, @event) => subject.OnNext((@type, @event)),
onError: e => subject.OnError(e),
onClosed: () => subject.OnCompleted(), cancellationToken: cancellationToken);
return subject;
})
.SelectMany(x => x)
.Select(t => (t.Item1, t.Item2 as TCRD))
.Where(t => t.Item2 != null);
.Where(t => t.Item2 != null)
.Finally(() => watcher?.Dispose());
}
}
}
2 changes: 1 addition & 1 deletion src/decrypt-api/decrypt-api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<Version>0.9.0.7</Version>
<Version>0.9.0.8</Version>
</PropertyGroup>
<ItemGroup>
<Folder Include="Models\" />
Expand Down
2 changes: 1 addition & 1 deletion src/encrypt-api/encrypt-api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<Version>0.9.0.7</Version>
<Version>0.9.0.8</Version>
</PropertyGroup>
<ItemGroup>
<Folder Include="Models\" />
Expand Down