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

Layered operator #272

Merged
merged 173 commits into from Apr 3, 2024
Merged

Layered operator #272

merged 173 commits into from Apr 3, 2024

Conversation

gazarenkov
Copy link
Collaborator

Description

Operator was redesigned in order to:

  • Have more testable and documentable layered design
  • Be closer to "desired state" driven operator design
  • Move majority of tests to test unit level and reduce number of controller tests (still have all the original controller tests in place to be able to compare)
  • Make it fit design document

Which issue(s) does this PR fix or relate to

#69

PR acceptance criteria

  • Tests
  • Documentation

How to test changes / Special notes to the reviewer

make test

# Conflicts:
#	.gitignore
#	controllers/backstage_controller.go
#	controllers/backstage_controller_test.go
#	controllers/backstage_deployment.go
#	controllers/backstage_service.go
#	controllers/local_db_deployment.go
#	controllers/local_db_storage.go
# Conflicts:
#	api/v1alpha1/backstage_types.go
#	config/crd/bases/janus-idp.io_backstages.yaml
#	controllers/backstage_backend_auth.go
#	controllers/backstage_controller.go
#	controllers/backstage_controller_test.go
#	controllers/local_db_statefulset.go
Co-authored-by: gazarenkov <gazarenkov@users.noreply.github.com>
Copy link
Contributor

github-actions bot commented Apr 1, 2024

⚠️ Files changed in bundle generation!

Those changes to the operator bundle manifests should have been pushed automatically to your PR branch.
You might also need to manually update the .rhdh/bundle/manifests/rhdh-operator.csv.yaml CSV file accordingly.

Makefile Outdated Show resolved Hide resolved
examples/rhdh-cr-with-app-configs.yaml Outdated Show resolved Hide resolved
@@ -98,7 +111,7 @@ type Application struct {

// Image Pull Secrets to use in all containers (including Init Containers)
// +optional
ImagePullSecrets *[]string `json:"imagePullSecrets,omitempty"`
ImagePullSecrets []string `json:"imagePullSecrets,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

If ImagePullSecrets []string is not defined it contains nil pointer If ImagePullSecrets []string is initialized with empty array it contains pointer to empty slice with len:0 and cap:0

So, yes we can distinguish just checking ImagePullSecrets == nil Is it what you're asking about?

It is just that, as it is, the way it is iterated upon in this PR (https://github.com/gazarenkov/janus-idp-operator/blob/e6c56cecebf4f76748e8c80903059593e7fd78a8/pkg/model/deployment.go#L188-L191) will never allow CR users to explicitly set this list to an empty list.

This used to work previously (see

if backstage.Spec.Application.ImagePullSecrets != nil { // use image pull secrets from the CR spec
deployment.Spec.Template.Spec.ImagePullSecrets = nil
if len(*backstage.Spec.Application.ImagePullSecrets) > 0 {
for _, imagePullSecret := range *backstage.Spec.Application.ImagePullSecrets {
deployment.Spec.Template.Spec.ImagePullSecrets = append(deployment.Spec.Template.Spec.ImagePullSecrets, v1.LocalObjectReference{
Name: imagePullSecret,
), i.e., if I explicitly set imagePullSecrets: [] in my CR, the resulting Deployment won't have any pull secrets defined, and if I don't set imagePullSecrets in the CR, it will inherit those coming from the operator/raw config.

But this can be tackled in a separate issue.

Co-authored-by: Armel Soro <armel@rm3l.org>
Co-authored-by: Armel Soro <armel@rm3l.org>
Makefile Outdated Show resolved Hide resolved
Copy link

sonarcloud bot commented Apr 3, 2024

Quality Gate Passed Quality Gate passed

Issues
11 New issues
6 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link
Member

@rm3l rm3l left a comment

Choose a reason for hiding this comment

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

Approving to unblock other work items, but besides what's already in the review comments, there are a couple of things that have an impact on the current downstream documentation. We need to make sure those are handled later in the product documentation:

  • the way the backend auth secret is handled
  • to see changes from a custom CM already referenced in CR, either doing oc rollout restart of the Deployment or updating the spec.application.replicas field in the CR to 0 then back to what it was, so that the operator can recreate the Deployment with the new changes
  • changes to the default naming pattern of the route URL: changed from https://backstage-<CUSTOM_RESOURCE_NAME>-<NAMESPACE_NAME>.<OPENSHIFT_INGRESS_DOMAIN> to https://<CUSTOM_RESOURCE_NAME>-backstage-<NAMESPACE_NAME>.<OPENSHIFT_INGRESS_DOMAIN>

@openshift-ci openshift-ci bot added the lgtm PR is ready to be merged. Required by Prow. label Apr 3, 2024
Copy link

openshift-ci bot commented Apr 3, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rm3l

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

@openshift-ci openshift-ci bot added the approved PR has been approved by an approver from all required OWNERS files. Required by Prow. label Apr 3, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit 0a8f41f into janus-idp:main Apr 3, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved PR has been approved by an approver from all required OWNERS files. Required by Prow. lgtm PR is ready to be merged. Required by Prow. size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants