diff --git a/actions/kubeapi/namespaces/delete.go b/actions/kubeapi/namespaces/delete.go index 112e47444..e0a13699d 100644 --- a/actions/kubeapi/namespaces/delete.go +++ b/actions/kubeapi/namespaces/delete.go @@ -23,7 +23,7 @@ func DeleteNamespace(client *rancher.Client, clusterID, namespaceName string) er return err } - return kwait.PollUntilContextTimeout(context.Background(), defaults.FiveSecondTimeout, defaults.TenSecondTimeout, false, func(context.Context) (bool, error) { + return kwait.PollUntilContextTimeout(context.Background(), defaults.FiveSecondTimeout, defaults.OneMinuteTimeout, false, func(context.Context) (bool, error) { _, pollErr := ctx.Core.Namespace().Get(namespaceName, metav1.GetOptions{}) if pollErr != nil { if k8serrors.IsNotFound(pollErr) { diff --git a/validation/projects/projects_extended_resource_quota_test.go b/validation/projects/projects_extended_resource_quota_test.go index 60889754a..47e57cfd1 100644 --- a/validation/projects/projects_extended_resource_quota_test.go +++ b/validation/projects/projects_extended_resource_quota_test.go @@ -51,7 +51,7 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) SetupSuite() { } func (perq *ProjectsExtendedResourceQuotaTestSuite) setupUserForProject() (*rancher.Client, *wrangler.Context) { - log.Info("Create a standard user and add the user to the downstream cluster as cluster owner.") + log.Info("Creating a standard user and add the user to the downstream cluster as cluster owner.") _, standardUserClient, err := rbac.AddUserWithRoleToCluster(perq.client, rbac.StandardUser.String(), rbac.ClusterOwner.String(), perq.cluster, nil) require.NoError(perq.T(), err, "Failed to add the user as a cluster owner to the downstream cluster") @@ -67,7 +67,7 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestProjectLevelExtendedReso standardUserClient, _ := perq.setupUserForProject() - log.Info("Create a project with extended ephemeral storage quota applied at project level.") + log.Info("Creating a project with extended ephemeral storage quota limits.") projectExtendedQuota := map[string]string{ projectapi.ExtendedEphemeralStorageResourceQuotaRequest: "100Mi", projectapi.ExtendedEphemeralStorageResourceQuotaLimit: "200Mi", @@ -85,11 +85,11 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestProjectLevelExtendedReso err = namespaceapi.VerifyAnnotationInNamespace(standardUserClient, perq.cluster.ID, firstNamespace.Name, projectapi.ResourceQuotaAnnotation, true) require.NoError(perq.T(), err, "%s annotation should exist", projectapi.ResourceQuotaAnnotation) - log.Info("Verify that the resource quota object is created for the namespace and the quota limits and requests in the resource quota are accurate.") + log.Info("Verifying that the resource quota object is created for the namespace and the quota limits and requests in the resource quota are accurate.") err = namespaceapi.VerifyNamespaceResourceQuota(standardUserClient, perq.cluster.ID, firstNamespace.Name, namespaceExtendedQuota) require.NoError(perq.T(), err) - log.Info("Create a pod in the first namespace within the resource quota limits of the namespace.") + log.Infof("Creating a pod in the first namespace %s within the resource quota limits of the namespace.", firstNamespace.Name) podEphemeralStorageRequest := "60Mi" podEphemeralStorageLimit := "120Mi" requests := map[corev1.ResourceName]string{ @@ -101,7 +101,7 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestProjectLevelExtendedReso _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, firstNamespace.Name, podapi.PauseImage, requests, limits, true) require.NoError(perq.T(), err) - log.Info("Verify that the resource quota usage in the namespace is accurate after creating the pod within quota limits.") + log.Infof("Verifying that the resource quota usage in the namespace %s is accurate after creating the pod within the quota limits.", firstNamespace.Name) expectedUsage := map[string]string{ projectapi.ExtendedEphemeralStorageResourceQuotaRequest: podEphemeralStorageRequest, projectapi.ExtendedEphemeralStorageResourceQuotaLimit: podEphemeralStorageLimit, @@ -109,25 +109,25 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestProjectLevelExtendedReso err = namespaceapi.VerifyUsedNamespaceResourceQuota(standardUserClient, perq.cluster.ID, firstNamespace.Name, expectedUsage) require.NoError(perq.T(), err) - log.Info("Verify that the resource quota usage in the project is accurate after creating the first namespace.") + log.Info("Verifying that the resource quota usage in the project is accurate after creating the first namespace.") err = projectapi.VerifyUsedProjectExtendedResourceQuota(standardUserClient, perq.cluster.ID, createdProject.Name, expectedUsage) require.NoError(perq.T(), err) - log.Info("Create a second namespace in the same project.") + log.Info("Creating a second namespace in the same project.") namespaceName := namegen.AppendRandomString("testns-") secondNamespace, err := namespaceapi.CreateNamespace(standardUserClient, perq.cluster.ID, createdProject.Name, namespaceName, "", nil, nil) require.NoError(perq.T(), err) - log.Info("Verify that the resource quota validation for the second namespace fails.") + log.Infof("Verifying that the resource quota validation for the second namespace %s fails.", secondNamespace.Name) err = namespaceapi.VerifyNamespaceResourceQuotaValidationStatus(standardUserClient, perq.cluster.ID, secondNamespace.Name, nil, namespaceExtendedQuota, false, "exceeds project limit") require.NoError(perq.T(), err) - log.Info("Attempt to create a pod in the second namespace exceeding the resource quota limits of the project and verify that the pod creation fails with exceeded quota error.") + log.Infof("Attempting to create a pod in the second namespace %s, exceeding the resource quota limits of the project.", secondNamespace.Name) _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, secondNamespace.Name, podapi.PauseImage, requests, limits, false) require.Error(perq.T(), err) require.Contains(perq.T(), err.Error(), projectapi.ExceedededResourceQuotaErrorMessage) - log.Info("Verify that resource quota usage in the second namespace remains unchanged after failed pod creation.") + log.Infof("Verifying that resource quota usage in the second namespace %s remains unchanged after failed pod creation.", secondNamespace.Name) expectedUsage = map[string]string{ projectapi.ExtendedEphemeralStorageResourceQuotaRequest: namespaceapi.InitialUsedResourceQuotaValue, projectapi.ExtendedEphemeralStorageResourceQuotaLimit: namespaceapi.InitialUsedResourceQuotaValue, @@ -135,7 +135,7 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestProjectLevelExtendedReso err = namespaceapi.VerifyUsedNamespaceResourceQuota(standardUserClient, perq.cluster.ID, secondNamespace.Name, expectedUsage) require.NoError(perq.T(), err) - log.Info("Verify project-level quota usage remains unchanged.") + log.Info("Verifying that project-level quota usage remains unchanged.") expectedUsage = map[string]string{ projectapi.ExtendedEphemeralStorageResourceQuotaRequest: podEphemeralStorageRequest, projectapi.ExtendedEphemeralStorageResourceQuotaLimit: podEphemeralStorageLimit, @@ -150,7 +150,7 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestProjectLevelExtendedPodC standardUserClient, _ := perq.setupUserForProject() - log.Info("Create project with extended project-level pod count quota = 1") + log.Info("Creating a project with extended project-level pod count quota.") projectExtendedQuota := map[string]string{ projectapi.ExtendedPodResourceQuotaKey: "1", } @@ -166,20 +166,20 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestProjectLevelExtendedPodC err = namespaceapi.VerifyAnnotationInNamespace(standardUserClient, perq.cluster.ID, ns1.Name, projectapi.ResourceQuotaAnnotation, true) require.NoError(perq.T(), err, "%s annotation should exist", projectapi.ResourceQuotaAnnotation) - log.Info("Verify that the resource quota object is created for the namespace and the quota limits and requests in the resource quota are accurate.") + log.Infof("Verifying that the resource quota object is created for the namespace %s and the quota limits and requests in the resource quota are accurate.", ns1.Name) err = namespaceapi.VerifyNamespaceResourceQuota(standardUserClient, perq.cluster.ID, ns1.Name, namespaceExtendedQuota) require.NoError(perq.T(), err) - log.Info("Create a pod in the first namespace (should succeed).") + log.Infof("Creating a pod in the first namespace %s", ns1.Name) _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, ns1.Name, podapi.PauseImage, nil, nil, true) require.NoError(perq.T(), err) - log.Info("Create second namespace in same project.") + log.Info("Creating a second namespace in the same project.") ns2Name := namegen.AppendRandomString("testns-") ns2, err := namespaceapi.CreateNamespace(standardUserClient, perq.cluster.ID, createdProject.Name, ns2Name, "", nil, nil) require.NoError(perq.T(), err) - log.Info("Attempt to create pod in second namespace - SHOULD FAIL if project-level extended quota is enforced.") + log.Infof("Attempting to create a pod in the second namespace %s, exceeding the project-level extended pod count quota", ns2.Name) _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, ns2.Name, podapi.PauseImage, nil, nil, false) require.Error(perq.T(), err) require.Contains(perq.T(), err.Error(), projectapi.ExceedededResourceQuotaErrorMessage) @@ -191,7 +191,7 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestProjectLevelExistingReso standardUserClient, _ := perq.setupUserForProject() - log.Info("Create a project with existing pod count resource quota.") + log.Info("Creating a project with existing pod count resource quota.") projectPodLimit := "1" namespacePodLimit := "1" @@ -207,7 +207,11 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestProjectLevelExistingReso createdProject, firstNamespace, err := projectapi.CreateProjectAndNamespaceWithTemplate(standardUserClient, perq.cluster.ID, projectTemplate) require.NoError(perq.T(), err) - log.Info("Create a second namespace in the same project.") + log.Infof("Creating a pod in the first namespace %s", firstNamespace.Name) + _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, firstNamespace.Name, podapi.PauseImage, nil, nil, true) + require.NoError(perq.T(), err) + + log.Info("Creating a second namespace in the same project.") existingLimits := map[string]string{"pods": namespacePodLimit} ns2Name := namegen.AppendRandomString("testns2-") ns2, err := namespaceapi.CreateNamespace(standardUserClient, perq.cluster.ID, createdProject.Name, ns2Name, "", nil, nil) @@ -215,14 +219,196 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestProjectLevelExistingReso err = namespaceapi.VerifyNamespaceResourceQuotaValidationStatus(standardUserClient, perq.cluster.ID, ns2.Name, existingLimits, nil, false, "exceeds project limit") require.NoError(perq.T(), err) - log.Info("Create a pod in the first namespace.") - _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, firstNamespace.Name, podapi.PauseImage, nil, nil, true) + log.Infof("Attempting to create another pod in the second namespace %s, exceeding the project-level existing pod count quota", ns2.Name) + _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, ns2.Name, podapi.PauseImage, nil, nil, false) + require.Error(perq.T(), err, "expected project-level pod quota to block pods across namespaces") + require.Contains(perq.T(), err.Error(), projectapi.ExceedededResourceQuotaErrorMessage) +} + +func (perq *ProjectsExtendedResourceQuotaTestSuite) TestProjectMixedQuotaExceedExtendedEphemeralStorage() { + subSession := perq.session.NewSession() + defer subSession.Cleanup() + + standardUserClient, _ := perq.setupUserForProject() + + log.Info("Creating a project with project-level pod count and extended ephemeral storage quota.") + projectPodCount := "2" + namespacePodCount := "1" + projectExistingQuota := &v3.ResourceQuotaLimit{ + Pods: projectPodCount, + } + namespaceExistingQuota := &v3.ResourceQuotaLimit{ + Pods: namespacePodCount, + } + projectExtendedQuota := map[string]string{ + projectapi.ExtendedEphemeralStorageResourceQuotaRequest: "150Mi", + projectapi.ExtendedEphemeralStorageResourceQuotaLimit: "250Mi", + } + + namespaceExtendedQuota := map[string]string{ + projectapi.ExtendedEphemeralStorageResourceQuotaRequest: "100Mi", + projectapi.ExtendedEphemeralStorageResourceQuotaLimit: "200Mi", + } + + projectTemplate := projectapi.NewProjectTemplate(perq.cluster.ID) + projectapi.ApplyProjectAndNamespaceResourceQuotas(projectTemplate, projectExistingQuota, projectExtendedQuota, namespaceExistingQuota, namespaceExtendedQuota) + createdProject, ns1, err := projectapi.CreateProjectAndNamespaceWithTemplate(standardUserClient, perq.cluster.ID, projectTemplate) + require.NoError(perq.T(), err) + + log.Infof("Creating a pod in the namespace %s within the extended project limits.", ns1.Name) + requests := map[corev1.ResourceName]string{ + corev1.ResourceEphemeralStorage: "100Mi", + } + limits := map[corev1.ResourceName]string{ + corev1.ResourceEphemeralStorage: "200Mi", + } + + _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, ns1.Name, podapi.PauseImage, requests, limits, true) + require.NoError(perq.T(), err) + + log.Info("Creating a second namespace in same project.") + ns2Name := namegen.AppendRandomString("testns-") + ns2, err := namespaceapi.CreateNamespace(standardUserClient, perq.cluster.ID, createdProject.Name, ns2Name, "", nil, nil) + require.NoError(perq.T(), err) + + log.Infof("Attempting to create a pod in the second namespace %s, exceeding the project-level extended ephemeral storage quota", ns2.Name) + _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, ns2.Name, podapi.PauseImage, requests, limits, false) + require.Error(perq.T(), err) + require.Contains(perq.T(), err.Error(), projectapi.ExceedededResourceQuotaErrorMessage) + + log.Info("Verifying project-level used quota remains unchanged.") + expectedProjectUsed := map[string]string{ + projectapi.ExtendedEphemeralStorageResourceQuotaRequest: "100Mi", + projectapi.ExtendedEphemeralStorageResourceQuotaLimit: "200Mi", + } + err = projectapi.VerifyUsedProjectExtendedResourceQuota(standardUserClient, perq.cluster.ID, createdProject.Name, expectedProjectUsed) require.NoError(perq.T(), err) +} + +func (perq *ProjectsExtendedResourceQuotaTestSuite) TestProjectMixedQuotaExceedExistingPodCount() { + subSession := perq.session.NewSession() + defer subSession.Cleanup() + + standardUserClient, _ := perq.setupUserForProject() - log.Info("Attempt to create another pod in the second namespace and verify that it fails with exceeded quota error") + log.Info("Creating a project with project-level pod count and extended ephemeral storage quota.") + projectPodCount := "1" + namespacePodCount := "1" + projectExistingQuota := &v3.ResourceQuotaLimit{ + Pods: projectPodCount, + } + namespaceExistingQuota := &v3.ResourceQuotaLimit{ + Pods: namespacePodCount, + } + projectExtendedQuota := map[string]string{ + projectapi.ExtendedEphemeralStorageResourceQuotaRequest: "250Mi", + projectapi.ExtendedEphemeralStorageResourceQuotaLimit: "500Mi", + } + + namespaceExtendedQuota := map[string]string{ + projectapi.ExtendedEphemeralStorageResourceQuotaRequest: "100Mi", + projectapi.ExtendedEphemeralStorageResourceQuotaLimit: "200Mi", + } + + projectTemplate := projectapi.NewProjectTemplate(perq.cluster.ID) + projectapi.ApplyProjectAndNamespaceResourceQuotas(projectTemplate, projectExistingQuota, projectExtendedQuota, namespaceExistingQuota, namespaceExtendedQuota) + createdProject, ns1, err := projectapi.CreateProjectAndNamespaceWithTemplate(standardUserClient, perq.cluster.ID, projectTemplate) + require.NoError(perq.T(), err) + + log.Infof("Creating a pod in the namespace %s within the existing project limits.", ns1.Name) + _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, ns1.Name, podapi.PauseImage, nil, nil, true) + require.NoError(perq.T(), err) + + log.Infof("Creating a second namespace in the same project") + ns2Name := namegen.AppendRandomString("testns-") + ns2, err := namespaceapi.CreateNamespace(standardUserClient, perq.cluster.ID, createdProject.Name, ns2Name, "", nil, nil) + require.NoError(perq.T(), err) + + log.Infof("Attempting to create a pod in the second namespace %s, exceeding existing project pod count limit.", ns2.Name) _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, ns2.Name, podapi.PauseImage, nil, nil, false) - require.Error(perq.T(), err, "expected project-level pod quota to block pods across namespaces") + require.Error(perq.T(), err) require.Contains(perq.T(), err.Error(), projectapi.ExceedededResourceQuotaErrorMessage) + + log.Info("Verifying project-level used quota remains unchanged.") + expectedUsed := map[string]string{ + projectapi.ExistingPodResourceQuotaKey: "1", + } + err = projectapi.VerifyUsedProjectExistingResourceQuota(standardUserClient, perq.cluster.ID, createdProject.Name, expectedUsed) + require.NoError(perq.T(), err) +} + +func (perq *ProjectsExtendedResourceQuotaTestSuite) TestProjectLevelExistingOverridesExtended() { + subSession := perq.session.NewSession() + defer subSession.Cleanup() + + standardUserClient, _ := perq.setupUserForProject() + + log.Info("Creating a project with existing and extended pod count resource quotas that conflict.") + projectPodCount := "1" + namespacePodCount := "1" + + projectExistingQuota := &v3.ResourceQuotaLimit{ + Pods: projectPodCount, + } + + namespaceExistingQuota := &v3.ResourceQuotaLimit{ + Pods: namespacePodCount, + } + + projectExtendedQuota := map[string]string{ + projectapi.ExtendedPodResourceQuotaKey: "10", + projectapi.ExtendedEphemeralStorageResourceQuotaRequest: "200Mi", + projectapi.ExtendedEphemeralStorageResourceQuotaLimit: "400Mi", + } + + namespaceExtendedQuota := map[string]string{ + projectapi.ExtendedPodResourceQuotaKey: "5", + projectapi.ExtendedEphemeralStorageResourceQuotaRequest: "50Mi", + projectapi.ExtendedEphemeralStorageResourceQuotaLimit: "100Mi", + } + + projectTemplate := projectapi.NewProjectTemplate(perq.cluster.ID) + projectapi.ApplyProjectAndNamespaceResourceQuotas(projectTemplate, projectExistingQuota, projectExtendedQuota, namespaceExistingQuota, namespaceExtendedQuota) + createdProject, ns1, err := projectapi.CreateProjectAndNamespaceWithTemplate(standardUserClient, perq.cluster.ID, projectTemplate) + require.NoError(perq.T(), err) + require.Equal(perq.T(), projectPodCount, createdProject.Spec.ResourceQuota.Limit.Pods) + require.Equal(perq.T(), namespacePodCount, createdProject.Spec.NamespaceDefaultResourceQuota.Limit.Pods) + require.Equal(perq.T(), projectExtendedQuota, createdProject.Spec.ResourceQuota.Limit.Extended) + require.Equal(perq.T(), namespaceExtendedQuota, createdProject.Spec.NamespaceDefaultResourceQuota.Limit.Extended) + + log.Info("Verifying project-level quota usage after first namespace creation.") + projectExistingUsed := map[string]string{ + projectapi.ExistingPodResourceQuotaKey: "1", + } + projectExtendedUsed := map[string]string{ + projectapi.ExtendedPodResourceQuotaKey: "5", + } + + err = projectapi.VerifyUsedProjectExistingResourceQuota(standardUserClient, perq.cluster.ID, createdProject.Name, projectExistingUsed) + require.NoError(perq.T(), err) + + err = projectapi.VerifyUsedProjectExtendedResourceQuota(standardUserClient, perq.cluster.ID, createdProject.Name, projectExtendedUsed) + require.NoError(perq.T(), err) + + log.Info("Creating a second namespace in same project.") + ns2Name := namegen.AppendRandomString("testns-") + ns2, err := namespaceapi.CreateNamespace(standardUserClient, perq.cluster.ID, createdProject.Name, ns2Name, "", nil, nil) + require.NoError(perq.T(), err) + + log.Infof("Creating a pod in the first namespace %s within existing project pod count limit.", ns1.Name) + _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, ns1.Name, podapi.PauseImage, nil, nil, true) + require.NoError(perq.T(), err) + + log.Infof("Attempting to create a pod in the second namespace %s, exceeding existing project pod count limit.", ns2.Name) + _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, ns2.Name, podapi.PauseImage, nil, nil, false) + require.Error(perq.T(), err) + require.Contains(perq.T(), err.Error(), projectapi.ExceedededResourceQuotaErrorMessage) + + log.Info("Verifying project-level usage remains unchanged.") + err = projectapi.VerifyUsedProjectExistingResourceQuota(standardUserClient, perq.cluster.ID, createdProject.Name, projectExistingUsed) + require.NoError(perq.T(), err) + err = projectapi.VerifyUsedProjectExtendedResourceQuota(standardUserClient, perq.cluster.ID, createdProject.Name, projectExtendedUsed) + require.NoError(perq.T(), err) } func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceLevelExtendedResourceQuota() { @@ -231,7 +417,7 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceLevelExtendedRe standardUserClient, _ := perq.setupUserForProject() - log.Info("Create a project with extended ephemeral storage resource quota.") + log.Info("Creating a project with extended ephemeral storage resource quota.") projectExtendedQuota := map[string]string{ projectapi.ExtendedEphemeralStorageResourceQuotaRequest: "200Mi", projectapi.ExtendedEphemeralStorageResourceQuotaLimit: "400Mi", @@ -248,11 +434,11 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceLevelExtendedRe require.Equal(perq.T(), projectExtendedQuota, createdProject.Spec.ResourceQuota.Limit.Extended, "Project extended quota mismatch") require.Equal(perq.T(), namespaceExtendedQuota, createdProject.Spec.NamespaceDefaultResourceQuota.Limit.Extended, "Namespace extended quota mismatch") - log.Infof("Verify that the namespace has the annotation: %s.", projectapi.ResourceQuotaAnnotation) + log.Infof("Verifying that the namespace has the annotation: %s.", projectapi.ResourceQuotaAnnotation) err = namespaceapi.VerifyAnnotationInNamespace(standardUserClient, perq.cluster.ID, ns1.Name, projectapi.ResourceQuotaAnnotation, true) require.NoError(perq.T(), err, "%s annotation should exist", projectapi.ResourceQuotaAnnotation) - log.Info("Verify the resource quota object created for the namespace has the correct hard and used limits.") + log.Info("Verifying the resource quota object created for the namespace has the correct hard and used limits.") err = namespaceapi.VerifyNamespaceResourceQuota(standardUserClient, perq.cluster.ID, ns1.Name, namespaceExtendedQuota) require.NoError(perq.T(), err) expectedUsage := map[string]string{ @@ -262,7 +448,7 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceLevelExtendedRe err = namespaceapi.VerifyUsedNamespaceResourceQuota(standardUserClient, perq.cluster.ID, ns1.Name, expectedUsage) require.NoError(perq.T(), err) - log.Infof("Create a pod in the namespace %s with the quota limits within the namespace quota limits, and verify that the pod is created.", ns1.Name) + log.Infof("Creating a pod in the first namespace %s within the namespace quota limits", ns1.Name) podEphemeralStorageRequest := "50Mi" podEphemeralStorageLimit := "100Mi" @@ -276,7 +462,7 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceLevelExtendedRe _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, ns1.Name, podapi.PauseImage, requests, limits, true) require.NoError(perq.T(), err, "Failed to create pod with ephemeral storage requests and limits") - log.Info("Verify the resource quota object in the namespace has the correct used limits.") + log.Info("Verifying the resource quota object in the namespace has the correct used limits.") expectedUsage = map[string]string{ projectapi.ExtendedEphemeralStorageResourceQuotaRequest: podEphemeralStorageRequest, projectapi.ExtendedEphemeralStorageResourceQuotaLimit: podEphemeralStorageLimit, @@ -284,21 +470,21 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceLevelExtendedRe err = namespaceapi.VerifyUsedNamespaceResourceQuota(standardUserClient, perq.cluster.ID, ns1.Name, expectedUsage) require.NoError(perq.T(), err) - log.Info("Attempt to create another pod in the namespace exceeding the namespace quota limits, and verify that the pod creation fails with exceeded quota error.") + log.Infof("Attempting to create another pod in the namespace %s, exceeding the namespace quota limits", ns1.Name) _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, ns1.Name, podapi.PauseImage, requests, limits, false) require.Error(perq.T(), err, "Pod creation with resource quota limits exceeding namespace quota should fail") require.Contains(perq.T(), err.Error(), projectapi.ExceedededResourceQuotaErrorMessage) - log.Info("Verify that resource quota usage in the namespace remains unchanged after failed pod creation.") + log.Info("Verifying that resource quota usage in the namespace remains unchanged after failed pod creation.") err = namespaceapi.VerifyUsedNamespaceResourceQuota(standardUserClient, perq.cluster.ID, ns1.Name, expectedUsage) require.NoError(perq.T(), err) - log.Info("Create another namespace in the same project.") + log.Info("Creating another namespace in the same project.") ns2Name := namegen.AppendRandomString("testns") ns2, err := namespaceapi.CreateNamespace(standardUserClient, perq.cluster.ID, createdProject.Name, ns2Name, "", nil, nil) require.NoError(perq.T(), err) - log.Info("Verify that the resource quota usage in the project is accurate.") + log.Info("Verifying that the resource quota usage in the project is accurate.") expectedUsage = map[string]string{ projectapi.ExtendedEphemeralStorageResourceQuotaRequest: "100Mi", projectapi.ExtendedEphemeralStorageResourceQuotaLimit: "200Mi", @@ -306,11 +492,11 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceLevelExtendedRe err = projectapi.VerifyUsedProjectExtendedResourceQuota(standardUserClient, perq.cluster.ID, createdProject.Name, expectedUsage) require.NoError(perq.T(), err) - log.Infof("Create a pod in the namespace %s with the quota limits within the namespace quota limits, and verify that the pods are created.", ns2.Name) + log.Infof("Creating a pod in the namespace %s within the namespace quota limits", ns2.Name) _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, ns2.Name, podapi.PauseImage, requests, limits, true) require.NoError(perq.T(), err, "Failed to create pod with ephemeral storage requests and limits") - log.Info("Verify that the resource quota usage in the namespace is accurate after creating a pod within the quota limits.") + log.Info("Verifying that the resource quota usage in the namespace is accurate after creating a pod within the quota limits.") expectedUsage = map[string]string{ projectapi.ExtendedEphemeralStorageResourceQuotaRequest: podEphemeralStorageRequest, projectapi.ExtendedEphemeralStorageResourceQuotaLimit: podEphemeralStorageLimit, @@ -325,7 +511,7 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceLevelExtendedPo standardUserClient, _ := perq.setupUserForProject() - log.Info("Create a project with extended pod count resource quota.") + log.Info("Creating a project with extended pod count resource quota.") projectExtendedQuota := map[string]string{ projectapi.ExtendedPodResourceQuotaKey: "10", } @@ -341,11 +527,11 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceLevelExtendedPo require.Equal(perq.T(), projectExtendedQuota, createdProject.Spec.ResourceQuota.Limit.Extended, "Project extended quota mismatch") require.Equal(perq.T(), namespaceExtendedQuota, createdProject.Spec.NamespaceDefaultResourceQuota.Limit.Extended, "Namespace extended quota mismatch") - log.Infof("Verify that the namespace has the annotation: %s.", projectapi.ResourceQuotaAnnotation) + log.Infof("Verifying that the namespace has the annotation: %s.", projectapi.ResourceQuotaAnnotation) err = namespaceapi.VerifyAnnotationInNamespace(standardUserClient, perq.cluster.ID, ns1.Name, projectapi.ResourceQuotaAnnotation, true) require.NoError(perq.T(), err, "%s annotation should exist", projectapi.ResourceQuotaAnnotation) - log.Info("Verify the resource quota object created for the namespace has the correct hard and used limits.") + log.Info("Verifying the resource quota object created for the namespace has the correct hard and used limits.") err = namespaceapi.VerifyNamespaceResourceQuota(standardUserClient, perq.cluster.ID, ns1.Name, namespaceExtendedQuota) require.NoError(perq.T(), err) expectedUsage := map[string]string{ @@ -354,43 +540,43 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceLevelExtendedPo err = namespaceapi.VerifyUsedNamespaceResourceQuota(standardUserClient, perq.cluster.ID, ns1.Name, expectedUsage) require.NoError(perq.T(), err) - log.Infof("Create a pod in the namespace %s with the quota limits within the namespace quota limits, and verify that the pod is created.", ns1.Name) + log.Infof("Creating a pod in the namespace %s within the namespace quota limits", ns1.Name) _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, ns1.Name, podapi.PauseImage, nil, nil, true) require.NoError(perq.T(), err) - log.Info("Verify the resource quota object in the namespace has the correct used limits.") + log.Info("Verifying the resource quota object in the namespace has the correct used limits.") expectedUsage = map[string]string{ projectapi.ExtendedPodResourceQuotaKey: "1", } err = namespaceapi.VerifyUsedNamespaceResourceQuota(standardUserClient, perq.cluster.ID, ns1.Name, expectedUsage) require.NoError(perq.T(), err) - log.Info("Attempt to create another pod in the namespace exceeding the namespace quota limits, and verify that the pod creation fails with exceeded quota error.") + log.Infof("Attempting to create another pod in the namespace %s, exceeding the namespace quota limits", ns1.Name) _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, ns1.Name, podapi.PauseImage, nil, nil, false) require.Error(perq.T(), err) require.Contains(perq.T(), err.Error(), projectapi.ExceedededResourceQuotaErrorMessage) - log.Info("Verify that resource quota usage in the namespace remains unchanged after failed pod creation.") + log.Info("Verifying that resource quota usage in the namespace remains unchanged after failed pod creation.") err = namespaceapi.VerifyUsedNamespaceResourceQuota(standardUserClient, perq.cluster.ID, ns1.Name, expectedUsage) require.NoError(perq.T(), err) - log.Info("Create another namespace in the same project.") + log.Info("Creating another namespace in the same project.") ns2Name := namegen.AppendRandomString("testns") ns2, err := namespaceapi.CreateNamespace(standardUserClient, perq.cluster.ID, createdProject.Name, ns2Name, "", nil, nil) require.NoError(perq.T(), err) - log.Info("Verify that the resource quota usage in the project is accurate.") + log.Info("Verifying that the resource quota usage in the project is accurate.") expectedUsage = map[string]string{ projectapi.ExtendedPodResourceQuotaKey: "2", } err = projectapi.VerifyUsedProjectExtendedResourceQuota(standardUserClient, perq.cluster.ID, createdProject.Name, expectedUsage) require.NoError(perq.T(), err) - log.Infof("Create a pod in the namespace %s with the quota limits within the namespace quota limits, and verify that the pods are created.", ns2.Name) + log.Infof("Creating a pod in the namespace %s within the namespace quota limits", ns2.Name) _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, ns2.Name, podapi.PauseImage, nil, nil, true) require.NoError(perq.T(), err) - log.Info("Verify that the resource quota usage in the namespace is accurate after creating a pod within the quota limits.") + log.Info("Verifying that the resource quota usage in the namespace is accurate after creating a pod within the quota limits.") expectedUsage = map[string]string{ projectapi.ExtendedPodResourceQuotaKey: "1", } @@ -404,7 +590,7 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceLevelShorthandE standardUserClient, _ := perq.setupUserForProject() - log.Info("Create a project with shorthand extended ephemeral storage resource quota.") + log.Info("Creating a project with shorthand extended ephemeral storage resource quota.") projectExtendedQuota := map[string]string{ projectapi.ExtendedEphemeralStorageResourceQuotaKey: "200Mi", } @@ -419,7 +605,7 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceLevelShorthandE require.Equal(perq.T(), projectExtendedQuota, createdProject.Spec.ResourceQuota.Limit.Extended, "Project extended quota mismatch") require.Equal(perq.T(), namespaceExtendedQuota, createdProject.Spec.NamespaceDefaultResourceQuota.Limit.Extended, "Namespace extended quota mismatch") - log.Info("Verify the resource quota object created for the namespace has the correct hard and used limits.") + log.Info("Verifying the resource quota object created for the namespace has the correct hard and used limits.") err = namespaceapi.VerifyNamespaceResourceQuota(standardUserClient, perq.cluster.ID, ns1.Name, namespaceExtendedQuota) require.NoError(perq.T(), err) expectedUsage := map[string]string{ @@ -428,7 +614,7 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceLevelShorthandE err = namespaceapi.VerifyUsedNamespaceResourceQuota(standardUserClient, perq.cluster.ID, ns1.Name, expectedUsage) require.NoError(perq.T(), err) - log.Infof("Create a pod in the namespace %s with the quota limits within the namespace quota limits, and verify that the pod is created.", ns1.Name) + log.Infof("Creating a pod in the namespace %s within the namespace quota limits", ns1.Name) podEphemeralStorageRequest := "50Mi" podEphemeralStorageLimit := "100Mi" @@ -442,39 +628,39 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceLevelShorthandE _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, ns1.Name, podapi.PauseImage, requests, limits, true) require.NoError(perq.T(), err, "Failed to create pod with ephemeral storage requests and limits") - log.Info("Verify the resource quota object in the namespace has the correct used limits.") + log.Info("Verifying the resource quota object in the namespace has the correct used limits.") expectedUsage = map[string]string{ projectapi.ExtendedEphemeralStorageResourceQuotaKey: podEphemeralStorageRequest, } err = namespaceapi.VerifyUsedNamespaceResourceQuota(standardUserClient, perq.cluster.ID, ns1.Name, expectedUsage) require.NoError(perq.T(), err) - log.Info("Attempt to create another pod in the namespace exceeding the namespace quota limits, and verify that the pod creation fails with exceeded quota error.") + log.Infof("Attempting to create another pod in the namespace %s, exceeding the namespace quota limits", ns1.Name) _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, ns1.Name, podapi.PauseImage, requests, limits, false) require.Error(perq.T(), err, "Pod creation with resource quota limits exceeding namespace quota should fail") require.Contains(perq.T(), err.Error(), projectapi.ExceedededResourceQuotaErrorMessage) - log.Info("Verify that resource quota usage in the namespace remains unchanged after failed pod creation.") + log.Info("Verifying that resource quota usage in the namespace remains unchanged after failed pod creation.") err = namespaceapi.VerifyUsedNamespaceResourceQuota(standardUserClient, perq.cluster.ID, ns1.Name, expectedUsage) require.NoError(perq.T(), err) - log.Info("Create another namespace in the same project.") + log.Info("Creating another namespace in the same project.") ns2Name := namegen.AppendRandomString("testns") ns2, err := namespaceapi.CreateNamespace(standardUserClient, perq.cluster.ID, createdProject.Name, ns2Name, "", nil, nil) require.NoError(perq.T(), err) - log.Info("Verify that the resource quota usage in the project is accurate.") + log.Info("Verifying that the resource quota usage in the project is accurate.") expectedUsage = map[string]string{ projectapi.ExtendedEphemeralStorageResourceQuotaKey: "100Mi", } err = projectapi.VerifyUsedProjectExtendedResourceQuota(standardUserClient, perq.cluster.ID, createdProject.Name, expectedUsage) require.NoError(perq.T(), err) - log.Infof("Create a pod in the namespace %s with the quota limits within the namespace quota limits, and verify that the pods are created.", ns2.Name) + log.Infof("Creating a pod in the namespace %s within the namespace quota limits", ns2.Name) _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, ns2.Name, podapi.PauseImage, requests, limits, true) require.NoError(perq.T(), err, "Failed to create pod with ephemeral storage requests and limits") - log.Info("Verify that the resource quota usage in the namespace is accurate after creating a pod within the quota limits.") + log.Info("Verifying that the resource quota usage in the namespace is accurate after creating a pod within the quota limits.") expectedUsage = map[string]string{ projectapi.ExtendedEphemeralStorageResourceQuotaKey: podEphemeralStorageRequest, } @@ -488,7 +674,7 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceLevelExistingRe standardUserClient, _ := perq.setupUserForProject() - log.Info("Create a project with existing pod count resource quota.") + log.Info("Creating a project with existing pod count resource quota.") projectPodLimit := "10" namespacePodLimit := "1" @@ -506,11 +692,11 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceLevelExistingRe require.Equal(perq.T(), projectPodLimit, createdProject.Spec.ResourceQuota.Limit.Pods, "Project existing quota mismatch") require.Equal(perq.T(), namespacePodLimit, createdProject.Spec.NamespaceDefaultResourceQuota.Limit.Pods, "Namespace existing quota mismatch") - log.Infof("Verify that the namespace has the annotation: %s.", projectapi.ResourceQuotaAnnotation) + log.Infof("Verifying that the namespace has the annotation: %s.", projectapi.ResourceQuotaAnnotation) err = namespaceapi.VerifyAnnotationInNamespace(standardUserClient, perq.cluster.ID, ns1.Name, projectapi.ResourceQuotaAnnotation, true) require.NoError(perq.T(), err, "%s annotation should exist", projectapi.ResourceQuotaAnnotation) - log.Info("Verify the resource quota object created for the namespace has the correct hard and used limits.") + log.Info("Verifying the resource quota object created for the namespace has the correct hard and used limits.") expectedNamespaceQuota := map[string]string{ projectapi.ExistingPodResourceQuotaKey: namespacePodLimit, } @@ -522,27 +708,27 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceLevelExistingRe err = namespaceapi.VerifyUsedNamespaceResourceQuota(standardUserClient, perq.cluster.ID, ns1.Name, expectedUsage) require.NoError(perq.T(), err) - log.Infof("Create a pod in the namespace %s with the quota limits within the namespace quota limits, and verify that the pod is created.", ns1.Name) + log.Infof("Creating a pod in the namespace %s within the namespace quota limits", ns1.Name) _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, ns1.Name, podapi.PauseImage, nil, nil, true) require.NoError(perq.T(), err) - log.Info("Verify the resource quota object in the namespace has the correct used limits.") + log.Info("Verifying the resource quota object in the namespace has the correct used limits.") expectedUsage = map[string]string{ projectapi.ExistingPodResourceQuotaKey: "1", } err = namespaceapi.VerifyUsedNamespaceResourceQuota(standardUserClient, perq.cluster.ID, ns1.Name, expectedUsage) require.NoError(perq.T(), err) - log.Info("Attempt to create another pod in the namespace exceeding the namespace quota limits, and verify that the pod creation fails with exceeded quota error.") + log.Infof("Attempting to create another pod in the namespace %s, exceeding the namespace quota limits.", ns1.Name) _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, ns1.Name, podapi.PauseImage, nil, nil, false) require.Error(perq.T(), err) require.Contains(perq.T(), err.Error(), projectapi.ExceedededResourceQuotaErrorMessage) - log.Info("Verify that resource quota usage in the namespace remains unchanged after failed pod creation.") + log.Info("Verifying that resource quota usage in the namespace remains unchanged after failed pod creation.") err = namespaceapi.VerifyUsedNamespaceResourceQuota(standardUserClient, perq.cluster.ID, ns1.Name, expectedUsage) require.NoError(perq.T(), err) - log.Info("Create another namespace in the same project.") + log.Info("Creating another namespace in the same project.") ns2Name := namegen.AppendRandomString("testns") ns2, err := namespaceapi.CreateNamespace(standardUserClient, perq.cluster.ID, createdProject.Name, ns2Name, "", nil, nil) require.NoError(perq.T(), err) @@ -552,11 +738,11 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceLevelExistingRe err = projectapi.VerifyUsedProjectExistingResourceQuota(standardUserClient, perq.cluster.ID, createdProject.Name, projectExistingUsed) require.NoError(perq.T(), err) - log.Infof("Create a pod in the namespace %s with the quota limits within the namespace quota limits, and verify that the pods are created.", ns2.Name) + log.Infof("Creating a pod in the namespace %s within the namespace quota limits", ns2.Name) _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, ns2.Name, podapi.PauseImage, nil, nil, true) require.NoError(perq.T(), err) - log.Info("Verify that the resource quota usage in the namespace is accurate after creating a pod within the quota limits.") + log.Info("Verifying that the resource quota usage in the namespace is accurate after creating a pod within the quota limits.") expectedUsage = map[string]string{ projectapi.ExistingPodResourceQuotaKey: "1", } @@ -570,7 +756,7 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceMixedQuotaExcee standardUserClient, _ := perq.setupUserForProject() - log.Info("Create a project with existing pod count quota and extended ephemeral storage quota.") + log.Info("Creating a project with existing pod count quota and extended ephemeral storage quota.") projectPodCount := "10" namespacePodCount := "2" projectExistingQuota := &v3.ResourceQuotaLimit{ @@ -597,11 +783,11 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceMixedQuotaExcee require.Equal(perq.T(), namespacePodCount, createdProject.Spec.NamespaceDefaultResourceQuota.Limit.Pods) require.Equal(perq.T(), namespaceExtendedQuota, createdProject.Spec.NamespaceDefaultResourceQuota.Limit.Extended) - log.Infof("Verify namespace %s has resource quota annotation.", ns1.Name) + log.Infof("Verifying namespace %s has resource quota annotation.", ns1.Name) err = namespaceapi.VerifyAnnotationInNamespace(standardUserClient, perq.cluster.ID, ns1.Name, projectapi.ResourceQuotaAnnotation, true) require.NoError(perq.T(), err) - log.Info("Verify initial hard and used limits in namespace.") + log.Info("Verifying initial hard and used limits in namespace.") expectedHard := map[string]string{ projectapi.ExistingPodResourceQuotaKey: namespacePodCount, projectapi.ExtendedEphemeralStorageResourceQuotaRequest: "50Mi", @@ -618,7 +804,7 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceMixedQuotaExcee err = namespaceapi.VerifyUsedNamespaceResourceQuota(standardUserClient, perq.cluster.ID, ns1.Name, expectedUsed) require.NoError(perq.T(), err) - log.Info("Create pod within both pod-count and ephemeral-storage limits.") + log.Info("Creating a pod within both pod-count and ephemeral-storage limits.") requests := map[corev1.ResourceName]string{ corev1.ResourceEphemeralStorage: "50Mi", } @@ -636,12 +822,12 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceMixedQuotaExcee err = namespaceapi.VerifyUsedNamespaceResourceQuota(standardUserClient, perq.cluster.ID, ns1.Name, expectedUsed) require.NoError(perq.T(), err) - log.Info("Attempt to create another pod and verify that it fails due to exceeding ephemeral-storage limits.") + log.Infof("Attempting to create another pod in the namespace %s, exceeding the namespace quota limits.", ns1.Name) _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, ns1.Name, podapi.PauseImage, requests, limits, false) require.Error(perq.T(), err) require.Contains(perq.T(), err.Error(), projectapi.ExceedededResourceQuotaErrorMessage) - log.Info("Verify project level used quota is accurate.") + log.Info("Verifying project level used quota is accurate.") projectExtendedUsed := map[string]string{ projectapi.ExtendedEphemeralStorageResourceQuotaRequest: "50Mi", projectapi.ExtendedEphemeralStorageResourceQuotaLimit: "100Mi", @@ -661,7 +847,7 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceMixedQuotaExcee standardUserClient, _ := perq.setupUserForProject() - log.Info("Create a project with existing pod count quota and extended ephemeral storage quota.") + log.Info("Creating a project with existing pod count quota and extended ephemeral storage quota.") projectPodCount := "10" namespacePodCount := "1" projectExistingQuota := &v3.ResourceQuotaLimit{ @@ -688,11 +874,11 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceMixedQuotaExcee require.Equal(perq.T(), namespacePodCount, createdProject.Spec.NamespaceDefaultResourceQuota.Limit.Pods) require.Equal(perq.T(), namespaceExtendedQuota, createdProject.Spec.NamespaceDefaultResourceQuota.Limit.Extended) - log.Infof("Verify namespace %s has resource quota annotation.", ns1.Name) + log.Infof("Verifying namespace %s has resource quota annotation.", ns1.Name) err = namespaceapi.VerifyAnnotationInNamespace(standardUserClient, perq.cluster.ID, ns1.Name, projectapi.ResourceQuotaAnnotation, true) require.NoError(perq.T(), err) - log.Info("Verify initial hard and used limits in namespace.") + log.Info("Verifying initial hard and used limits in namespace.") expectedHard := map[string]string{ projectapi.ExistingPodResourceQuotaKey: namespacePodCount, projectapi.ExtendedEphemeralStorageResourceQuotaRequest: "100Mi", @@ -709,7 +895,7 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceMixedQuotaExcee err = namespaceapi.VerifyUsedNamespaceResourceQuota(standardUserClient, perq.cluster.ID, ns1.Name, expectedUsed) require.NoError(perq.T(), err) - log.Info("Create a pod within both pod-count and ephemeral-storage limits.") + log.Info("Creating a pod within both pod-count and ephemeral-storage limits.") requests := map[corev1.ResourceName]string{ corev1.ResourceEphemeralStorage: "50Mi", } @@ -727,12 +913,12 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceMixedQuotaExcee err = namespaceapi.VerifyUsedNamespaceResourceQuota(standardUserClient, perq.cluster.ID, ns1.Name, expectedUsed) require.NoError(perq.T(), err) - log.Info("Attempt to create another pod and verify that it fails due to exceeding pod limits.") + log.Infof("Attempting to create another pod in the namespace %s, exceeding the namespace quota limits.", ns1.Name) _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, ns1.Name, podapi.PauseImage, requests, limits, false) require.Error(perq.T(), err) require.Contains(perq.T(), err.Error(), projectapi.ExceedededResourceQuotaErrorMessage) - log.Info("Verify project level used quota is accurate.") + log.Info("Verifying project level used quota is accurate.") projectExtendedUsed := map[string]string{ projectapi.ExtendedEphemeralStorageResourceQuotaRequest: "100Mi", projectapi.ExtendedEphemeralStorageResourceQuotaLimit: "200Mi", @@ -752,7 +938,7 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceLevelExistingOv standardUserClient, _ := perq.setupUserForProject() - log.Info("Create project with existing and extended pod count resource quotas that conflict.") + log.Info("Creating a project with existing and extended pod count resource quotas that conflict.") projectPodCount := "10" namespacePodCount := "1" @@ -785,11 +971,11 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceLevelExistingOv require.Equal(perq.T(), projectExtendedQuota, createdProject.Spec.ResourceQuota.Limit.Extended) require.Equal(perq.T(), namespaceExtendedQuota, createdProject.Spec.NamespaceDefaultResourceQuota.Limit.Extended) - log.Infof("Verify namespace %s has resource quota annotation.", ns1.Name) + log.Infof("Verifying namespace %s has resource quota annotation.", ns1.Name) err = namespaceapi.VerifyAnnotationInNamespace(standardUserClient, perq.cluster.ID, ns1.Name, projectapi.ResourceQuotaAnnotation, true) require.NoError(perq.T(), err) - log.Info("Verify initial hard and used limits in namespace.") + log.Info("Verifying initial hard and used limits in namespace.") expectedHard := map[string]string{ projectapi.ExistingPodResourceQuotaKey: namespacePodCount, projectapi.ExtendedPodResourceQuotaKey: "3", @@ -808,7 +994,7 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceLevelExistingOv err = namespaceapi.VerifyUsedNamespaceResourceQuota(standardUserClient, perq.cluster.ID, ns1.Name, expectedUsed) require.NoError(perq.T(), err) - log.Info("Create a pod within both pod-count and ephemeral-storage limits.") + log.Info("Creating a pod within both pod-count and ephemeral-storage limits.") requests := map[corev1.ResourceName]string{ corev1.ResourceEphemeralStorage: "50Mi", } @@ -828,16 +1014,16 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceLevelExistingOv err = namespaceapi.VerifyUsedNamespaceResourceQuota(standardUserClient, perq.cluster.ID, ns1.Name, expectedUsed) require.NoError(perq.T(), err) - log.Info("Attempt to create another pod and verify that it fails due to exceeding EXISTING pod limits.") + log.Infof("Attempting to create another pod in the namespace %s, exceeding the namespace quota limits.", ns1.Name) _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, ns1.Name, podapi.PauseImage, requests, limits, false) require.Error(perq.T(), err) require.Contains(perq.T(), err.Error(), projectapi.ExceedededResourceQuotaErrorMessage) - log.Info("Verify used quota remains unchanged after failure.") + log.Info("Verifying used quota remains unchanged after failure.") err = namespaceapi.VerifyUsedNamespaceResourceQuota(standardUserClient, perq.cluster.ID, ns1.Name, expectedUsed) require.NoError(perq.T(), err) - log.Info("Verify project-level used quota is accurate.") + log.Info("Verifying project-level used quota is accurate.") projectExtendedUsed := map[string]string{ projectapi.ExtendedPodResourceQuotaKey: "3", projectapi.ExtendedEphemeralStorageResourceQuotaRequest: "50Mi", @@ -858,7 +1044,7 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestProjectResourceQuotaUsed standardUserClient, _ := perq.setupUserForProject() - log.Info("Create project with existing and extended resource quotas.") + log.Info("Creating a project with existing and extended resource quotas.") projectExistingQuota := &v3.ResourceQuotaLimit{ Pods: "10", } @@ -882,7 +1068,7 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestProjectResourceQuotaUsed createdProject, _, err := projectapi.CreateProjectAndNamespaceWithTemplate(standardUserClient, perq.cluster.ID, projectTemplate) require.NoError(perq.T(), err) - log.Info("Verify initial project UsedLimit after first namespace creation.") + log.Info("Verifying initial project UsedLimit after first namespace creation.") expectedProjectExistingUsed := map[string]string{ projectapi.ExistingPodResourceQuotaKey: "2", } @@ -896,12 +1082,12 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestProjectResourceQuotaUsed err = projectapi.VerifyUsedProjectExtendedResourceQuota(standardUserClient, perq.cluster.ID, createdProject.Name, expectedProjectExtendedUsed) require.NoError(perq.T(), err) - log.Info("Create a second namespace in the same project and verify project used quota increases.") + log.Info("Creating a second namespace in the same project and verifying project used quota increases.") ns2Name := namegen.AppendRandomString("testns-") ns2, err := namespaceapi.CreateNamespace(standardUserClient, perq.cluster.ID, createdProject.Name, ns2Name, "", nil, nil) require.NoError(perq.T(), err) - log.Info("Verify project UsedLimit is updated after namespace creation.") + log.Info("Verifying project UsedLimit is updated after namespace creation.") expectedProjectExistingUsed = map[string]string{ projectapi.ExistingPodResourceQuotaKey: "4", } @@ -915,11 +1101,11 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestProjectResourceQuotaUsed err = projectapi.VerifyUsedProjectExtendedResourceQuota(standardUserClient, perq.cluster.ID, createdProject.Name, expectedProjectExtendedUsed) require.NoError(perq.T(), err) - log.Infof("Delete namespace %s and verify project used quota decreases.", ns2.Name) + log.Infof("Deleting namespace %s and verifying project used quota decreases.", ns2.Name) err = namespaceapi.DeleteNamespace(standardUserClient, perq.cluster.ID, ns2.Name) require.NoError(perq.T(), err) - log.Info("Verify project UsedLimit is updated after namespace deletion.") + log.Info("Verifying project UsedLimit is updated after namespace deletion.") expectedProjectExistingUsed = map[string]string{ projectapi.ExistingPodResourceQuotaKey: "2", } @@ -940,17 +1126,17 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestMoveNamespaceWithoutQuot standardUserClient, _ := perq.setupUserForProject() - log.Info("Create a Project without resource quota.") + log.Info("Creating a Project without resource quota.") projectWithoutQuota, ns, err := projectapi.CreateProjectAndNamespace(standardUserClient, perq.cluster.ID) require.NoError(perq.T(), err) err = projectapi.VerifyProjectHasNoExtendedResourceQuota(standardUserClient, perq.cluster.ID, projectWithoutQuota.Name) require.NoError(perq.T(), err) - log.Info("Verify namespace initially has no resource quota annotation.") + log.Info("Verifying namespace initially has no resource quota annotation.") err = namespaceapi.VerifyAnnotationInNamespace(standardUserClient, perq.cluster.ID, ns.Name, projectapi.ResourceQuotaAnnotation, false) require.NoError(perq.T(), err) - log.Info("Create another project with extended ephemeral storage quota.") + log.Info("Creating another project with extended ephemeral storage quota.") projectExtendedQuota := map[string]string{ projectapi.ExtendedEphemeralStorageResourceQuotaRequest: "100Gi", projectapi.ExtendedEphemeralStorageResourceQuotaLimit: "200Gi", @@ -966,23 +1152,23 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestMoveNamespaceWithoutQuot projectWithQuota, _, err := projectapi.CreateProjectAndNamespaceWithTemplate(standardUserClient, perq.cluster.ID, projectTemplate) require.NoError(perq.T(), err) - log.Infof("Verify used limit for project %s before namespace move.", projectWithQuota.Name) + log.Infof("Verifying used limit for project %s before namespace move.", projectWithQuota.Name) err = projectapi.VerifyUsedProjectExtendedResourceQuota(standardUserClient, perq.cluster.ID, projectWithQuota.Name, namespaceExtendedQuota) require.NoError(perq.T(), err) - log.Infof("Move namespace %s from %s to Project %s.", ns.Name, projectWithoutQuota.Name, projectWithQuota.Name) + log.Infof("Moving namespace %s from %s to Project %s.", ns.Name, projectWithoutQuota.Name, projectWithQuota.Name) err = namespaceapi.MoveNamespaceToProject(standardUserClient, perq.cluster.ID, ns.Name, projectWithQuota.Name) require.NoError(perq.T(), err) - log.Info("Verify resource quota annotation exists in the moved namespace.") + log.Info("Verifying resource quota annotation exists in the moved namespace.") err = namespaceapi.VerifyAnnotationInNamespace(standardUserClient, perq.cluster.ID, ns.Name, projectapi.ResourceQuotaAnnotation, true) require.NoError(perq.T(), err) - log.Info("Verify ResourceQuota hard limits in the moved namespace.") + log.Info("Verifying ResourceQuota hard limits in the moved namespace.") err = namespaceapi.VerifyNamespaceResourceQuota(standardUserClient, perq.cluster.ID, ns.Name, namespaceExtendedQuota) require.NoError(perq.T(), err) - log.Info("Verify initial used values for the resources in the moved namespace.") + log.Info("Verifying initial used values for the resources in the moved namespace.") expectedUsed := map[string]string{ projectapi.ExtendedEphemeralStorageResourceQuotaRequest: namespaceapi.InitialUsedResourceQuotaValue, projectapi.ExtendedEphemeralStorageResourceQuotaLimit: namespaceapi.InitialUsedResourceQuotaValue, @@ -990,7 +1176,7 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestMoveNamespaceWithoutQuot err = namespaceapi.VerifyUsedNamespaceResourceQuota(standardUserClient, perq.cluster.ID, ns.Name, expectedUsed) require.NoError(perq.T(), err) - log.Info("Create a pod within extended quota limits.") + log.Info("Creating a pod within extended quota limits.") requests := map[corev1.ResourceName]string{ corev1.ResourceEphemeralStorage: "10Gi", } @@ -1001,20 +1187,20 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestMoveNamespaceWithoutQuot _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, ns.Name, podapi.PauseImage, requests, limits, true) require.NoError(perq.T(), err) - log.Info("Verify ResourceQuota used limit in the namespace is updated.") + log.Info("Verifying ResourceQuota used limit in the namespace is updated.") err = namespaceapi.VerifyUsedNamespaceResourceQuota(standardUserClient, perq.cluster.ID, ns.Name, namespaceExtendedQuota) require.NoError(perq.T(), err) - log.Info("Attempt to create pod exceeding extended quota limits.") + log.Infof("Attempting to create pod in the namepspace %s, exceeding extended quota limits.", ns.Name) _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, ns.Name, podapi.PauseImage, requests, limits, false) require.Error(perq.T(), err) require.Contains(perq.T(), err.Error(), projectapi.ExceedededResourceQuotaErrorMessage) - log.Info("Verify ResourceQuota used remains unchanged after failure.") + log.Info("Verifying ResourceQuota used remains unchanged after failure.") err = namespaceapi.VerifyUsedNamespaceResourceQuota(standardUserClient, perq.cluster.ID, ns.Name, namespaceExtendedQuota) require.NoError(perq.T(), err) - log.Infof("Verify used limit for project %s is updated after namespace move.", projectWithQuota.Name) + log.Infof("Verifying used limit for project %s is updated after namespace move.", projectWithQuota.Name) expectedProjectUsed := map[string]string{ projectapi.ExtendedEphemeralStorageResourceQuotaRequest: "20Gi", projectapi.ExtendedEphemeralStorageResourceQuotaLimit: "40Gi", @@ -1029,7 +1215,7 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestMoveNamespaceWithExtende standardUserClient, _ := perq.setupUserForProject() - log.Info("Create a project with extended ephemeral storage quota.") + log.Info("Creating a project with extended ephemeral storage quota.") projectExtendedQuota := map[string]string{ projectapi.ExtendedEphemeralStorageResourceQuotaRequest: "100Gi", projectapi.ExtendedEphemeralStorageResourceQuotaLimit: "200Gi", @@ -1047,11 +1233,11 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestMoveNamespaceWithExtende err = projectapi.VerifyUsedProjectExtendedResourceQuota(standardUserClient, perq.cluster.ID, projectWithQuota.Name, namespaceExtendedQuota) require.NoError(perq.T(), err) - log.Info("Verify namespace has the resource quota annotation.") + log.Info("Verifying namespace has the resource quota annotation.") err = namespaceapi.VerifyAnnotationInNamespace(standardUserClient, perq.cluster.ID, ns.Name, projectapi.ResourceQuotaAnnotation, true) require.NoError(perq.T(), err) - log.Info("Create a pod within extended quota limits.") + log.Info("Creating a pod within extended quota limits.") requests := map[corev1.ResourceName]string{ corev1.ResourceEphemeralStorage: "10Gi", } @@ -1062,36 +1248,36 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestMoveNamespaceWithExtende _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, ns.Name, podapi.PauseImage, requests, limits, true) require.NoError(perq.T(), err) - log.Info("Verify resource quota used limit is updated in the namespace.") + log.Info("Verifying resource quota used limit is updated in the namespace.") err = namespaceapi.VerifyUsedNamespaceResourceQuota(standardUserClient, perq.cluster.ID, ns.Name, namespaceExtendedQuota) require.NoError(perq.T(), err) - log.Info("Verify that creating a pod exceeding extended quota limits fails.") + log.Info("Verifying that creating a pod exceeding extended quota limits fails.") _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, ns.Name, podapi.PauseImage, requests, limits, false) require.Error(perq.T(), err) require.Contains(perq.T(), err.Error(), projectapi.ExceedededResourceQuotaErrorMessage) - log.Info("Create a second project without any resource quota.") + log.Info("Creating a second project without any resource quota.") projectWithoutQuota, _, err := projectapi.CreateProjectAndNamespace(standardUserClient, perq.cluster.ID) require.NoError(perq.T(), err) err = projectapi.VerifyProjectHasNoExtendedResourceQuota(standardUserClient, perq.cluster.ID, projectWithoutQuota.Name) require.NoError(perq.T(), err) - log.Infof("Move namespace %s from project %s to project %s.", ns.Name, projectWithQuota.Name, projectWithoutQuota.Name) + log.Infof("Moving namespace %s from project %s to project %s.", ns.Name, projectWithQuota.Name, projectWithoutQuota.Name) err = namespaceapi.MoveNamespaceToProject(standardUserClient, perq.cluster.ID, ns.Name, projectWithoutQuota.Name) require.NoError(perq.T(), err) - log.Info("Verify resource quota is removed from the moved namespace.") + log.Info("Verifying resource quota is removed from the moved namespace.") err = namespaceapi.VerifyAnnotationInNamespace(standardUserClient, perq.cluster.ID, ns.Name, projectapi.ResourceQuotaAnnotation, false) require.NoError(perq.T(), err) err = namespaceapi.VerifyNamespaceHasNoResourceQuota(standardUserClient, perq.cluster.ID, ns.Name) require.NoError(perq.T(), err) - log.Info("Verify pod creation is no longer quota restricted.") + log.Info("Verifying pod creation is no longer quota restricted.") _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, ns.Name, podapi.PauseImage, requests, limits, true) require.NoError(perq.T(), err) - log.Infof("Verify used limit for project %s is updated after namespace move.", projectWithQuota.Name) + log.Infof("Verifying used limit for project %s is updated after namespace move.", projectWithQuota.Name) expectedProjectUsed := map[string]string{ projectapi.ExtendedEphemeralStorageResourceQuotaRequest: namespaceapi.InitialUsedResourceQuotaValue, projectapi.ExtendedEphemeralStorageResourceQuotaLimit: namespaceapi.InitialUsedResourceQuotaValue, @@ -1106,7 +1292,7 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceOverrideExtende standardUserClient, _ := perq.setupUserForProject() - log.Info("Create project with extended ephemeral-storage quota.") + log.Info("Creating a project with extended ephemeral-storage quota.") projectExtendedQuota := map[string]string{ projectapi.ExtendedEphemeralStorageResourceQuotaRequest: "100Gi", projectapi.ExtendedEphemeralStorageResourceQuotaLimit: "200Gi", @@ -1124,7 +1310,7 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceOverrideExtende err = namespaceapi.VerifyNamespaceResourceQuota(standardUserClient, perq.cluster.ID, ns.Name, namespaceExtendedQuota) require.NoError(perq.T(), err) - log.Info("Override namespace ResourceQuota within project limits.") + log.Info("Overriding namespace ResourceQuota within project limits.") validNamespaceOverrideQuota := map[string]string{ projectapi.ExtendedEphemeralStorageResourceQuotaRequest: "50Gi", projectapi.ExtendedEphemeralStorageResourceQuotaLimit: "100Gi", @@ -1133,11 +1319,11 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceOverrideExtende err = namespaceapi.UpdateNamespaceResourceQuotaAnnotation(standardUserClient, perq.cluster.ID, ns.Name, nil, validNamespaceOverrideQuota) require.NoError(perq.T(), err) - log.Info("Verify namespace ResourceQuota reflects overridden values.") + log.Info("Verifying namespace ResourceQuota reflects overridden values.") err = namespaceapi.VerifyNamespaceResourceQuota(standardUserClient, perq.cluster.ID, ns.Name, validNamespaceOverrideQuota) require.NoError(perq.T(), err) - log.Info("Create pod within overridden namespace quota.") + log.Info("Creating a pod within the overridden namespace quota.") requests := map[corev1.ResourceName]string{ corev1.ResourceEphemeralStorage: "40Gi", } @@ -1147,7 +1333,7 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceOverrideExtende _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, ns.Name, podapi.PauseImage, requests, limits, true) require.NoError(perq.T(), err) - log.Info("Verify ResourceQuota used values are updated correctly in the namespace.") + log.Info("Verifying ResourceQuota used values are updated correctly in the namespace.") expectedUsed := map[string]string{ projectapi.ExtendedEphemeralStorageResourceQuotaRequest: "40Gi", projectapi.ExtendedEphemeralStorageResourceQuotaLimit: "80Gi", @@ -1155,12 +1341,12 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceOverrideExtende err = namespaceapi.VerifyUsedNamespaceResourceQuota(standardUserClient, perq.cluster.ID, ns.Name, expectedUsed) require.NoError(perq.T(), err) - log.Info("Attempt to create a pod exceeding namespace quota.") + log.Infof("Attempting to create a pod in the namespace %s, exceeding namespace quota.", ns.Name) _, err = podapi.CreatePodWithResources(standardUserClient, perq.cluster.ID, ns.Name, podapi.PauseImage, requests, limits, false) require.Error(perq.T(), err) require.Contains(perq.T(), err.Error(), projectapi.ExceedededResourceQuotaErrorMessage) - log.Info("Attempt to override namespace quota beyond project limits.") + log.Info("Attempting to override namespace quota beyond project limits.") invalidNamespaceQuota := map[string]string{ projectapi.ExtendedEphemeralStorageResourceQuotaRequest: "150Gi", projectapi.ExtendedEphemeralStorageResourceQuotaLimit: "300Gi", @@ -1168,11 +1354,11 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestNamespaceOverrideExtende err = namespaceapi.UpdateNamespaceResourceQuotaAnnotation(standardUserClient, perq.cluster.ID, ns.Name, nil, invalidNamespaceQuota) require.NoError(perq.T(), err) - log.Info("Verify resource quota validation status in the namespace reflects exceeded project limits.") + log.Info("Verifying resource quota validation status in the namespace reflects exceeded project limits.") err = namespaceapi.VerifyNamespaceResourceQuotaValidationStatus(standardUserClient, perq.cluster.ID, ns.Name, nil, invalidNamespaceQuota, false, "exceeds project limit") require.NoError(perq.T(), err) - log.Info("Verify namespace ResourceQuota remains unchanged after failed override.") + log.Info("Verifying namespace ResourceQuota remains unchanged after failed override.") err = namespaceapi.VerifyNamespaceResourceQuota(standardUserClient, perq.cluster.ID, ns.Name, validNamespaceOverrideQuota) require.NoError(perq.T(), err) } @@ -1183,7 +1369,7 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestProjectExtendedQuotaLess standardUserClient, _ := perq.setupUserForProject() - log.Info("Create a project where project extended ephemeral-storage quota < namespace extended ephemeral-storage quota.") + log.Info("Attempting to create a project where project extended ephemeral-storage quota < namespace extended ephemeral-storage quota.") projectExtendedQuota := map[string]string{ projectapi.ExtendedEphemeralStorageResourceQuotaKey: "10Mi", } @@ -1232,7 +1418,7 @@ func (perq *ProjectsExtendedResourceQuotaTestSuite) TestProjectExistingQuotaLess standardUserClient, _ := perq.setupUserForProject() - log.Info("Create a project where project existing pod quota < namespace existing pod quota.") + log.Info("Attempting to create a project where project existing pod quota < namespace existing pod quota.") projectExistingQuota := &v3.ResourceQuotaLimit{ Pods: "1", }