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
add ownership for unshared secrets and configmaps #220
Conversation
now updated with vendored constant |
api.ServiceNameAnnotation: service.Name, | ||
api.ServiceUIDAnnotation: string(service.UID), | ||
api.ServiceNameAnnotation: service.Name, | ||
apiannotations.OpenShiftComponent: "service-ca", |
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.
Can we use api.OwningJiraComponent
here as well?
api.AlphaServiceNameAnnotation: service.Name, | ||
api.AlphaServiceUIDAnnotation: string(service.UID), | ||
api.AlphaServiceNameAnnotation: service.Name, | ||
apiannotations.OpenShiftComponent: "service-ca", |
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.
Can we use api.OwningJiraComponent
here as well?
@@ -207,7 +208,17 @@ func (sc *serviceServingCertUpdateController) ensureSecretData(service *v1.Servi | |||
} | |||
return true, nil | |||
} | |||
return update, nil | |||
|
|||
if update { |
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.
Minor refactoring suggestion; drop if update{}
and:
if !update && len(secretCopy.Annotations[apiannotations.OpenShiftComponent]) == 0 {
secretCopy...
update = true
}
return update, nil
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.
I personally dislike it because you have to remember more state, but I will yield to the reviewer.
@@ -109,6 +109,11 @@ func (bi *configMapCABundleInjector) Sync(ctx context.Context, syncCtx factory.S | |||
// make a copy to avoid mutating cache state | |||
configMapCopy := configMap.DeepCopy() | |||
configMapCopy.Data = map[string]string{api.InjectionDataKey: bi.caBundle} | |||
// set the owning-component unless someone else has claimed it. | |||
if len(configMapCopy.Annotations[api.OwningJiraComponent]) == 0 { | |||
configMapCopy.Annotations[api.OwningJiraComponent] = api.OwningJiraComponent |
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.
Shouldn't it be configMapCopy.Annotations[apiannotations.OpenShiftComponent]
instead?
@@ -329,6 +329,7 @@ func toBaseSecret(service *corev1.Service) *corev1.Secret { | |||
Annotations: map[string]string{ | |||
api.ServiceUIDAnnotation: string(service.UID), | |||
api.ServiceNameAnnotation: service.Name, | |||
api.OwningJiraComponent: "service-ca", |
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.
I actually meant to replace "service-ca"
with api.OwningJiraComponent
:
apiannotations.OpenShiftComponent: api.OwningJiraComponent,
@@ -342,6 +343,7 @@ func toBaseSecret(service *corev1.Service) *corev1.Secret { | |||
Annotations: map[string]string{ | |||
api.AlphaServiceUIDAnnotation: string(service.UID), | |||
api.AlphaServiceNameAnnotation: service.Name, | |||
api.OwningJiraComponent: "service-ca", |
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.
apiannotations.OpenShiftComponent: api.OwningJiraComponent,
@@ -407,6 +409,7 @@ func toRequiredSecret(dnsSuffix string, ca *crypto.CA, intermediateCACert *x509. | |||
|
|||
secretCopy.Annotations[api.AlphaServingCertExpiryAnnotation] = servingCert.Certs[0].NotAfter.Format(time.RFC3339) | |||
secretCopy.Annotations[api.ServingCertExpiryAnnotation] = servingCert.Certs[0].NotAfter.Format(time.RFC3339) | |||
secretCopy.Annotations[api.OwningJiraComponent] = api.OwningJiraComponent |
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.
Shouldn't it be secretCopy.Annotations[apiannotations.OpenShiftComponent]
instead?
@@ -147,6 +147,7 @@ func TestServiceServingCertControllerSync(t *testing.T) { | |||
expectedSecretAnnotations: map[string]string{ | |||
api.AlphaServiceUIDAnnotation: testServiceUID, | |||
api.AlphaServiceNameAnnotation: testServiceName, | |||
api.OwningJiraComponent: api.OwningJiraComponent, |
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.
Wrong annotation name here as well; apiannotations.OpenShiftComponent
. Several occurences in this file.
|
||
// set the owning-component unless someone else has claimed it. | ||
if !update && len(secretCopy.Annotations[api.OwningJiraComponent]) == 0 { | ||
secretCopy.Annotations[api.OwningJiraComponent] = api.OwningJiraComponent |
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.
Shouldn't it be secretCopy.Annotations[apiannotations.OpenShiftComponent]
instead?
I hate constants that cannot change for constants. tried again. |
huh, wonder if that's a flake or I broke it /retest |
installer failure |
install failures /retest |
@deads2k: all tests passed! Full PR test history. Your PR dashboard. 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. I understand the commands that are listed here. |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: deads2k, liouk 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 |
[ART PR BUILD NOTIFIER] This PR has been included in build ose-service-ca-operator-container-v4.15.0-202311202349.p0.gfe88761.assembly.stream for distgit ose-service-ca-operator. |
The openshift/api field will merge and be revendored here.
serving secrets and injected configmaps are not shared, we stomp all the keys. Add the service-ca as the owner of these configmaps since we control the content.