From 46f8148f5b90bf6e77a857e207f449e1e21173c0 Mon Sep 17 00:00:00 2001 From: Eugene Fedorenko Date: Thu, 21 Nov 2024 09:56:45 -0800 Subject: [PATCH 01/10] filter deploymenttargets by environment --- controllers/schedulingpolicy_controller.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/schedulingpolicy_controller.go b/controllers/schedulingpolicy_controller.go index 7c5c9a5..4736bd4 100644 --- a/controllers/schedulingpolicy_controller.go +++ b/controllers/schedulingpolicy_controller.go @@ -100,9 +100,9 @@ func (r *SchedulingPolicyReconciler) Reconcile(ctx context.Context, req ctrl.Req return r.manageFailure(ctx, reqLogger, schedulingPolicy, err, "Failed to list ClusterTypes") } - // fetch the list if deployment targets in the namespace + // fetch the list if deployment targets in the namespace with environment field equal to the namespace name deploymentTargets := &schedulerv1alpha1.DeploymentTargetList{} - err = r.List(ctx, deploymentTargets, client.InNamespace(req.Namespace)) + err = r.List(ctx, deploymentTargets, client.InNamespace(req.Namespace), client.MatchingFields{"environment": req.Namespace}) if err != nil { return r.manageFailure(ctx, reqLogger, schedulingPolicy, err, "Failed to list DeploymentTargets") } From 92db9be1dd83784f020db9a1e9a21d97b9154b42 Mon Sep 17 00:00:00 2001 From: Eugene Fedorenko Date: Thu, 21 Nov 2024 10:35:04 -0800 Subject: [PATCH 02/10] ci --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 03baed8..38eb823 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -38,7 +38,7 @@ jobs: tags: ghcr.io/microsoft/kalypso-scheduler:${{ env.IMAGE_TAG }}, ghcr.io/microsoft/kalypso-scheduler:latest - name: Upload Image Tags - uses: actions/upload-artifact@v2.2.2 + uses: actions/upload-artifact with: name: image_tag_paris path: ${{ github.workspace }}/IMAGE_TAG From bf89614c3a484909abfe2973ccfa05f77c4bdfa4 Mon Sep 17 00:00:00 2001 From: Eugene Fedorenko Date: Thu, 21 Nov 2024 10:35:47 -0800 Subject: [PATCH 03/10] version --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 38eb823..79c68aa 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -38,7 +38,7 @@ jobs: tags: ghcr.io/microsoft/kalypso-scheduler:${{ env.IMAGE_TAG }}, ghcr.io/microsoft/kalypso-scheduler:latest - name: Upload Image Tags - uses: actions/upload-artifact + uses: actions/upload-artifact@v4.4.3 with: name: image_tag_paris path: ${{ github.workspace }}/IMAGE_TAG From cbb39988e390fffb8dbc82c975c0a690b75b871f Mon Sep 17 00:00:00 2001 From: Eugene Fedorenko Date: Tue, 3 Dec 2024 12:34:10 -0800 Subject: [PATCH 04/10] no build --- .github/workflows/ci.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 79c68aa..26f0ff3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -27,7 +27,6 @@ jobs: IMAGE_TAG=${{ vars.MAJOR_VERSION }}.${{ vars.MINOR_VERSION }}.${{ vars.HF_VERSION }}-${{ github.run_number }} echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV echo $IMAGE_TAG > $GITHUB_WORKSPACE/IMAGE_TAG - make build - name: Build and Push to GHCR uses: docker/build-push-action@v2 From 66560e4e5f563d0150b4700161ac8e2f81e35ad1 Mon Sep 17 00:00:00 2001 From: Eugene Fedorenko Date: Tue, 3 Dec 2024 12:43:12 -0800 Subject: [PATCH 05/10] go --- .github/workflows/ci.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 26f0ff3..1b3ce66 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -51,6 +51,11 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 + + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: '1.20' - name: Install Helmify run: | From 4b7f112d544a2f08201b024a04b97b95a9e77729 Mon Sep 17 00:00:00 2001 From: Eugene Fedorenko Date: Tue, 10 Dec 2024 12:26:58 -0800 Subject: [PATCH 06/10] index on environment --- controllers/workload_controller.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/controllers/workload_controller.go b/controllers/workload_controller.go index ec63bce..0f6b111 100644 --- a/controllers/workload_controller.go +++ b/controllers/workload_controller.go @@ -40,6 +40,10 @@ type WorkloadReconciler struct { Scheme *runtime.Scheme } +const ( + EnvironmentField = "spec.environment" +) + // +kubebuilder:rbac:groups=scheduler.kalypso.io,resources=workloads,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=scheduler.kalypso.io,resources=workloads/status,verbs=get;update;patch // +kubebuilder:rbac:groups=scheduler.kalypso.io,resources=workloads/finalizers,verbs=update @@ -236,6 +240,19 @@ func (h *WorkloadReconciler) manageFailure(ctx context.Context, logger logr.Logg // SetupWithManager sets up the controller with the Manager. func (r *WorkloadReconciler) SetupWithManager(mgr ctrl.Manager) error { + // Add the field index for the environmrnt in the deployment target + if err := mgr.GetFieldIndexer().IndexField(context.Background(), &schedulerv1alpha1.DeploymentTarget{}, EnvironmentField, func(rawObj client.Object) []string { + return []string{rawObj.(*schedulerv1alpha1.DeploymentTarget).Spec.Environment} + }); err != nil { + return err + } + + // if err := mgr.GetFieldIndexer().IndexField(context.Background(), &schedulerv1alpha1.Assignment{}, DeploymentTargetField, func(rawObj client.Object) []string { + // return []string{rawObj.(*schedulerv1alpha1.Assignment).Spec.DeploymentTarget} + // }); err != nil { + // return err + // } + return ctrl.NewControllerManagedBy(mgr). For(&schedulerv1alpha1.Workload{}). Owns(&schedulerv1alpha1.DeploymentTarget{}). From 65c6eb5da4b141ed8612e8ae0ed94955e03f3f8b Mon Sep 17 00:00:00 2001 From: Eugene Fedorenko Date: Tue, 10 Dec 2024 12:44:40 -0800 Subject: [PATCH 07/10] update --- controllers/schedulingpolicy_controller.go | 8 ++++++++ controllers/workload_controller.go | 16 ---------------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/controllers/schedulingpolicy_controller.go b/controllers/schedulingpolicy_controller.go index 4736bd4..c7f028c 100644 --- a/controllers/schedulingpolicy_controller.go +++ b/controllers/schedulingpolicy_controller.go @@ -48,6 +48,7 @@ const ( ReconcilerField = "spec.reconciler" NamespaceServiceField = "spec.namespaceService" DeploymentTargetField = "spec.deploymentTarget" + EnvironmentField = "spec.environment" ) // +kubebuilder:rbac:groups=scheduler.kalypso.io,resources=schedulingpolicies,verbs=get;list;watch;create;update;patch;delete @@ -267,6 +268,13 @@ func (r *SchedulingPolicyReconciler) SetupWithManager(mgr ctrl.Manager) error { return err } + // Add the field index for the environmrnt in the deployment target + if err := mgr.GetFieldIndexer().IndexField(context.Background(), &schedulerv1alpha1.DeploymentTarget{}, EnvironmentField, func(rawObj client.Object) []string { + return []string{rawObj.(*schedulerv1alpha1.DeploymentTarget).Spec.Environment} + }); err != nil { + return err + } + return ctrl.NewControllerManagedBy(mgr). For(&schedulerv1alpha1.SchedulingPolicy{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})). Owns(&schedulerv1alpha1.Assignment{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})). diff --git a/controllers/workload_controller.go b/controllers/workload_controller.go index 0f6b111..b8c7abb 100644 --- a/controllers/workload_controller.go +++ b/controllers/workload_controller.go @@ -40,10 +40,6 @@ type WorkloadReconciler struct { Scheme *runtime.Scheme } -const ( - EnvironmentField = "spec.environment" -) - // +kubebuilder:rbac:groups=scheduler.kalypso.io,resources=workloads,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=scheduler.kalypso.io,resources=workloads/status,verbs=get;update;patch // +kubebuilder:rbac:groups=scheduler.kalypso.io,resources=workloads/finalizers,verbs=update @@ -240,18 +236,6 @@ func (h *WorkloadReconciler) manageFailure(ctx context.Context, logger logr.Logg // SetupWithManager sets up the controller with the Manager. func (r *WorkloadReconciler) SetupWithManager(mgr ctrl.Manager) error { - // Add the field index for the environmrnt in the deployment target - if err := mgr.GetFieldIndexer().IndexField(context.Background(), &schedulerv1alpha1.DeploymentTarget{}, EnvironmentField, func(rawObj client.Object) []string { - return []string{rawObj.(*schedulerv1alpha1.DeploymentTarget).Spec.Environment} - }); err != nil { - return err - } - - // if err := mgr.GetFieldIndexer().IndexField(context.Background(), &schedulerv1alpha1.Assignment{}, DeploymentTargetField, func(rawObj client.Object) []string { - // return []string{rawObj.(*schedulerv1alpha1.Assignment).Spec.DeploymentTarget} - // }); err != nil { - // return err - // } return ctrl.NewControllerManagedBy(mgr). For(&schedulerv1alpha1.Workload{}). From bd850291d4f8579388bbc5b6aa5f8ce4e0803eef Mon Sep 17 00:00:00 2001 From: Eugene Fedorenko Date: Tue, 10 Dec 2024 12:54:44 -0800 Subject: [PATCH 08/10] fix --- controllers/schedulingpolicy_controller.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/schedulingpolicy_controller.go b/controllers/schedulingpolicy_controller.go index c7f028c..9a26eca 100644 --- a/controllers/schedulingpolicy_controller.go +++ b/controllers/schedulingpolicy_controller.go @@ -103,7 +103,7 @@ func (r *SchedulingPolicyReconciler) Reconcile(ctx context.Context, req ctrl.Req // fetch the list if deployment targets in the namespace with environment field equal to the namespace name deploymentTargets := &schedulerv1alpha1.DeploymentTargetList{} - err = r.List(ctx, deploymentTargets, client.InNamespace(req.Namespace), client.MatchingFields{"environment": req.Namespace}) + err = r.List(ctx, deploymentTargets, client.InNamespace(req.Namespace), client.MatchingFields{EnvironmentField: req.Namespace}) if err != nil { return r.manageFailure(ctx, reqLogger, schedulingPolicy, err, "Failed to list DeploymentTargets") } From 1052c156e7f9f223e83754764c0c6026c41ad121 Mon Sep 17 00:00:00 2001 From: Eugene Fedorenko Date: Mon, 16 Dec 2024 11:38:01 -0800 Subject: [PATCH 09/10] Update controllers/schedulingpolicy_controller.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- controllers/schedulingpolicy_controller.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/schedulingpolicy_controller.go b/controllers/schedulingpolicy_controller.go index 9a26eca..b5a48eb 100644 --- a/controllers/schedulingpolicy_controller.go +++ b/controllers/schedulingpolicy_controller.go @@ -268,7 +268,7 @@ func (r *SchedulingPolicyReconciler) SetupWithManager(mgr ctrl.Manager) error { return err } - // Add the field index for the environmrnt in the deployment target + // Add the field index for the environment in the deployment target if err := mgr.GetFieldIndexer().IndexField(context.Background(), &schedulerv1alpha1.DeploymentTarget{}, EnvironmentField, func(rawObj client.Object) []string { return []string{rawObj.(*schedulerv1alpha1.DeploymentTarget).Spec.Environment} }); err != nil { From 3960fa143e74e70c6f0bb2465f36d9482f954173 Mon Sep 17 00:00:00 2001 From: Eugene Fedorenko Date: Mon, 16 Dec 2024 11:39:37 -0800 Subject: [PATCH 10/10] Update controllers/schedulingpolicy_controller.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- controllers/schedulingpolicy_controller.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/schedulingpolicy_controller.go b/controllers/schedulingpolicy_controller.go index b5a48eb..d45f187 100644 --- a/controllers/schedulingpolicy_controller.go +++ b/controllers/schedulingpolicy_controller.go @@ -101,7 +101,7 @@ func (r *SchedulingPolicyReconciler) Reconcile(ctx context.Context, req ctrl.Req return r.manageFailure(ctx, reqLogger, schedulingPolicy, err, "Failed to list ClusterTypes") } - // fetch the list if deployment targets in the namespace with environment field equal to the namespace name + // fetch the list of deployment targets in the namespace with environment field equal to the namespace name deploymentTargets := &schedulerv1alpha1.DeploymentTargetList{} err = r.List(ctx, deploymentTargets, client.InNamespace(req.Namespace), client.MatchingFields{EnvironmentField: req.Namespace}) if err != nil {