Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

feat(certs): create MRC on install #4747

Merged
merged 6 commits into from
May 25, 2022
Merged

Conversation

jaellio
Copy link
Contributor

@jaellio jaellio commented May 16, 2022

Description:

Updates the osm-bootstrap to create a default MeshRootCertificate
on osm install. Adds a preset-mesh-root-certificate ConfigMap to
the Helm templates. The osm-bootstrap will obtain the MRC spec
from the ConfigMap and attempt to create a default MRC. If an MRC
already exists with a complete state and issuing rotation stage then
the osm-bootstrap will not create the default MRC.

Additional changes:

  • adds MeshRootCertificate CRD to uninstall list
  • adds the tokenSecretName and tokenSecretKey values to the
    osm.vault values
  • removes SecretName from the certManager provider in the mesh
    root certificate
  • cleans up MeshConfig tests

Resolves #4712

Note: This change does not include creating the Vault token
secret. The MRC created is not used at this point by the OSM
control plane. This will come in a later PR.

Testing done:

  • CI
  • Demo

Affected area:

Functional Area
Certificate Management [x]

Please answer the following questions with yes/no.

  1. Does this change contain code from or inspired by another project? No

    • Did you notify the maintainers and provide attribution?
  2. Is this a breaking change? No

  3. Has documentation corresponding to this change been updated in the osm-docs repo (if applicable)? No

@codecov-commenter
Copy link

codecov-commenter commented May 16, 2022

Codecov Report

Merging #4747 (1c3223b) into main (ecc4e67) will increase coverage by 0.04%.
The diff coverage is 75.75%.

@@            Coverage Diff             @@
##             main    #4747      +/-   ##
==========================================
+ Coverage   68.96%   69.01%   +0.04%     
==========================================
  Files         227      227              
  Lines       16454    16512      +58     
==========================================
+ Hits        11348    11395      +47     
- Misses       5054     5065      +11     
  Partials       52       52              
Flag Coverage Δ
unittests 69.01% <75.75%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
cmd/osm-bootstrap/osm-bootstrap.go 47.67% <74.60%> (+7.58%) ⬆️
cmd/cli/uninstall_mesh.go 69.37% <100.00%> (+0.09%) ⬆️
pkg/certificate/providers/config.go 79.68% <100.00%> (ø)
pkg/certificate/manager.go 92.66% <0.00%> (+1.83%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ecc4e67...1c3223b. Read the comment docs.

@jaellio
Copy link
Contributor Author

jaellio commented May 16, 2022

Waiting on #4736

@jaellio jaellio force-pushed the createMRC branch 4 times, most recently from 1ce273c to fca63ec Compare May 19, 2022 21:33
@jaellio jaellio marked this pull request as ready for review May 19, 2022 22:20
cmd/osm-bootstrap/osm-bootstrap.go Outdated Show resolved Hide resolved
cmd/osm-bootstrap/osm-bootstrap_test.go Outdated Show resolved Hide resolved
cmd/osm-bootstrap/osm-bootstrap_test.go Outdated Show resolved Hide resolved
@jaellio jaellio marked this pull request as draft May 23, 2022 15:32
@jaellio jaellio marked this pull request as ready for review May 23, 2022 18:17
charts/osm/README.md Outdated Show resolved Hide resolved
cmd/osm-bootstrap/osm-bootstrap.go Outdated Show resolved Hide resolved
presetMeshRootCertificate := presetMeshRootCertificateConfigMap.Data[presetMeshRootCertificateJSONKey]
presetMeshRootCertificateSpec := configv1alpha2.MeshRootCertificateSpec{}
err := json.Unmarshal([]byte(presetMeshRootCertificate), &presetMeshRootCertificateSpec)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

this function returns an error, so prefer to return the error vs log.Fatal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. I was following the same pattern we have for the MeshConfig, but that makes sense. For my own understanding, should a fatal log only be used when a function doesn't return an error? I would consider this error irrecoverable and I think log.Fatal fits here in that sense.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ya I'd say that I try to keep errors opaque. So there's either an error or a warning. A warning might get logged (but not returned), and the caller can decide what to do when the call to the function fails.

ie: an error just means the call failed, the caller decides what to do.

Another rule that's touted a lot is: only panic/exit in package main. All other packages should return errors. The typical exception is convenience functions that begin with Must, ie: text.MustParse

cmd/osm-bootstrap/osm-bootstrap.go Outdated Show resolved Hide resolved
cmd/osm-bootstrap/osm-bootstrap.go Outdated Show resolved Hide resolved
jaellio added 5 commits May 24, 2022 12:56
Updates the osm-bootstrap to create a default MeshRootCertificate
on osm install. Adds a preset-mesh-root-certificate ConfigMap to
the Helm templates. The osm-bootstrap will obtain the MRC spec
from the ConfigMap and attempt to create a default MRC. If an MRC
already exists with complete state and issuing rotationStage then
the osm-bootstrap will not create the default MRC.

Additional changes:
- adds MeshRootCertificate CRD to uninstall list
- adds a tokenSecretName value to the osm.vault values

Signed-off-by: jaellio <jaellio@microsoft.com>
Signed-off-by: jaellio <jaellio@microsoft.com>
Signed-off-by: jaellio <jaellio@microsoft.com>
Signed-off-by: jaellio <jaellio@microsoft.com>
Signed-off-by: jaellio <jaellio@microsoft.com>
@jaellio jaellio force-pushed the createMRC branch 2 times, most recently from 7061984 to 1c3223b Compare May 24, 2022 20:46
Signed-off-by: jaellio <jaellio@microsoft.com>
@jaellio jaellio merged commit 7ddd4d1 into openservicemesh:main May 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a MeshRootCertificate on osm install
5 participants