-
Notifications
You must be signed in to change notification settings - Fork 150
Add custom branding to config map #220
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
Conversation
|
Everything expected to fail until api changes are in place |
|
Gonna add e2e for this feature? |
|
Users will set the CustomLogoFile on the operator config, if it doesn't work, they will prob |
So here are the errors I have been able to generate:
|
|
@benjaminapetersen - I added logic in the operator.go function |
|
Some comments about your API: ...
spec:
customization:
...
customLogoFile: # this really should be customLogo
name: myconfig # validate using the logic stated below
key: mypic.jpg # there is no value is allowing a user to pick the key |
| // recorder | ||
| recorder: recorder, | ||
| recorder: recorder, | ||
| resourceSyncer: resourceSyncer, |
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 would expect a config informer name addition below.
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 do not have another config informer. The informer is part of the resourceSyncer.
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.
@enj - Can you clarify this further? We do have the config informer set just as it is in the cluster auth op.
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 will probably clarify:
https://github.com/openshift/cluster-authentication-operator/blob/master/pkg/operator2/operator.go#L230
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.
Further this line:
operator.WithInformer(configMapInformer, operator.FilterByNames(api.OpenShiftConsoleConfigMapName, api.ServiceCAConfigMapName)),
Shows that right now in theopenshift-console namespace, the informers only fire on changes to console-config & service-ca. If you sync in my-logo, my-logo2, etc, these will not trigger the informer. In addition, if my-logo is already sync'd into the openshift-console namespace, but the user changes the value of the logo within the configmap, this will also NOT be noticed.
It's possible you are seeing sync because you are triggering the loop in other ways. By the time a typical user is getting to the point of configuring a custom logo, the system will be very idle. There won't be other events to piggy-back on. If you happen to be testing with some bash scripts, I'd be cautious about what they are doing that might be triggering the loop in unexpected ways.
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.
So, we are assuming a "non-happy" path where the user changes the configmap directly in the openshift-console namespace? We should only expect a change when the user changes the configmap in openshift-config but I agree we should cover this just in case.
As a side question, if the user can manipulate the openshift-console namespace, why did we bother putting the custom logo config map in the openshift-config in the first place?
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.
done
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.
No, we are not saying the user changes a configmap directly in openshift-console. I think you are misunderstanding the design here. You have 2 sync loops running with the syncer.
When the resource syncer finally decides "yes, this is a logo, copy it over"... our main sync needs to know that the new custom-logo configmap even exists & watches is so that it updates (and you cannot trust an accidental update because the sync loop ran for another reason).
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.
Make sure you understand how the sync loops communicate. It is a very small overlap (precisely to ensure our main loop is not triggered too much).
| // Get Operator Config here | ||
| logoName := operatorConfig.Spec.Customization.CustomLogoFile.Name | ||
| // add syncing for the custom logo config map | ||
| if logoName != "" { |
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.
If this is empty, you need to set the source to ""/""
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 am skipping the sync code completely if there is no logoName set so I don't know what good it would be to set the source to "/". Currently, the code is working as intended.
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.
""/"" meant "namespace / name"
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.
Still not following here, if the logoName is empty (the value has not been set on the operator config), then I would end up with "namespace / ", plus this code would not get executed.
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.
Ensure it deletes? I was able to easily get about a dozen new configmaps in theopenshift-console namespace. That shouldn't happen.
pkg/console/operator/operator.go
Outdated
| // add syncing for the custom logo config map | ||
| if logoName != "" { | ||
| err := c.resourceSyncer.SyncConfigMap( | ||
| resourcesynccontroller.ResourceLocation{Namespace: api.OpenShiftConsoleNamespace, Name: logoName}, |
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.
The destination must be static.
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 wish I could make the destination name static but that value is set by the user. The SyncConfigMap does not have an issue with me passing a dynamic name into the ResourceLocations.
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.
Try oc apply -f on this operator config:
apiVersion: operator.openshift.io/v1
kind: Console
metadata:
name: cluster
spec:
customization:
customProductName: Muh Clusta
customLogoFile:
name: console-config # uh oh! We gonna blow up....
key: fake-logo.pngThere 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.
oc apply -f
apiVersion: operator.openshift.io/v1
kind: Console
metadata:
name: cluster
spec:
customization:
customProductName: Muh Clusta
customLogoFile:
name: service-ca # also bad things will happen.
key: fake-logo.pngThere 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 am glad you changed your mind on having this dynamic. I will set the destination name to a set name and that will prevent existing configmaps from being clobbered.
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.
done
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 am glad you changed your mind on having this dynamic.
I dont know what this means?
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.
We haven't changed our minds. The user SHOULD be able to do:
customLogoFile:
name: console-config # or service-ca or whatever they want to call it, we don't care...
key: fake-logo.pngAnd it SHOULD NOT destroy console-config or service-ca. This should be copied into a configmap named custom-logo in openshift-console with no risk of destroying any console config.
pkg/console/operator/operator.go
Outdated
| if err != nil { | ||
| klog.Errorf("customLogo configmap not valid, %v", err) | ||
| // Set Operator Status to CustomLogoInvalid | ||
| c.SetStatusCondition(operatorConfig, reasonCustomLogoInvalid, operatorsv1.ConditionFalse, reasonCustomLogoInvalid, "custom logo config map does not exist or has error") |
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.
While I see these in the conditions array programmatically, the oc get console.operator.openshift.io cluster -o yaml status.conditions does not show them
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.
Aborted at your call point, before a sync of status.
|
So I pulled this branch, built and deployed the operator. Then I did the following: # create a configmap with a logo
oc create configmap my-logo-file --from-file ~/Desktop/fake-logo.png -n openshift-config
# update the operator to use it
oc apply -f console.operator.with.my-logo-file.yamlMy operator config file looks like this: apiVersion: operator.openshift.io/v1
kind: Console
metadata:
name: cluster
spec:
customization:
customProductName: My Super Fancy Cluster
customLogoFile:
name: my-logo-file
key: fake-logo.png
I should only have 1 configmap, just the most recent.
apiVersion: operator.openshift.io/v1
kind: Console
metadata:
name: cluster
spec:
managementState: Managed
Recommendations from the above:
|
pkg/console/operator/operator.go
Outdated
| // add syncing for the custom logo config map | ||
| if logoName != "" { | ||
| err := c.resourceSyncer.SyncConfigMap( | ||
| resourcesynccontroller.ResourceLocation{Namespace: api.OpenShiftConsoleNamespace, Name: logoName}, |
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.
oc apply -f
apiVersion: operator.openshift.io/v1
kind: Console
metadata:
name: cluster
spec:
customization:
customProductName: Muh Clusta
customLogoFile:
name: service-ca # also bad things will happen.
key: fake-logo.png|
/hold Until bugs addressed. |
|
@zherman0: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. DetailsInstructions 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. |
|
@zherman0: PR needs rebase. DetailsInstructions 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. |
Add custom product name and logo to the config map and update unit/e2e tests.
For testing:
Creating config map with image (image needs to be less than 1MB)
oc create configmap myconfig --from-file=/mypic.jpg -n openshift-configCreating operator config:
Update Operator Config:
oc apply -f custom.yamlVerify Changes in Deployment:
oc get deployment console -n openshift-console -o yamlIf testing this locally before merge, you will need to make sure console code is the latest along with the console-operator code.
Additionally, you will need to manually run the
oc apply -f manifests/03-rbac-role-ns-openshift-config.yamlandoc apply -f manifests/04-rbac-rolebinding.yaml