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

Add feature flag to disable creds-init #3379

Merged
merged 1 commit into from Nov 3, 2020
Merged

Add feature flag to disable creds-init #3379

merged 1 commit into from Nov 3, 2020

Conversation

ghost
Copy link

@ghost ghost commented Oct 13, 2020

Fixes #2791

Prior to this commit Tekton scans service accounts attached to taskruns
and mounts secrets matching a specific format into all the Steps of a
Task. Then the entrypoint goes through those secrets and copies them
to the user's home directory so they can be used by git, docker, etc

This commit adds a feature-flag, disable-creds-init, that lets users
turn off the service account scanning behaviour. The default is "false"
so the creds-init behaviour remains enabled. Disabling creds-init can be
desirable for a lot of reasons:

  1. The process is opaque and difficult to debug
  2. It's not particularly well suited for non-root, multi-UID tasks.
  3. Only a limited set of credential types are supported

Warning: Disabling creds-init will probably break PipelineResources.

Changes

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

  • Includes tests
  • Includes docs (if user facing)
  • Commit messages follow commit message best practices
  • Release notes block has been filled in or deleted (only if no user facing changes)

See the contribution guide for more details.

Double check this list of stuff that's easy to miss:

Release Notes

Tekton's built-in credential mechanism can now be disabled by setting the `disable-creds-init` feature-flag to "true".

@tekton-robot tekton-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Oct 13, 2020
@tekton-robot tekton-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 13, 2020
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/pod/creds_init.go 91.7% 88.1% -3.6
pkg/pod/pod.go 87.3% 87.4% 0.1

@tekton-robot tekton-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 13, 2020
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/pod/creds_init.go 91.7% 90.5% -1.2
pkg/pod/pod.go 87.3% 87.4% 0.1

@ghost
Copy link
Author

ghost commented Oct 13, 2020

/kind feature

@tekton-robot tekton-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Oct 13, 2020
@ghost
Copy link
Author

ghost commented Oct 13, 2020

/test pull-tekton-pipeline-integration-tests

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/pod/creds_init.go 91.7% 92.9% 1.2
pkg/pod/pod.go 87.3% 87.4% 0.1

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/pod/creds_init.go 91.7% 92.9% 1.2
pkg/pod/pod.go 87.3% 87.4% 0.1

@ghost
Copy link
Author

ghost commented Oct 13, 2020

/test pull-tekton-pipeline-integration-tests

Comment on lines 52 to 54
if cfg != nil && cfg.FeatureFlags != nil && cfg.FeatureFlags.DisableCredsInit == true {
return nil, nil, nil, nil
}
Copy link
Member

Choose a reason for hiding this comment

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

what do you think about using g.FeatureFlags.DisableCredsInit directly instead of comparing with true, like this:

if cfg != nil && cfg.FeatureFlags != nil && cfg.FeatureFlags.DisableCredsInit {
    return nil, nil, nil, nil
}

docs/auth.md Outdated
Comment on lines 574 to 576
4. Tasks with Steps that run as non-root, particularly those where the UIDs
change from Step to Step, can log more warning messages than those without,
creating noise.
Copy link
Member

Choose a reason for hiding this comment

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

is there a way to clarify reason 4, it isn't clear to me what without is referring to

docs/auth.md Outdated
Comment on lines 580 to 649
1. Credentials must now be passed explicitly to Tasks either with Workspaces,
environment variables (using `envFrom` in your Steps and a Task param to
specify a Secret), or a custom volume and volumeMount definition.
Copy link
Member

Choose a reason for hiding this comment

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

could be helpful to reference the documentation for Workspaces, envFrom etc

Comment on lines 119 to 121
if cfg != nil && cfg.FeatureFlags != nil && cfg.FeatureFlags.DisableCredsInit == true {
return nil, nil
}
Copy link
Member

Choose a reason for hiding this comment

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

same as above on using g.FeatureFlags.DisableCredsInit directly:

if cfg != nil && cfg.FeatureFlags != nil && cfg.FeatureFlags.DisableCredsInit {
    return nil, nil
}

pkg/pod/pod.go Outdated
Comment on lines 170 to 172
// Mount /tekton/creds with a fresh volume for each Step. It needs to
// be world-writeable and empty so creds can be initialized in there. Cant
// guarantee what UID container runs with.
Copy link
Member

Choose a reason for hiding this comment

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

may be useful to update this to mention that it mounts fresh volume for each step except when creds-init is disabled

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/pod/creds_init.go 91.7% 92.9% 1.2
pkg/pod/pod.go 87.3% 87.4% 0.1

@ghost
Copy link
Author

ghost commented Oct 14, 2020

@jerop thanks a lot for the feedback! I've made the changes you requested.

@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 20, 2020
Prior to this commit Tekton scans service accounts attached to taskruns
and mounts secrets matching a specific format into all the Steps of a
Task. Then the entrypoint goes through those secrets and copies them
to the user's home directory so they can be used by `git`, `docker`, etc

This commit adds a feature-flag, `disable-creds-init`, that lets users
turn off the service account scanning behaviour. The default is "false"
so the creds-init behaviour remains enabled. Disabling creds-init can be
desirable for a lot of reasons:

1. The process is opaque and difficult to debug
2. It's not particularly well suited for non-root, multi-UID tasks.
3. Only a limited set of credential types are supported

Warning: Disabling creds-init will largely prevent Git and Image
PipelineResources from working.
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 20, 2020
@ghost ghost added this to the Pipelines v0.18 milestone Oct 20, 2020
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/pod/creds_init.go 91.7% 92.9% 1.2
pkg/pod/pod.go 87.3% 87.4% 0.1

@ghost
Copy link
Author

ghost commented Oct 20, 2020

/test pull-tekton-pipeline-go-coverage
/test tekton-pipeline-unit-tests

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/pod/creds_init.go 91.7% 92.9% 1.2
pkg/pod/pod.go 87.3% 87.4% 0.1

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vdemeester

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 Nov 3, 2020
@jerop
Copy link
Member

jerop commented Nov 3, 2020

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 3, 2020
@tekton-robot tekton-robot merged commit 42715eb into tektoncd:master Nov 3, 2020
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/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v0.13.0: unsuccessful cred copy: ".ssh" from "/tekton/creds" to "/root"
3 participants