Skip to content
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

Improve the test to decide which search results to serve #47128

Merged
merged 5 commits into from
Jul 29, 2024

Conversation

cjyabraham
Copy link
Contributor

@cjyabraham cjyabraham commented Jul 10, 2024

This addresses one of the issues that came from #47108

In deciding what search results to serve, we had previously been checking to see whether a user was in China using the ipinfo.io service. The problem, however, is that many people who are not in China are running privacy software that blocks this service and so they were incorrectly being deemed to be in China. This means that a lot of people would be getting PageFind search results when it would have been fine to serve them the Google search results.

Additionally, there are people in China who are using VPNs so would be able to access Google search results but our system was instead serving them the inferior PageFind results.

This PR moves this test away from a geolocation of whether someone is in China and focuses instead on whether the user's browser can access Google. This is the only thing that matters anyway. If they can access Google, then they get the Google search results, otherwise it falls back to Pagefind search results.

For now, people can check the dev console to see debug output of either "Google is blocked" or "Google is NOT blocked" which will make testing easier. Before merge, we can remove these logs. After the first page load, a cookie is set and it will no longer perform the test, but you can try it again in an incognito window or by deleting the can_google cookie using dev tools.

It would be good to test this thoroughly with people inside and outside of China and have some people running privacy blocking plugins in their browsers. In all cases it should correctly determine whether you can access Google and will then serve the appropriate search results.

Signed-off-by: Chris Abraham <cjyabraham@gmail.com>
@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. sig/docs Categorizes an issue or PR as relevant to SIG Docs. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 10, 2024
@cjyabraham cjyabraham changed the title Improve China test Improve China test for search Jul 10, 2024
Copy link

netlify bot commented Jul 10, 2024

Pull request preview available for checking

Built without sensitive environment variables

Name Link
🔨 Latest commit 4c79d66
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-io-main-staging/deploys/669a00bc13e1390008b80688
😎 Deploy Preview https://deploy-preview-47128--kubernetes-io-main-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Signed-off-by: Chris Abraham <cjyabraham@gmail.com>
@cjyabraham cjyabraham changed the title Improve China test for search Improve Search results determination Jul 10, 2024
@cjyabraham cjyabraham changed the title Improve Search results determination Improve the test to decide which search results to serve Jul 10, 2024
@cjyabraham cjyabraham marked this pull request as ready for review July 10, 2024 07:33
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 10, 2024
Signed-off-by: Chris Abraham <cjyabraham@gmail.com>
Signed-off-by: Chris Abraham <cjyabraham@gmail.com>
@nate-double-u
Copy link
Contributor

/area localization
/area web-development

@k8s-ci-robot k8s-ci-robot added area/localization General issues or PRs related to localization area/web-development Issues or PRs related to the kubernetes.io's infrastructure, design, or build processes labels Jul 10, 2024
Copy link
Contributor

@nate-double-u nate-double-u left a comment

Choose a reason for hiding this comment

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

Comment edited out as a potential red herring.
-- Nate

@nate-double-u
Copy link
Contributor

nate-double-u commented Jul 11, 2024

I should clarify: I think the proposed method in this PR will work @cjyabraham, and we should test and review it. I was looking at other alternatives that don't try to load anything from Google at all, but we may not need to go that far.

static/js/search.js Outdated Show resolved Hide resolved
@sftim sftim requested a review from nate-double-u July 18, 2024 23:16
Signed-off-by: Chris Abraham <cjyabraham@gmail.com>
Copy link
Contributor

@nate-double-u nate-double-u left a comment

Choose a reason for hiding this comment

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

This update feels pretty performant. It's a touch slow (like 1.5 to 2 counts) when I set the can_google cookie to false, but afterward, on subsequent reloads, PageFind loads as quickly as a regular search does. I haven't been able to hit the full 5-second timeout (which, if it were common, would be too long to wait).

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 22, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 6a3a2c8766e44e70480ac3f3c3f514b023fbe995

@katcosgrove
Copy link
Contributor

Tested in Chrome with and without uBlock Origin on. Same results as Nate, only about a 1-1.5 second wait on Pagefind results the first time the cookie was set to false. I'm happy with the performance there.

It's lightweight and relatively performant. This feels like a good solution.

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: katcosgrove

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 29, 2024
@k8s-ci-robot k8s-ci-robot merged commit f477d1c into kubernetes:main Jul 29, 2024
6 checks passed
@cjyabraham cjyabraham deleted the cn branch July 30, 2024 01:16
@cjyabraham
Copy link
Contributor Author

I was going to remove the console.log commands before merge. They were just to help debug. If people think that's useful, I can set up another PR for that.

@sftim
Copy link
Contributor

sftim commented Jul 30, 2024

Please do send in that further PR @cjyabraham (not urgent).

@cjyabraham
Copy link
Contributor Author

Here it is: #47314

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/localization General issues or PRs related to localization area/web-development Issues or PRs related to the kubernetes.io's infrastructure, design, or build processes cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/docs Categorizes an issue or PR as relevant to SIG Docs. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants