mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-08 03:33:56 +00:00
Incorrect type passed into quota reflector
This commit is contained in:
parent
f3d943e0a4
commit
c9e4c846e6
@ -181,7 +181,7 @@ func (r *replenishmentControllerFactory) NewController(options *ReplenishmentCon
|
|||||||
return r.kubeClient.Core().Secrets(api.NamespaceAll).Watch(options)
|
return r.kubeClient.Core().Secrets(api.NamespaceAll).Watch(options)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&api.PersistentVolumeClaim{},
|
&api.Secret{},
|
||||||
options.ResyncPeriod(),
|
options.ResyncPeriod(),
|
||||||
framework.ResourceEventHandlerFuncs{
|
framework.ResourceEventHandlerFuncs{
|
||||||
DeleteFunc: ObjectReplenishmentDeleteFunc(options),
|
DeleteFunc: ObjectReplenishmentDeleteFunc(options),
|
||||||
|
@ -86,6 +86,43 @@ var _ = Describe("ResourceQuota", func() {
|
|||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("should create a ResourceQuota and capture the life of a secret.", func() {
|
||||||
|
By("Creating a ResourceQuota")
|
||||||
|
quotaName := "test-quota"
|
||||||
|
resourceQuota := newTestResourceQuota(quotaName)
|
||||||
|
resourceQuota, err := createResourceQuota(f.Client, f.Namespace.Name, resourceQuota)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
|
By("Ensuring resource quota status is calculated")
|
||||||
|
usedResources := api.ResourceList{}
|
||||||
|
usedResources[api.ResourceQuotas] = resource.MustParse("1")
|
||||||
|
err = waitForResourceQuota(f.Client, f.Namespace.Name, quotaName, usedResources)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
|
By("Creating a Secret")
|
||||||
|
secret := newTestSecretForQuota("test-secret")
|
||||||
|
secret, err = f.Client.Secrets(f.Namespace.Name).Create(secret)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
|
By("Ensuring resource quota status captures secret creation")
|
||||||
|
usedResources = api.ResourceList{}
|
||||||
|
usedResources[api.ResourceQuotas] = resource.MustParse("1")
|
||||||
|
usedResources[api.ResourceSecrets] = resource.MustParse("2")
|
||||||
|
// we expect there to be two secrets because each namespace will receive
|
||||||
|
// a service account token secret by default
|
||||||
|
err = waitForResourceQuota(f.Client, f.Namespace.Name, quotaName, usedResources)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
|
By("Deleting a secret")
|
||||||
|
err = f.Client.Secrets(f.Namespace.Name).Delete(secret.Name)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
|
By("Ensuring resource quota status released usage")
|
||||||
|
usedResources[api.ResourceSecrets] = resource.MustParse("1")
|
||||||
|
err = waitForResourceQuota(f.Client, f.Namespace.Name, quotaName, usedResources)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
})
|
||||||
|
|
||||||
It("should create a ResourceQuota and capture the life of a pod.", func() {
|
It("should create a ResourceQuota and capture the life of a pod.", func() {
|
||||||
By("Creating a ResourceQuota")
|
By("Creating a ResourceQuota")
|
||||||
quotaName := "test-quota"
|
quotaName := "test-quota"
|
||||||
@ -342,6 +379,7 @@ func newTestResourceQuota(name string) *api.ResourceQuota {
|
|||||||
hard[api.ResourceQuotas] = resource.MustParse("1")
|
hard[api.ResourceQuotas] = resource.MustParse("1")
|
||||||
hard[api.ResourceCPU] = resource.MustParse("1")
|
hard[api.ResourceCPU] = resource.MustParse("1")
|
||||||
hard[api.ResourceMemory] = resource.MustParse("500Mi")
|
hard[api.ResourceMemory] = resource.MustParse("500Mi")
|
||||||
|
hard[api.ResourceSecrets] = resource.MustParse("2")
|
||||||
return &api.ResourceQuota{
|
return &api.ResourceQuota{
|
||||||
ObjectMeta: api.ObjectMeta{Name: name},
|
ObjectMeta: api.ObjectMeta{Name: name},
|
||||||
Spec: api.ResourceQuotaSpec{Hard: hard},
|
Spec: api.ResourceQuotaSpec{Hard: hard},
|
||||||
@ -384,6 +422,19 @@ func newTestServiceForQuota(name string) *api.Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func newTestSecretForQuota(name string) *api.Secret {
|
||||||
|
return &api.Secret{
|
||||||
|
ObjectMeta: api.ObjectMeta{
|
||||||
|
Name: name,
|
||||||
|
},
|
||||||
|
Data: map[string][]byte{
|
||||||
|
"data-1": []byte("value-1\n"),
|
||||||
|
"data-2": []byte("value-2\n"),
|
||||||
|
"data-3": []byte("value-3\n"),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// createResourceQuota in the specified namespace
|
// createResourceQuota in the specified namespace
|
||||||
func createResourceQuota(c *client.Client, namespace string, resourceQuota *api.ResourceQuota) (*api.ResourceQuota, error) {
|
func createResourceQuota(c *client.Client, namespace string, resourceQuota *api.ResourceQuota) (*api.ResourceQuota, error) {
|
||||||
return c.ResourceQuotas(namespace).Create(resourceQuota)
|
return c.ResourceQuotas(namespace).Create(resourceQuota)
|
||||||
|
Loading…
Reference in New Issue
Block a user