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

Make SA implicit in TestPropagatedParams #6185

Merged

Conversation

concaf
Copy link
Contributor

@concaf concaf commented Feb 17, 2023

Changes

Make SA implicit in TestPropagatedParams

Currently, `serviceAccountName: default` is added to some PipelineRuns
in the test `TestPropagatedParams` and not the others. This commit
removes it from all TaskRuns and PipelineRuns defined in the test.

While this may seem inconsequential, making the service account
implicit fixes running this test in OpenShift Pipelines where the
default service account is not `default`.

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Has Docs included if any changes are user facing
  • Has Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including
    functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings)
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

NONE

@tekton-robot tekton-robot added kind/misc Categorizes issue or PR as a miscellaneuous one. release-note-none Denotes a PR that doesnt merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Feb 17, 2023
@concaf
Copy link
Contributor Author

concaf commented Feb 17, 2023

/kind misc

@concaf
Copy link
Contributor Author

concaf commented Feb 17, 2023

/test check-pr-has-kind-label

@tekton-robot
Copy link
Collaborator

@concaf: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test pull-tekton-pipeline-alpha-integration-tests
  • /test pull-tekton-pipeline-beta-integration-tests
  • /test pull-tekton-pipeline-build-tests
  • /test pull-tekton-pipeline-integration-tests
  • /test tekton-pipeline-unit-tests

The following commands are available to trigger optional jobs:

  • /test pull-tekton-pipeline-go-coverage

Use /test all to run all jobs.

In response to this:

/test check-pr-has-kind-label

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link
Member

@lbernick lbernick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding a serviceAccountName to the test input (for tests that don't actually rely on the service account name at all), where it could be removed without breaking tests, I think it would be better to exclude the serviceaccountname from the want/got comparison for this set of tests.

@concaf concaf force-pushed the concaf/fix/tests-serviceAccountName branch from fe775fb to d1447f7 Compare February 20, 2023 10:10
@concaf concaf changed the title Add SA to PipelineRuns in TestPropagatedParams Make SA implicit in TestPropagatedParams Feb 20, 2023
@concaf
Copy link
Contributor Author

concaf commented Feb 20, 2023

@lbernick thanks for the quick response, it makes sense :) i've updated the PR

@vdemeester
Copy link
Member

propagated_params_test.go:113: The resolved spec does not match the expected spec. Here is the diff:   &v1beta1.PipelineRun{
          }

That logs is not that usefull 🙃

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the "defaulting" mechanism will do its job, the expected TaskRun or PipelineRun will have a default serviceAccountName set. We need to make sure we ignore this as well, using the same pattern as ignoreTypeMeta and other cmpopts.IgnoreFields.

test/propagated_params_test.go Show resolved Hide resolved
@concaf concaf force-pushed the concaf/fix/tests-serviceAccountName branch from d1447f7 to 5eafe20 Compare February 28, 2023 13:55
@tekton-robot tekton-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Feb 28, 2023
@@ -44,7 +44,8 @@ var (
ignoreConditions = cmpopts.IgnoreFields(duckv1.Status{}, "Conditions")
ignoreContainerStates = cmpopts.IgnoreFields(corev1.ContainerState{}, "Terminated")
ignoreStepState = cmpopts.IgnoreFields(v1beta1.StepState{}, "ImageID")
ignoreTaskRunSpec = cmpopts.IgnoreFields(v1beta1.TaskRunSpec{}, "Resources")
ignoreTaskRunSpec = cmpopts.IgnoreFields(v1beta1.TaskRunSpec{}, "Resources", "ServiceAccountName")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this variable used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you mean ignoreTaskRunSpec? it's used here -

ignoreTaskRunSpec,

@@ -44,7 +44,8 @@ var (
ignoreConditions = cmpopts.IgnoreFields(duckv1.Status{}, "Conditions")
ignoreContainerStates = cmpopts.IgnoreFields(corev1.ContainerState{}, "Terminated")
ignoreStepState = cmpopts.IgnoreFields(v1beta1.StepState{}, "ImageID")
ignoreTaskRunSpec = cmpopts.IgnoreFields(v1beta1.TaskRunSpec{}, "Resources")
ignoreTaskRunSpec = cmpopts.IgnoreFields(v1beta1.TaskRunSpec{}, "Resources", "ServiceAccountName")
ignorePipelineRunSpec = cmpopts.IgnoreFields(v1beta1.PipelineRunSpec{}, "ServiceAccountName")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest renaming to "ignoreServiceAccountName" and adding a comment that we're ignoring it because the default can differ between platforms

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, done

Currently, `serviceAccountName: default` is added to some PipelineRuns
in the test `TestPropagatedParams` and not the others. This commit
removes it from all TaskRuns and PipelineRuns defined in the test.

While this may seem inconsequential, making the service account
implicit fixes running this test in OpenShift Pipelines where the
default service account is not `default`.

Further, the field `ServiceAccountName` has been configured to be
ignored in both, `TaskRunSpec` and `PipelineRunSpec` as the actual
output still contains the Service Account name.
@concaf concaf force-pushed the concaf/fix/tests-serviceAccountName branch from 5eafe20 to cf9b51e Compare March 1, 2023 09:10
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lbernick

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 1, 2023
@concaf
Copy link
Contributor Author

concaf commented Mar 6, 2023

thanks @lbernick 😸
cc: @vdemeester good to go?

Copy link
Member

@jerop jerop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 6, 2023
@tekton-robot tekton-robot merged commit 160b7ce into tektoncd:main Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/misc Categorizes issue or PR as a miscellaneuous one. lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesnt merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants