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

(bugfix): OCPBUGS-3072 - fix operator-sdk run bundle(-upgrade) PSA related issues #6210

Merged

Conversation

everettraven
Copy link
Contributor

Description of the change:

  • Update default channel name selection to be different based on using FBC vs SQLite image.
  • Update the SecurityContext from the registry pod containers created by operator-sdk run bundle(-upgrade) to only be added to the containers when --security-context-config=restricted
  • Change default of --security-context-config flag to be legacy in anticipation of some OpenShift PSA changes.
  • Set the CatalogSource.grpcPodConfig.securityContextConfig to the same value of the --security-context-config flag.

Motivation for the change:

  • Fixes a bug where SQLite bundle images couldn't be properly run due to setting the default channel name to operator-sdk-run-bundle.
    • This became a problem because we can manipulate FBCs to utilize this default channel, but we can not as easily manipulate the SQLite bundle to do the same.
  • Fixes a bug where even when specifying --security-context-config=legacy , the registry pod created still set the SecurityContext on the container as if it was in a restricted environment.

Checklist

If the pull request includes user-facing changes, extra documentation is required:

@everettraven everettraven temporarily deployed to deploy December 2, 2022 19:12 Inactive
@everettraven everettraven temporarily deployed to deploy December 2, 2022 19:12 Inactive
@everettraven everettraven temporarily deployed to deploy December 2, 2022 19:12 Inactive
@everettraven everettraven temporarily deployed to deploy December 2, 2022 19:12 Inactive
@everettraven everettraven temporarily deployed to deploy December 2, 2022 19:12 Inactive
@everettraven everettraven temporarily deployed to deploy December 2, 2022 19:12 Inactive
@everettraven everettraven temporarily deployed to deploy December 2, 2022 19:12 Inactive
@@ -139,7 +139,7 @@ func (c *IndexImageCatalogCreator) BindFlags(fs *pflag.FlagSet) {
"while pulling bundles")

// default to Restricted
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// default to Restricted
// default to Legacy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be resolved as of 1d2e1ed

Comment on lines 92 to 99
func withGrpcPodConfig(securityContextConfig string) func(*v1alpha1.CatalogSource) {
return func(cs *v1alpha1.CatalogSource) {
cs.Spec.GrpcPodConfig = &v1alpha1.GrpcPodConfig{
SecurityContextConfig: v1alpha1.SecurityConfig(securityContextConfig),
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Function name should align with what we're passing into the function. Either pass in the full grpcPodConfig or rename (and refactor) to just handle the securityContextConfig.

Suggestion showing the latter option:

Suggested change
func withGrpcPodConfig(securityContextConfig string) func(*v1alpha1.CatalogSource) {
return func(cs *v1alpha1.CatalogSource) {
cs.Spec.GrpcPodConfig = &v1alpha1.GrpcPodConfig{
SecurityContextConfig: v1alpha1.SecurityConfig(securityContextConfig),
}
}
}
func withGrpcPodSecurityContextConfig(securityContextConfig string) func(*v1alpha1.CatalogSource) {
return func(cs *v1alpha1.CatalogSource) {
if cs.Spec.GrpcPodConfig == nil {
cs.Spec.GrpcPodConfig = &v1alpha1.GrpcPodConfig{}
}
cs.Spec.GrpcPodConfig.SecurityContextConfig = v1alpha1.SecurityConfig(securityContextConfig)
}
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be resolved as of 1d2e1ed

@everettraven everettraven temporarily deployed to deploy December 2, 2022 21:13 Inactive
@everettraven everettraven temporarily deployed to deploy December 2, 2022 21:13 Inactive
@everettraven everettraven temporarily deployed to deploy December 2, 2022 21:13 Inactive
@everettraven everettraven temporarily deployed to deploy December 2, 2022 21:13 Inactive
@everettraven everettraven temporarily deployed to deploy December 2, 2022 21:13 Inactive
@everettraven everettraven temporarily deployed to deploy December 2, 2022 21:13 Inactive
@everettraven everettraven temporarily deployed to deploy December 2, 2022 21:13 Inactive
@everettraven everettraven temporarily deployed to deploy December 2, 2022 22:07 Inactive
@everettraven everettraven temporarily deployed to deploy December 2, 2022 22:07 Inactive
@everettraven everettraven temporarily deployed to deploy December 2, 2022 22:07 Inactive
@everettraven everettraven temporarily deployed to deploy December 2, 2022 22:07 Inactive
@everettraven everettraven temporarily deployed to deploy December 2, 2022 22:07 Inactive
@everettraven everettraven temporarily deployed to deploy December 2, 2022 22:07 Inactive
@everettraven everettraven temporarily deployed to deploy December 2, 2022 22:07 Inactive
@jmrodri
Copy link
Member

jmrodri commented Dec 7, 2022

Fixes a bug where even when specifying --security-context-config=legacy , the registry pod created still set the SecurityContext on the container as if it was in a restricted environment.

@everettraven The SecurityContext was always there even before PSA. So are we saying that if the context is legacy mode that ALL of the security contexts are removed? It might be correct, but I'd make sure to ask that we're not undoing something that was needed before.

@everettraven
Copy link
Contributor Author

The SecurityContext was always there even before PSA. So are we saying that if the context is legacy mode that ALL of the security contexts are removed? It might be correct, but I'd make sure to ask that we're not undoing something that was needed before.

@jmrodri I don't think we ran into this issue previously because we were by default using a container in the pod that wasn't running as root. The problem is that when you specify a specific index image that may be attempting to run as root and set --security-context-config=legacy we were still enforcing PSA in a way that made it so the container is not able to run as root, hence it would fail to run the registry pod.

I haven't taken a look at this for a couple weeks since I was on vacation, so I don't recall if I have tested all possible scenarios. Since I have to fix the failing unit tests I will run through a manual suite of tests again to ensure this is functioning as expected.

@everettraven everettraven temporarily deployed to deploy December 19, 2022 20:23 — with GitHub Actions Inactive
@everettraven everettraven temporarily deployed to deploy December 19, 2022 20:23 — with GitHub Actions Inactive
@everettraven everettraven temporarily deployed to deploy December 20, 2022 18:54 — with GitHub Actions Inactive
Signed-off-by: Bryce Palmer <bpalmer@redhat.com>
@everettraven everettraven temporarily deployed to deploy December 20, 2022 19:07 — with GitHub Actions Inactive
@everettraven everettraven temporarily deployed to deploy December 20, 2022 19:07 — with GitHub Actions Inactive
@everettraven everettraven temporarily deployed to deploy December 20, 2022 19:07 — with GitHub Actions Inactive
@everettraven everettraven temporarily deployed to deploy December 20, 2022 19:07 — with GitHub Actions Inactive
@everettraven everettraven temporarily deployed to deploy December 20, 2022 19:07 — with GitHub Actions Inactive
@everettraven everettraven temporarily deployed to deploy December 20, 2022 19:07 — with GitHub Actions Inactive
@everettraven everettraven temporarily deployed to deploy December 20, 2022 19:07 — with GitHub Actions Inactive
- click `Edit` on the `v.*` branch rule.
- In section `Protect matching branches` of the `Rule settings` box, set "Required approving reviewers" to `6`.
1. Lock down the `v1.3.x` branch to prevent further commits before the release completes:
1. Go to `Settings -> Branches` in the SDK repo.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: I think the formatting here didn't quite do what you intended with the indents

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, running the docs site locally it doesn't look like it formatted correctly. That being said, I pretty much snatched this straight from an existing section for locking down the branch and just changed some values. The section I snatched from:

1. Lock down the `master` branch to prevent further commits before the release completes:
1. Go to `Settings -> Branches` in the SDK repo.
1. Under `Branch protection rules`, click `Edit` on the `master` branch rule.
1. In section `Protect matching branches` of the `Rule settings` box, increase the number of required approving reviewers to 6.

@oceanc80
Copy link
Collaborator

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Dec 20, 2022
@everettraven everettraven merged commit 2058be2 into operator-framework:master Dec 22, 2022
@everettraven everettraven deleted the bugfix/OCPBUGS3072-rbu branch December 22, 2022 14:52
@everettraven
Copy link
Contributor Author

/cherry-pick v1.26.x

@openshift-cherrypick-robot

@everettraven: new pull request created: #6226

In response to this:

/cherry-pick v1.26.x

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.

@rashmigottipati
Copy link
Member

/cherry-pick v1.25.x

@openshift-cherrypick-robot

@rashmigottipati: #6210 failed to apply on top of branch "v1.25.x":

Applying: (bugfix): OCPBUGS-3072 - fix run bundle PSA related issues
Using index info to reconstruct a base tree...
M	internal/olm/operator/registry/fbcindex/fbc_registry_pod.go
Falling back to patching base and 3-way merge...
Auto-merging internal/olm/operator/registry/fbcindex/fbc_registry_pod.go
CONFLICT (content): Merge conflict in internal/olm/operator/registry/fbcindex/fbc_registry_pod.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 (bugfix): OCPBUGS-3072 - fix run bundle PSA related issues
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherry-pick v1.25.x

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.

@everettraven everettraven restored the bugfix/OCPBUGS3072-rbu branch January 25, 2023 17:47
rashmigottipati pushed a commit to rashmigottipati/operator-sdk that referenced this pull request Jan 25, 2023
…related issues (operator-framework#6210)

Signed-off-by: rashmigottipati <chowdary.grashmi@gmail.com>
rashmigottipati pushed a commit to rashmigottipati/operator-sdk that referenced this pull request Jan 25, 2023
…related issues (operator-framework#6210)

Signed-off-by: rashmigottipati <chowdary.grashmi@gmail.com>
rashmigottipati pushed a commit to rashmigottipati/operator-sdk that referenced this pull request Jan 25, 2023
…related issues (operator-framework#6210)

Signed-off-by: rashmigottipati <chowdary.grashmi@gmail.com>
rashmigottipati added a commit that referenced this pull request Jan 25, 2023
…related issues (#6210) (#6261)

Signed-off-by: rashmigottipati <chowdary.grashmi@gmail.com>

Signed-off-by: rashmigottipati <chowdary.grashmi@gmail.com>
Co-authored-by: Bryce Palmer <bpalmer@redhat.com>
tiraboschi added a commit to tiraboschi/hyperconverged-cluster-operator that referenced this pull request Jul 10, 2023
operator-sdk run bundle(-upgrade) is running
by default in legacy mode (see:
operator-framework/operator-sdk#6210 )
which is not going to work out of the box
on OCP/OKD 4.14 where PSA is enforced to restricted
by default.

Set --security-context-config=restricted to
be able to execute on CI also on OCP/OKD 4.14.

Signed-off-by: stirabos <stirabos@redhat.com>
kubevirt-bot pushed a commit to kubevirt/hyperconverged-cluster-operator that referenced this pull request Jul 11, 2023
operator-sdk run bundle(-upgrade) is running
by default in legacy mode (see:
operator-framework/operator-sdk#6210 )
which is not going to work out of the box
on OCP/OKD 4.14 where PSA is enforced to restricted
by default.

Set --security-context-config=restricted to
be able to execute on CI also on OCP/OKD 4.14.

Signed-off-by: stirabos <stirabos@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants