✨ Modify the userdata secret creation logic #264
✨ Modify the userdata secret creation logic #264
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: maelk 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 |
/cc @jan-est |
/test-v1a3-integration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few small comments but otherwise looks good to me
if (m.Machine.Spec.Bootstrap.DataSecretName == nil && | ||
m.Machine.Spec.Bootstrap.Data != nil) || | ||
(m.Machine.Spec.Bootstrap.DataSecretName != nil && | ||
m.Machine.Namespace != host.Namespace) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems a very complex logic, can we simplify it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not really. There are two cases, the first one is that objects are not in the same namespace when DataSecretName is set, and the second one is that DataSecretName is not set but Data is set. I don't see how to make it simpler.
tmpBootstrapSecret.Finalizers = []string{} | ||
err = m.client.Update(ctx, &tmpBootstrapSecret) | ||
if err != nil { | ||
m.setError("Failed to delete BareMetalMachine", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the message contain some info about the actual reason i.e. cannot delete Bootstrap secret, Failed to delete BMM or something like that?
// Delete the secret with use data | ||
err = m.client.Delete(ctx, &tmpBootstrapSecret) | ||
if err != nil { | ||
m.setError("Failed to delete BareMetalMachine", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the message contain some info about the actual reason i.e. cannot delete Bootstrap secret, Failed to delete BMM or something like that?
Create the UserData secret if BMH and Machine are in different namespaces and DataSecretName is set or when it is unset and Data is set.
998b4c6
to
fee8cdd
Compare
/test-v1a3-integration |
1 similar comment
/test-v1a3-integration |
/lgtm |
What this PR does / why we need it:
Currently, we always create a secret with the userdata for BMH. Since CABPK v1alpha3, CABPK creates a secret containing the userData. This PR removes the duplication of the secret where possible.
Several cases: