Skip to content

Fix mgmt-framework rest server startup script#8260

Closed
sachinholla wants to merge 1 commit intosonic-net:masterfrom
sachinholla:rest_startup
Closed

Fix mgmt-framework rest server startup script#8260
sachinholla wants to merge 1 commit intosonic-net:masterfrom
sachinholla:rest_startup

Conversation

@sachinholla
Copy link
Copy Markdown
Contributor

Why I did it

Mgmt-framework REST startup script is broken after PR #4937. This PR misspells the table name as "RESET_SERVER"; hence the user defined settings from REST_SERVER table are never loaded. REST server always comes up with default settings.
Also the startup script rest-server.sh does not use the jq -r commands correctly. With -r option, it prints a null value when the field requested does not exists. Startup script would have assigned a "null" value for all non-configured parameters and would have failed (if it had spelt the table name correctly in mgmt_vars.j2).

How I did it

Fixed mgmt_vars.j2 to load correct db entry and rest-server.sh to handle optional fields correctly.

Also introduced a new jinja filter "json" in sonic-cfggen, which formats the value using json.dumps() function. The mgmt_vars.j2 template uses this filter to transform db values into a syntactically correct json.

How to verify it

Verify REST server startup and a GET operation with following configurations:

  • No REST_SERVER and x509 table entries
  • With client_auth config in REST_SERVER entry
  • With log_level config in REST_SERVER entry
  • With certificate configs in REST_SERVER entry
  • WIth all configs in REST_SERVER entry
  • With certificate configs in x509 entry
  • With client_auth config in REST_SERVER entry and certificate configs in x509 entry

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106

Description for the changelog

PR sonic-net#4937 broke rest server startup -- server does not load user
defined configs from db and always comes up with default config.
Fixed mgmt_vars.j2 to load correct db entry and rest-server.sh to
handle optional fields correctly.

Also introduced a new jinja filter 'json' in sonic-cfggen. It formats
the value using json.dumps() function. mgmt_vars.j2 tempalte uses this
filter to transform db values into a syntactically correct json.
@sachinholla sachinholla requested a review from lguohan as a code owner July 26, 2021 16:00
@sachinholla sachinholla requested a review from a team as a code owner June 10, 2022 02:01
@sachinholla sachinholla closed this May 8, 2023
@sachinholla sachinholla deleted the rest_startup branch May 8, 2023 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant