Git Product home page Git Product logo

Comments (7)

msuozzo avatar msuozzo commented on May 7, 2024

Hey thanks for reaching out.

tl;dr

  1. You do need the trailing slash in the SyncBaseURL config.
  2. What do you see in the App Engine logs (link) when you attempt to sync and get the 404? Is there a request? If so, what is the URL reported?
  3. Can you successfully curl https://<my-app>.appspot.com/api/santa/ack?

Why a trailing slash?

This is the line in Santa that generates the URL of the first stage in the sync process with the SyncBaseURL value. If your eyes can take reading ObjectiveC, the function it's calling is NSURL's URLWithString:relativeToURL whose documentation can be found here. Strategically far away from the baseURL argument documentation, you'll find the description "construct a URL...by providing the folder’s URL as the base path (with a trailing slash)...".

Request resolution logic

First, as you may have seen in the curl response, the 302 redirect is sending you to a login page. This means that the App Engine config requires that request to be from an authenticated google user.

santa-api shouldn't require this type of authentication since Santa clients won't have google account credentials.

But it might be helpful to step back and go through the logic Upvote uses to resolve e.g. a santa_api request:

  • check dispatch.yaml for the module to have handle the request (here)
    • if the requested URL contains "/api/santa_api/", handle the request with santa-api
  • check the action to take in santa_api.yaml (here)
    • require an HTTPS connection (secure: always)
    • don't require auth (implicit login: optional)
    • use upvote.gae.modules.santa_api.main.app to handle the request
  • check the webapp2 route configurations for a matched handler (here)
    • if a route is matched, call that handler
    • if no route is matched, return a 404

If the trailing slash isn't provided in SyncBaseURL, the URL pattern won't match "/api/santa/" so it will be routed to the default module which requires authentication and you will get a 302. If a URL that isn't valid in santa_api (like "/api/santa" itself), the webapp2 app won't match any routes and the request will fall through and return a 404.

I'm not exactly sure why you're getting 404 in your santactl sync but the App Engine logs should be able to give some clues and if that doesn't work, you can check the system logs on the mac client.

Regardless, let me know if you make any progress or figure out the issue and do feel free to report any other deployment issues you run into. Good luck :)

from upvote_py2.

thehilll avatar thehilll commented on May 7, 2024

Thanks a lot for such a full explanation. I've put the setting back to include the trailing slash (good to know that isn't a variable to worry about), and when I do that (and get the 404) I do feel entries in the App Engine logs:

The URL is /api/santa/preflight/<machine-sn> and I am using machine SN as MachineID in the santa config.

When I look at that error the back trace is:

The resource could not be found. (/base/data/home/apps/d~<my-app>/santa-api:auto.409459141396563161/upvote/gae/shared/common/handlers.py:186)
Traceback (most recent call last):
  File "/base/alloc/tmpfs/dynamic_runtimes/python27/c5586dbb532f7e5f_unzipped/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1505, in __call__
    rv = self.router.dispatch(request, response)
  File "/base/alloc/tmpfs/dynamic_runtimes/python27/c5586dbb532f7e5f_unzipped/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1240, in default_dispatcher
    route, args, kwargs = rv = self.match(request)
  File "/base/alloc/tmpfs/dynamic_runtimes/python27/c5586dbb532f7e5f_unzipped/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1189, in default_matcher
    raise exc.HTTPNotFound()
HTTPNotFound: The resource could not be found.

Also, I can reach:

curl https://<my-app>.appspot.com/api/santa/ack
ACK (santa-api)

Thanks again.

from upvote_py2.

russellhancox avatar russellhancox commented on May 7, 2024

I believe this is due to the MachineID you're using not being a valid UUID. The routes in the santa-api require the machine identifier to match a UUID regex.

As Santa's default machine IDs are the hardware UUID, the expectation that the identifiers be a UUID makes sense but Santa allows this to be anything an administrator wishes so it probably makes sense to drop the requirement that the identifier be a UUID, or at least make it configurable.

from upvote_py2.

thehilll avatar thehilll commented on May 7, 2024

Thank you. That is is definitely part of my problem. Also, the regex requires uppercase it seems (I generated a UUID with python's uuid.uuid4() which gave me lowercase, but that regex clearly only includes A-F for the letters).

I'm now hitting:

Unable to determine the current environment (/base/data/home/apps/d~/santa-api:auto.409459141396563161/upvote/gae/shared/common/settings_utils.py:87)

I can't tell if this is an Upvote environment or something related to App Engine.

from upvote_py2.

thehilll avatar thehilll commented on May 7, 2024

Just a comment for anyone following this, the right thing to do to get the UUID on a Mac is system_profiler SPHardwareDataType which does output the UUID in upper case.

from upvote_py2.

russellhancox avatar russellhancox commented on May 7, 2024

You can also just not set the MachineID settings in Santa - it'll use the machine UUID by default.

from upvote_py2.

thehilll avatar thehilll commented on May 7, 2024

Thanks, that makes deployment much easier.

The remaining issue was my misunderstanding the instructions when they say

After that configuration is complete, all that's necessary is to redeploy the app

I read that as applying to Bit9 (which we don't use), not any configuration. Once I did that the sync works.

from upvote_py2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.