Skip to content

Commit

Permalink
Explicitly set the PVC's storageClassName to default (#51)
Browse files Browse the repository at this point in the history
* Explicitly set the PVC's `storageClassName` to `default`

In the registry-cache extension we deploy PVCs to the Shoot. We see cases where the PVC and StorageClass creation can be racy. In K8s < 1.26, when the default StorageClass is created after the PVC, the PVC hangs in Pending state with reason `no persistent volumes available for this claim and no storage class is set`. In K8s, there is a feature gate called `RetroactiveDefaultStorageClass` which makes possible the StorageClass from PVC to be set when the PVC is created before the StorageClass. See https://kubernetes.io/docs/concepts/storage/persistent-volumes/#retroactive-default-storageclass-assignment
In the registry-cache extension we decided to hard-code the StorageClass name to `default` for time being. When it is ensured that `RetroactiveDefaultStorageClass` is enabled by default in the supported K8s versions, then we can drop this.

* Vendor gardener/[email protected]

gardener/[email protected] contains cherry-pick of gardener/gardener#8565.

* Fix typo

* Update comment
  • Loading branch information
ialidzhikov authored Oct 16, 2023
1 parent 8485fee commit e98f4a6
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.21.0

require (
github.com/ahmetb/gen-crd-api-reference-docs v0.3.0
github.com/gardener/gardener v1.80.1
github.com/gardener/gardener v1.80.4
github.com/go-logr/logr v1.2.4
github.com/onsi/ginkgo/v2 v2.11.0
github.com/onsi/gomega v1.27.10
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/gardener/etcd-druid v0.19.2 h1:Z8TTbmVUxZ7UWU5iJAwUHUI6A9E5Mfd5JcvokVfYH1A=
github.com/gardener/etcd-druid v0.19.2/go.mod h1:0Q9nKPiONDac/Gr0SZYFkVXHGt/Yt//rcRfDIUfftZo=
github.com/gardener/gardener v1.80.1 h1:VWDqZbf7E9UGWF8wYOtrbsYCXZWKYZ/+uxEY6/fZCiA=
github.com/gardener/gardener v1.80.1/go.mod h1:6X6NgG25u2qdhrGVndfHJnA8hOc6r/2UwtnJK+/9g2Q=
github.com/gardener/gardener v1.80.4 h1:2RzENvQ0TuXqLwrCOsVwWFc3B3btSLrj5Uu0HGvOY7A=
github.com/gardener/gardener v1.80.4/go.mod h1:6X6NgG25u2qdhrGVndfHJnA8hOc6r/2UwtnJK+/9g2Q=
github.com/gardener/hvpa-controller/api v0.5.0 h1:f4F3O7YUrenwh4S3TgPREPiB287JjjUiUL18OqPLyAA=
github.com/gardener/hvpa-controller/api v0.5.0/go.mod h1:QQl3ELkCaki+8RhXl0FZMfvnm0WCGwGJlGmrxJj6lvM=
github.com/gardener/machine-controller-manager v0.48.1 h1:Oxr5e6gRm7P40Ds4nGlga/0nmfF7cH4rOfjthR6Mm38=
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/registry/helper/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ var _ = Describe("Helpers", func() {
"docker.io",
false, registry.RegistryCache{},
),
Entry("no cache with the given upsteam",
Entry("no cache with the given upstream",
[]registry.RegistryCache{{Upstream: "gcr.io"}, {Upstream: "quay.io"}, {Upstream: "registry.k8s.io"}},
"docker.io",
false, registry.RegistryCache{},
),
Entry("with cache with the given upsteam",
Entry("with cache with the given upstream",
[]registry.RegistryCache{{Upstream: "gcr.io"}, {Upstream: "quay.io"}, {Upstream: "docker.io", Size: &size}, {Upstream: "registry.k8s.io"}},
"docker.io",
true, registry.RegistryCache{Upstream: "docker.io", Size: &size},
Expand Down
3 changes: 3 additions & 0 deletions pkg/component/registrycaches/registrycaches.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ func computeResourcesDataForRegistryCache(cache *v1alpha1.RegistryCache, image s
corev1.ResourceStorage: *cache.Size,
},
},
// We need to explicitly set the spec.storageClassName to default as marking the Gardener managed StorageClass as the default one is configurable on provider extensions side.
// For example, for provider-aws see the storage.managedDefaultClass field in the ControlPlaneConfig (https://github.com/gardener/gardener-extension-provider-aws/blob/v1.48.0/docs/usage/usage.md#controlplaneconfig).
StorageClassName: pointer.String("default"),
},
},
},
Expand Down
1 change: 1 addition & 0 deletions pkg/component/registrycaches/registrycaches_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ spec:
resources:
requests:
storage: ` + size + `
storageClassName: default
status: {}
status:
availableReplicas: 0
Expand Down
2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ github.com/fsnotify/fsnotify
# github.com/gardener/etcd-druid v0.19.2
## explicit; go 1.20
github.com/gardener/etcd-druid/api/v1alpha1
# github.com/gardener/gardener v1.80.1
# github.com/gardener/gardener v1.80.4
## explicit; go 1.21
github.com/gardener/gardener/.github
github.com/gardener/gardener/.github/ISSUE_TEMPLATE
Expand Down

0 comments on commit e98f4a6

Please sign in to comment.