Skip to content

Commit fe181d3

Browse files
author
Christoph Bühler
committed
fix(cache): Don't compare ManagedFields (introduced in 1.18)
This fixes #76. It should be noted, that in future maybe this field needs to be checked again since it is used for server-side-apply of kubectl.
1 parent 7a172c9 commit fe181d3

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

src/KubeOps/Operator/Caching/ResourceCache.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ internal class ResourceCache<TEntity> : IResourceCache<TEntity>
1313
where TEntity : IKubernetesObject<V1ObjectMeta>
1414
{
1515
private const string ResourceVersion = "ResourceVersion";
16+
private const string ManagedFields = "ManagedFields";
1617
private const string Finalizers = "Metadata.Finalizers";
1718
private const string Status = "Status";
1819

@@ -21,7 +22,7 @@ internal class ResourceCache<TEntity> : IResourceCache<TEntity>
2122
{
2223
Caching = true,
2324
AutoClearCache = false,
24-
MembersToIgnore = new List<string> { ResourceVersion },
25+
MembersToIgnore = new List<string> { ResourceVersion, ManagedFields },
2526
});
2627

2728
private readonly IDictionary<string, TEntity> _cache = new ConcurrentDictionary<string, TEntity>();
@@ -91,8 +92,6 @@ private CacheComparisonResult CompareCache(TEntity resource)
9192

9293
private bool Exists(TEntity resource) => _cache.ContainsKey(resource.Metadata.Uid);
9394

94-
private bool Exists(string id) => _cache.ContainsKey(id);
95-
9695
private void Remove(string resourceUid)
9796
{
9897
_cache.Remove(resourceUid);

tests/KubeOps.TestOperator/Entities/V1TestEntity.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using k8s.Models;
22
using KubeOps.Operator.Entities;
3-
using KubeOps.Operator.Entities.Annotations;
43

54
namespace KubeOps.TestOperator.Entities
65
{
@@ -17,7 +16,7 @@ public class V1TestEntityStatus
1716
public string Status { get; set; } = string.Empty;
1817
}
1918

20-
[KubernetesEntity(Group = "testing.dev", ApiVersion = "v1", Kind = "testentity", PluralName = "testentities")]
19+
[KubernetesEntity(Group = "testing.dev", ApiVersion = "v1", Kind = "TestEntity")]
2120
public class V1TestEntity : CustomKubernetesEntity<V1TestEntitySpec, V1TestEntityStatus>
2221
{
2322
}

tests/KubeOps.TestOperator/Entities/V2TestEntity.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class V2TestEntityStatus
2020
public string Status { get; set; } = string.Empty;
2121
}
2222

23-
[KubernetesEntity(Group = "testing.dev", ApiVersion = "v2", Kind = "testentity", PluralName = "testentities")]
23+
[KubernetesEntity(Group = "testing.dev", ApiVersion = "v2", Kind = "TestEntity")]
2424
public class V2TestEntity : CustomKubernetesEntity<V2TestEntitySpec, V2TestEntityStatus>
2525
{
2626
}

0 commit comments

Comments
 (0)