diff --git a/.vscode/launch.json b/.vscode/launch.json index 106183e1c..1ce4d21b3 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,7 +10,7 @@ "env": {}, "args": [ "--RADIX_APP=radix-job-demo", - "--JOB_NAME=radix-pipeline-20231030143058-mtwyg", + "--JOB_NAME=radix-pipeline-20231113133209-sb8w8", "--PIPELINE_TYPE=build-deploy", "--RADIX_TEKTON_IMAGE=radix-tekton:main-latest", "--RADIX_IMAGE_BUILDER=radix-image-builder:master-latest", @@ -23,7 +23,7 @@ "--AZURE_SUBSCRIPTION_ID=16ede44b-1f74-40a5-b428-46cca9a5741b", "--IMAGE_TAG=abcde", "--BRANCH=main", - "--COMMIT_ID=890e19c7bea84678d684daa2a9363cd8be4940bb", + "--COMMIT_ID=1cbb2fb6b8a562d44a27edae9678c86cb7cbda2e", "--PUSH_IMAGE=true", "--USE_CACHE=true", "--RADIX_FILE_NAME=/workspace/radixconfig.yaml", diff --git a/charts/radix-operator/Chart.yaml b/charts/radix-operator/Chart.yaml index bc815cbb5..4365073db 100644 --- a/charts/radix-operator/Chart.yaml +++ b/charts/radix-operator/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v2 name: radix-operator -version: 1.25.1 -appVersion: 1.45.1 +version: 1.25.2 +appVersion: 1.45.2 kubeVersion: ">=1.24.0" description: Radix Operator keywords: diff --git a/pipeline-runner/model/pipelineInfo.go b/pipeline-runner/model/pipelineInfo.go index fa41b381c..1bc4460d6 100644 --- a/pipeline-runner/model/pipelineInfo.go +++ b/pipeline-runner/model/pipelineInfo.go @@ -180,7 +180,7 @@ func (info *PipelineInfo) SetApplicationConfig(applicationConfig *application.Ap info.RadixApplication = applicationConfig.GetRadixApplicationConfig() // Obtain metadata for rest of pipeline - targetEnvironments := applicationConfig.GetTargetEnvironments(info.PipelineArguments.Branch) + targetEnvironments := application.GetTargetEnvironments(info.PipelineArguments.Branch, info.RadixApplication) // For deploy-only pipeline if info.IsPipelineType(radixv1.Deploy) && diff --git a/pipeline-runner/steps/apply_radixconfig.go b/pipeline-runner/steps/apply_radixconfig.go index 1d3e0d68a..b577792e4 100644 --- a/pipeline-runner/steps/apply_radixconfig.go +++ b/pipeline-runner/steps/apply_radixconfig.go @@ -360,7 +360,7 @@ func isRadixConfigNewOrModifiedSinceDeployment(rd *radixv1.RadixDeployment, ra * return true, nil } hashEqual, err := compareRadixApplicationHash(currentRdConfigHash, ra) - if !hashEqual && err != nil { + if !hashEqual && err == nil { log.Infof("RadixApplication updated since last deployment to environment %s", rd.Spec.Environment) } return !hashEqual, err @@ -375,7 +375,7 @@ func isBuildSecretNewOrModifiedSinceDeployment(rd *radixv1.RadixDeployment, buil return true, nil } hashEqual, err := compareBuildSecretHash(targetHash, buildSecret) - if !hashEqual && err != nil { + if !hashEqual && err == nil { log.Infof("Build secrets updated since last deployment to environment %s", rd.Spec.Environment) } return !hashEqual, err diff --git a/pipeline-runner/steps/build_test.go b/pipeline-runner/steps/build_test.go index 9334ce61c..4e85821ab 100644 --- a/pipeline-runner/steps/build_test.go +++ b/pipeline-runner/steps/build_test.go @@ -85,8 +85,7 @@ func (s *buildTestSuite) Test_BranchIsNotMapped_ShouldSkip() { cli := steps.NewBuildStep(jobWaiter) cli.Init(s.kubeClient, s.radixClient, s.kubeUtil, s.promClient, rr) - applicationConfig := application.NewApplicationConfig(s.kubeClient, s.kubeUtil, s.radixClient, rr, ra) - targetEnvs := applicationConfig.GetTargetEnvironments(anyNoMappedBranch) + targetEnvs := application.GetTargetEnvironments(anyNoMappedBranch, ra) pipelineInfo := &model.PipelineInfo{ PipelineArguments: model.PipelineArguments{ diff --git a/pipeline-runner/steps/deploy_test.go b/pipeline-runner/steps/deploy_test.go index 40ad8193e..514fb6055 100644 --- a/pipeline-runner/steps/deploy_test.go +++ b/pipeline-runner/steps/deploy_test.go @@ -75,8 +75,7 @@ func TestDeploy_BranchIsNotMapped_ShouldSkip(t *testing.T) { cli := steps.NewDeployStep(FakeNamespaceWatcher{}) cli.Init(kubeclient, radixclient, kubeUtil, &monitoring.Clientset{}, rr) - applicationConfig := application.NewApplicationConfig(kubeclient, kubeUtil, radixclient, rr, ra) - targetEnvs := applicationConfig.GetTargetEnvironments(anyNoMappedBranch) + targetEnvs := application.GetTargetEnvironments(anyNoMappedBranch, ra) pipelineInfo := &model.PipelineInfo{ PipelineArguments: model.PipelineArguments{ @@ -181,7 +180,7 @@ func TestDeploy_PromotionSetup_ShouldCreateNamespacesForAllBranchesIfNotExists(t cli.Init(kubeclient, radixclient, kubeUtil, &monitoring.Clientset{}, rr) applicationConfig := application.NewApplicationConfig(kubeclient, kubeUtil, radixclient, rr, ra) - targetEnvs := applicationConfig.GetTargetEnvironments("master") + targetEnvs := application.GetTargetEnvironments("master", ra) pipelineInfo := &model.PipelineInfo{ PipelineArguments: model.PipelineArguments{ diff --git a/pkg/apis/applicationconfig/applicationconfig.go b/pkg/apis/applicationconfig/applicationconfig.go index 4404b42fa..89ecc3e21 100644 --- a/pkg/apis/applicationconfig/applicationconfig.go +++ b/pkg/apis/applicationconfig/applicationconfig.go @@ -106,9 +106,9 @@ func IsConfigBranch(branch string, rr *v1.RadixRegistration) bool { } // GetTargetEnvironments Checks if given branch requires deployment to environments -func (app *ApplicationConfig) GetTargetEnvironments(branchToBuild string) []string { +func GetTargetEnvironments(branchToBuild string, ra *v1.RadixApplication) []string { var targetEnvs []string - for _, env := range app.config.Spec.Environments { + for _, env := range ra.Spec.Environments { if env.Build.From != "" && branch.MatchesPattern(env.Build.From, branchToBuild) { targetEnvs = append(targetEnvs, env.Name) } diff --git a/pkg/apis/applicationconfig/applicationconfig_test.go b/pkg/apis/applicationconfig/applicationconfig_test.go index 2e0966703..5f01d2f3d 100644 --- a/pkg/apis/applicationconfig/applicationconfig_test.go +++ b/pkg/apis/applicationconfig/applicationconfig_test.go @@ -43,12 +43,6 @@ func setupTest() (*test.Utils, kubernetes.Interface, *kube.Kube, radixclient.Int return &handlerTestUtils, kubeclient, kubeUtil, radixclient } -func getApplication(ra *radixv1.RadixApplication) *ApplicationConfig { - // The other arguments are not relevant for this test - application := NewApplicationConfig(nil, nil, nil, nil, ra) - return application -} - func Test_Create_Radix_Environments(t *testing.T) { _, client, kubeUtil, radixclient := setupTest() @@ -136,8 +130,7 @@ func TestIsThereAnythingToDeploy_multipleEnvsToOneBranch_ListsBoth(t *testing.T) WithEnvironment("prod", "master"). BuildRA() - application := getApplication(ra) - targetEnvs := application.GetTargetEnvironments(branch) + targetEnvs := GetTargetEnvironments(branch, ra) assert.ElementsMatch(t, []string{"prod", "qa"}, targetEnvs) } @@ -149,8 +142,7 @@ func TestIsThereAnythingToDeploy_multipleEnvsToOneBranchOtherBranchIsChanged_Lis WithEnvironment("prod", "master"). BuildRA() - application := getApplication(ra) - targetEnvs := application.GetTargetEnvironments(branch) + targetEnvs := GetTargetEnvironments(branch, ra) assert.Equal(t, 0, len(targetEnvs)) } @@ -162,8 +154,7 @@ func TestIsThereAnythingToDeploy_oneEnvToOneBranch_ListsBothButOnlyOneShouldBeBu WithEnvironment("prod", "master"). BuildRA() - application := getApplication(ra) - targetEnvs := application.GetTargetEnvironments(branch) + targetEnvs := GetTargetEnvironments(branch, ra) assert.ElementsMatch(t, []string{"qa"}, targetEnvs) } @@ -175,8 +166,7 @@ func TestIsThereAnythingToDeploy_twoEnvNoBranch(t *testing.T) { WithEnvironmentNoBranch("prod"). BuildRA() - application := getApplication(ra) - targetEnvs := application.GetTargetEnvironments(branch) + targetEnvs := GetTargetEnvironments(branch, ra) assert.Equal(t, 0, len(targetEnvs)) } @@ -186,8 +176,7 @@ func TestIsThereAnythingToDeploy_NoEnv(t *testing.T) { ra := utils.NewRadixApplicationBuilder(). BuildRA() - application := getApplication(ra) - targetEnvs := application.GetTargetEnvironments(branch) + targetEnvs := GetTargetEnvironments(branch, ra) assert.Equal(t, 0, len(targetEnvs)) } @@ -199,8 +188,7 @@ func TestIsThereAnythingToDeploy_promotionScheme_ListsBothButOnlyOneShouldBeBuil WithEnvironment("prod", ""). BuildRA() - application := getApplication(ra) - targetEnvs := application.GetTargetEnvironments(branch) + targetEnvs := GetTargetEnvironments(branch, ra) assert.ElementsMatch(t, []string{"qa"}, targetEnvs) } @@ -212,8 +200,7 @@ func TestIsThereAnythingToDeploy_wildcardMatch_ListsBothButOnlyOneShouldBeBuilt( WithEnvironment("prod", "master"). BuildRA() - application := getApplication(ra) - targetEnvs := application.GetTargetEnvironments(branch) + targetEnvs := GetTargetEnvironments(branch, ra) assert.ElementsMatch(t, []string{"feature"}, targetEnvs) }