Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add a label to identify the promoted/deployed pipeline for a pipelineRollout #273

Merged
merged 3 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions internal/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
)

// UpgradeState is the enum to track the possible state of
// a resource upgrade, it can only be `promoted` or `in-progress`.
type UpgradeState string

const (
// SSAManager is the default numaplane manager name used by server-side apply syncs
SSAManager = "numaplane-controller"
Expand Down Expand Up @@ -43,6 +47,18 @@ const (
// LabelKeyPipelineRolloutForPipeline is the label key used to identify the PipelineRollout a Pipeline is managed by
// This is useful as a Label to quickly locate all Pipelines of a given PipelineRollout
LabelKeyPipelineRolloutForPipeline = "numaplane.numaproj.io/pipeline-rollout-name"

// LabelKeyUpgradeState is the label key used to identify the upgrade state of a resource that is managed by
// a NumaRollout.
LabelKeyUpgradeState = "numaplane.numaproj.io/upgrade-state"

// LabelValueUpgradePromoted is the label value indicating that the resource managed by a NumaRollout is promoted
// after an upgrade.
LabelValueUpgradePromoted UpgradeState = "promoted"

// LabelValueUpgradeInProgress is the label value indicating that the resource managed by a NumaRollout is in progress
// of upgrade.
LabelValueUpgradeInProgress UpgradeState = "in-progress"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/pipelinerollout_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import (

numaflowv1 "github.com/numaproj/numaflow/pkg/apis/numaflow/v1alpha1"
"github.com/numaproj/numaplane/internal/common"

"github.com/numaproj/numaplane/internal/util"
"github.com/numaproj/numaplane/internal/util/kubernetes"
"github.com/numaproj/numaplane/internal/util/logger"
Expand Down Expand Up @@ -866,6 +865,7 @@ func pipelineLabels(pipelineRollout *apiv1.PipelineRollout) (map[string]string,
}

labelMapping[common.LabelKeyPipelineRolloutForPipeline] = pipelineRollout.Name
labelMapping[common.LabelKeyUpgradeState] = string(common.LabelValueUpgradePromoted)

return labelMapping, nil
}
Expand Down
13 changes: 8 additions & 5 deletions internal/controller/pipelinerollout_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,21 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/numaproj/numaplane/internal/common"
"strings"
"time"

"testing"

"github.com/stretchr/testify/assert"
"time"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/prometheus/client_golang/prometheus/testutil"
"github.com/stretchr/testify/assert"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"

numaflowv1 "github.com/numaproj/numaflow/pkg/apis/numaflow/v1alpha1"
"github.com/numaproj/numaplane/internal/common"
"github.com/numaproj/numaplane/internal/util/kubernetes"
apiv1 "github.com/numaproj/numaplane/pkg/apis/numaplane/v1alpha1"
)
Expand Down Expand Up @@ -143,6 +141,7 @@ var _ = Describe("PipelineRollout Controller", Ordered, func() {

By("Verifying the label of the pipeline")
Expect(createdResource.Labels[common.LabelKeyPipelineRolloutForPipeline]).Should(Equal(pipelineRollout.Name))
Expect(createdResource.Labels[common.LabelKeyUpgradeState]).Should(Equal(string(common.LabelValueUpgradePromoted)))
})

It("Should have the PipelineRollout Status Phase has Deployed and ObservedGeneration matching Generation", func() {
Expand Down Expand Up @@ -687,6 +686,10 @@ func TestPipelineLabels(t *testing.T) {
if labels[common.LabelKeyPipelineRolloutForPipeline] != pipelineRolloutName {
t.Errorf("pipelineLabels() = %v, expected %v", common.LabelKeyPipelineRolloutForPipeline, pipelineRolloutName)
}

if labels[common.LabelKeyUpgradeState] != string(common.LabelValueUpgradePromoted) {
t.Errorf("pipelineLabels() = %v, expected %v", common.LabelKeyUpgradeState, string(common.LabelValueUpgradePromoted))
}
}
})
}
Expand Down
Loading