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 secret fields not immutable anymore #1355

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGES/1343.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Change secret fields to become mutable. This affects the following fields:
- `Pulp.object_storage_azure_secret`
- `Pulp.object_storage_s3_secret`
- `Pulp.db_fields_encryption_secret`
- `Pulp.container_token_secret`
- `Pulp.admin_password_secret`
- `Pulp.cache.external_cache_secret`
- `Pulp.pulp_secret_key`
1 change: 1 addition & 0 deletions apis/repo-manager.pulpproject.org/v1beta2/pulp_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type PulpSpec struct {
// Default: "pulp"
// +kubebuilder:default:="pulp"
// +kubebuilder:validation:Enum:=pulp;galaxy
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="deployment_type is immutable"
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:hidden"}
DeploymentType string `json:"deployment_type,omitempty"`

Expand Down
82 changes: 58 additions & 24 deletions bundle/manifests/repo-manager.pulpproject.org_pulpbackups.yaml

Large diffs are not rendered by default.

603 changes: 454 additions & 149 deletions bundle/manifests/repo-manager.pulpproject.org_pulps.yaml

Large diffs are not rendered by default.

82 changes: 58 additions & 24 deletions config/crd/bases/repo-manager.pulpproject.org_pulpbackups.yaml

Large diffs are not rendered by default.

603 changes: 454 additions & 149 deletions config/crd/bases/repo-manager.pulpproject.org_pulps.yaml

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions controllers/repo_manager/precheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,6 @@ func checkImmutableFields(ctx context.Context, r *RepoManagerReconciler, pulp *r
// Checking immutable fields update
immutableFields := []immutableField{
{FieldName: "DeploymentType", FieldPath: repomanagerpulpprojectorgv1beta2.PulpSpec{}},
{FieldName: "ObjectStorageAzureSecret", FieldPath: repomanagerpulpprojectorgv1beta2.PulpSpec{}},
{FieldName: "ObjectStorageS3Secret", FieldPath: repomanagerpulpprojectorgv1beta2.PulpSpec{}},
{FieldName: "DBFieldsEncryptionSecret", FieldPath: repomanagerpulpprojectorgv1beta2.PulpSpec{}},
Copy link

Choose a reason for hiding this comment

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

Can we keep DBFieldsEncryptionSecret immutable for now? If a user changes it without properly following the key rotation (https://pulpproject.org/pulpcore/docs/admin/reference/settings/#db_encryption_key) then Pulp will become unusable and you will have to drop your database and start over. Until we can add this fancy rotation logic to the operator I think it is best to leave it immutable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would be possible. However admins can already shoot themselves in the foot when changing the value within the secret. And if someone wants to change to another secret, referencing the same secret value, they could not do so.

So IMO keeping it immutable would just be snake oil

Copy link

Choose a reason for hiding this comment

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

We want there to be something to tell the user "PLEASE DON'T CHANGE THIS VALUE".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense. I would think of adding it here with a warning box as well as changing the docs on the parameter for kubebuilder generation (and work with some caps in the latter case).

I would go with something along the lines of "DON'T CHANGE THIS VALUE UNLESS YOU KNOW WHAT YOU ARE DOING".

Is that reasonable/sufficient or would you still like to keep immutability on that?

{FieldName: "ContainerTokenSecret", FieldPath: repomanagerpulpprojectorgv1beta2.PulpSpec{}},
{FieldName: "AdminPasswordSecret", FieldPath: repomanagerpulpprojectorgv1beta2.PulpSpec{}},
{FieldName: "ExternalCacheSecret", FieldPath: repomanagerpulpprojectorgv1beta2.Cache{}},
{FieldName: "PulpSecretKey", FieldPath: repomanagerpulpprojectorgv1beta2.PulpSpec{}},
}
for _, field := range immutableFields {
// if tried to modify an immutable field we should trigger a reconcile loop
Expand Down
6 changes: 2 additions & 4 deletions staging_docs/admin/guides/configurations/secrets.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,13 @@ spec:
...
```

If the `admin_password_secret` field is not defined with the name of a `Secret` the Operator will create one (called *pulp-admin-password*) with a random string.
This field is immutable, i.e., it is not possible to modify the name of the `Secret` that the Operator will use to define the admin password. In case of a need to update the admin password, the `Secret` content should be updated instead.
If the `admin_password_secret` field is not defined with the name of a `Secret` the Operator will create one (called *pulp-admin-password*) with a random string.


### pulp-container-auth

Contains the keys which are going to be used for the [signing and validation of tokens](https://docs.pulpproject.org/pulp_container/authentication.html#token-authentication-label).
It is managed by `container_token_secret` field in Pulp `CR`. The `Secret` name is immutable (an attempt to change its name in Pulp `CR` will reconcile it), any update should be done in the existing `Secret` content.
It is managed by `container_token_secret` field in Pulp `CR`.

### pulp-secret-key

Expand All @@ -141,4 +140,3 @@ spec:
```

If the `pulp_secret_key` field is not defined with the name of a `Secret` the Operator will create one (called *pulp-secret-key*) with a random string.
This field is immutable, i.e., it is not possible to modify the name of the `Secret` that the Operator will use to define the Django `SECRET_KEY`. In case of a need to update it, the `Secret` content should be updated instead.
Loading