-
Notifications
You must be signed in to change notification settings - Fork 35
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
Update the Handler when watch on SetContainerImageFromRegistry functi… #336
Update the Handler when watch on SetContainerImageFromRegistry functi… #336
Conversation
@@ -456,100 +459,95 @@ func InjectCertConfig(notebook *nbv1.Notebook, configMapName string) error { | |||
// Otherwise, it checks the last-image-selection annotation to find the image stream and fetches the image from status.dockerImageReference, | |||
// assigning it to the container.image value. | |||
func SetContainerImageFromRegistry(ctx context.Context, config *rest.Config, notebook *nbv1.Notebook, log logr.Logger) error { | |||
// Create a dynamic client |
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 did not notice this did not pass through go fmt
before.
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.
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.
Great intiative, provide some suggestion:
Thank you for this, Andriana, I'm gonna test this out today. Apart from what Jiri proposed, I have no more objections. Just some nitpicks I commented on the previous PR in case you feel make sense and could be implemented: |
Thanks, Jan. I have updated the logic based on your feedback in this comment. The code now lists the containers and performs the updates when container.name matches notebook.name. Regarding this comment, I have applied logs where applicable. |
/test odh-notebook-controller-unit |
components/odh-notebook-controller/controllers/notebook_webhook.go
Outdated
Show resolved
Hide resolved
log.Info("Internal registry found. Will pickup the default value from image field.") | ||
return nil | ||
} else { | ||
log.Info("No Internal registry found, pick up imageHash from status.tag.dockerImageReference") |
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.
Also, I see this message twice in my attempts now. At the beginning and at the end of the notebook spin up 🤔
{"level":"info","ts":"2024-05-30T12:54:28Z","logger":"controllers.Notebook","msg":"Injecting trusted-ca volume and environment variables","notebook":"older-tag","namespace":"test"}
{"level":"info","ts":"2024-05-30T12:54:28Z","logger":"controllers.Notebook","msg":"No Internal registry found, pick up imageHash from status.tag.dockerImageReference","notebook":"older-tag","namespace":"test"}
{"level":"info","ts":"2024-05-30T12:54:28Z","logger":"controllers.Notebook","msg":"Creating Network Policy","name":"older-tag-ctrl-np"}
{"level":"info","ts":"2024-05-30T12:54:28Z","logger":"controllers.Notebook","msg":"Creating Network Policy","name":"older-tag-oauth-np"}
{"level":"info","ts":"2024-05-30T12:54:28Z","logger":"controllers.Notebook","msg":"Creating Service Account","notebook":"older-tag","namespace":"test"}
{"level":"info","ts":"2024-05-30T12:54:28Z","logger":"controllers.Notebook","msg":"Creating OAuth Service","notebook":"older-tag","namespace":"test"}
{"level":"info","ts":"2024-05-30T12:54:28Z","logger":"controllers.Notebook","msg":"Creating OAuth Secret","notebook":"older-tag","namespace":"test"}
{"level":"info","ts":"2024-05-30T12:54:28Z","logger":"controllers.Notebook","msg":"Creating Route","notebook":"older-tag","namespace":"test"}
{"level":"info","ts":"2024-05-30T12:54:28Z","logger":"controllers.Notebook","msg":"Removing reconciliation lock","notebook":"older-tag","namespace":"test"}
{"level":"info","ts":"2024-05-30T12:54:34Z","logger":"controllers.Notebook","msg":"No Internal registry found, pick up imageHash from status.tag.dockerImageReference","notebook":"older-tag","namespace":"test"}
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 that is generated by the admissionv1 (L258) one when it creates the notebook and one when the notebook is been updated.
To understand this a bit added some debug prints fmt.Println("2. ", container.Image)
and i saw the following:
{"level":"info","ts":"2024-05-30T16:49:09Z","msg":"Starting workers","controller":"notebook","controllerGroup":"kubeflow.org","controllerKind":"Notebook","worker count":1}
{"level":"info","ts":"2024-05-30T16:49:27Z","logger":"controllers.Notebook","msg":"odh-trusted-ca-bundle ConfigMap is not present, not starting mounting process.","notebook":"q7","namespace":"test"}
{"level":"info","ts":"2024-05-30T16:49:27Z","logger":"controllers.Notebook","msg":"Entering SetContainerImageFromRegistry","notebook":"q7","namespace":"test"}
2. :2024.1
{"level":"info","ts":"2024-05-30T16:49:27Z","logger":"controllers.Notebook","msg":"No internal registry found, let's pick up image reference from relevant ImageStream 'status.tags[].tag.dockerImageReference'","notebook":"q7","namespace":"test"}
{"level":"info","ts":"2024-05-30T16:49:27Z","logger":"controllers.Notebook","msg":"Exiting SetContainerImageFromRegistry","notebook":"q7","namespace":"test"}
{"level":"info","ts":"2024-05-30T16:49:27Z","logger":"controllers.Notebook","msg":"Creating Network Policy","name":"q7-ctrl-np"}
{"level":"info","ts":"2024-05-30T16:49:27Z","logger":"controllers.Notebook","msg":"Creating Network Policy","name":"q7-oauth-np"}
{"level":"info","ts":"2024-05-30T16:49:27Z","logger":"controllers.Notebook","msg":"Creating Service Account","notebook":"q7","namespace":"test"}
{"level":"info","ts":"2024-05-30T16:49:27Z","logger":"controllers.Notebook","msg":"Creating OAuth Service","notebook":"q7","namespace":"test"}
{"level":"info","ts":"2024-05-30T16:49:27Z","logger":"controllers.Notebook","msg":"Creating OAuth Secret","notebook":"q7","namespace":"test"}
{"level":"info","ts":"2024-05-30T16:49:27Z","logger":"controllers.Notebook","msg":"Creating Route","notebook":"q7","namespace":"test"}
{"level":"info","ts":"2024-05-30T16:49:27Z","logger":"controllers.Notebook","msg":"Removing reconciliation lock","notebook":"q7","namespace":"test"}
{"level":"info","ts":"2024-05-30T16:49:28Z","logger":"controllers.Notebook","msg":"Entering SetContainerImageFromRegistry","notebook":"q7","namespace":"test"}
2. quay.io/opendatahub/workbench-images@sha256:61fa79b91af6dc2276d7d8d799f8af36edc8e256db23a808362d9c8c4c45bb51
{"level":"info","ts":"2024-05-30T16:49:28Z","logger":"controllers.Notebook","msg":"Exiting SetContainerImageFromRegistry","notebook":"q7","namespace":"test"}
However, when you EDIT the notebook to for example ds:2023.2 the received debug message always 2. :2023.1
which means that when on UPDATE mode it get the default container.Image value that comes from the dashboard.
So, maybe the idea that i had to use something like this to display or not the log info maybe can not be applied if we use the admission update functionality
// If the image value is invalid means that we don't have internal registry picked up by default from dashboard
invalidImage := regexp.MustCompile(`^:\d+\.\d+$`)
if invalidImage.MatchString(container.Image) {
log.Info("No internal registry found, let's pick up image reference from relevant ImageStream 'status.tags[].tag.dockerImageReference'")
}
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 don't have a good solution as for now Jan for this, I suggest to track it on a jira issue to implemented later on as enhancement. I really afraid to touch it right now 🤣
components/odh-notebook-controller/controllers/notebook_webhook.go
Outdated
Show resolved
Hide resolved
components/odh-notebook-controller/controllers/notebook_webhook.go
Outdated
Show resolved
Hide resolved
6109c51
to
76ff751
Compare
This comment was marked as duplicate.
This comment was marked as duplicate.
…on to check also for update Add test for checking the update of the notebook
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.
/lgtm
/approve
Based on everyone review and discussion
this seems apt for the merge.
Thanks for all the work 💯
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: harshad16 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 |
92e8404
into
opendatahub-io:v1.7-branch
/cherrypick stable |
@harshad16: #336 failed to apply on top of branch "stable":
In response to this:
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-sigs/prow repository. |
…on to check also for update
Related to: https://issues.redhat.com/browse/RHOAIENG-3411
Description
How Has This Been Tested?
Replace odh-nbc-controller image with:
quay.io/opendatahub/odh-notebook-controller:pr-336
Dashboard changes for the
!Deleted
label are onquay.io/opendatahub/odh-dashboard:pr-2867
Merge criteria: