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

Spring Boot 3 #1623

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open

Spring Boot 3 #1623

wants to merge 18 commits into from

Conversation

shubham1g5
Copy link
Contributor

@shubham1g5 shubham1g5 commented Sep 4, 2024

Technical Summary

JIRA

Update to Spring Boot 3

Safety Assurance

Safety story

  • Relying on automated unit tests and staging scripts
  • Will keep on staging for a week or so to catch anything unexpected

QA Plan

https://dimagi.atlassian.net/browse/QA-7246

Special deploy instructions

  • This PR can be deployed after merge with no further considerations.

Rollback instructions

  • This PR can be reverted after deploy with no further considerations.

Review

  • The set of people pinged as reviewers is appropriate for the level of risk of the change.

@shubham1g5 shubham1g5 changed the title Sprint Boot 3 Spring Boot 3 Sep 15, 2024
Copy link

codecov bot commented Nov 2, 2024

Codecov Report

Attention: Patch coverage is 90.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 70.27%. Comparing base (bb7cdbb) to head (b5fa164).

Files with missing lines Patch % Lines
...yer/application/GlobalDefaultExceptionHandler.java 0.00% 1 Missing ⚠️
.../org/commcare/formplayer/web/client/WebClient.java 50.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1623      +/-   ##
============================================
+ Coverage     70.22%   70.27%   +0.04%     
- Complexity     2007     2010       +3     
============================================
  Files           254      254              
  Lines          7902     7908       +6     
  Branches        745      745              
============================================
+ Hits           5549     5557       +8     
  Misses         2070     2070              
+ Partials        283      281       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +79 to +82
// By setting the csrfRequestAttributeName to null, the CsrfToken must first be loaded to determine what
// attribute name to use. This causes the CsrfToken to be loaded on every request.
CsrfTokenRequestAttributeHandler requestHandler = new CsrfTokenRequestAttributeHandler();
requestHandler.setCsrfRequestAttributeName(null);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Noting that this change was in response to a change made in Spring 3 that defers the csrf tokens lookup until needed optimising reads of HttpSession. Although that breaks all requests to FP as 403 error due to csrf token coming as undefined in request headers. In response, I first implemented the opt out steps mentioned here, that didn't solve the problem completely (Half the times requests were with csrf undefined and got errored with 403 while on trying again the csrf was there in request payloads, but I could not get to the bottom of why it was happening). Ultimately I decided to completely opt out of deferred tokens behaviour by follow the steps listed here.

@shubham1g5 shubham1g5 marked this pull request as ready for review November 2, 2024 14:03
@@ -26,7 +26,6 @@ management.health.diskspace.threshold=1073742000

# metrics
management.statsd.metrics.export.flavor=datadog
management.metrics.web.server.request.autotime.enabled=false
Copy link
Contributor

Choose a reason for hiding this comment

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

the migration guide mentions "Should be applied at the ObservationRegistry level.". Do we need to do that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you have a reference to this ? I just saw that it's been removed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

More info here: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Migration-Guide#micrometer-and-metrics-changes and here: spring-projects/spring-boot#41745

Overall I think this is OK though I don't recall why we turned that metric off.

Copy link
Contributor

@snopoke snopoke left a comment

Choose a reason for hiding this comment

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

Overall this looks good to me.

@@ -26,7 +26,6 @@ management.health.diskspace.threshold=1073742000

# metrics
management.statsd.metrics.export.flavor=datadog
management.metrics.web.server.request.autotime.enabled=false
Copy link
Contributor

Choose a reason for hiding this comment

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

More info here: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Migration-Guide#micrometer-and-metrics-changes and here: spring-projects/spring-boot#41745

Overall I think this is OK though I don't recall why we turned that metric off.

formSessionRepo.saveAndFlush(loaded);
assertThat(loaded.getDateCreated()).isEqualTo(dateCreated);
assertThat(loaded.getVersion()).isEqualTo(2);
assertThat(loaded.getVersion()).isEqualTo(1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain these changes. They don't seem related to the Spring upgrade.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could not really find the related change documentation for this in hibernate but after upgrading to SB 3, the version doesn't increment unless you make a change to the object. My guess is that the change is caused by shifting to the Jakarta persistence apis from javax but I don't really have a supportive reference here that can explain this change.

@shubham1g5 shubham1g5 requested a review from Jtang-1 November 13, 2024 11:04
@shubham1g5
Copy link
Contributor Author

This has been on staging for a week and I have not seen anything related, as such I am planning to merge this after tomorrow's deploy so that it will get to prod in next week's deploy.

@snopoke
Copy link
Contributor

snopoke commented Nov 13, 2024

This has been on staging for a week and I have not seen anything related, as such I am planning to merge this after tomorrow's deploy so that it will get to prod in next week's deploy.

Has someone tested SMS forms?

@shubham1g5
Copy link
Contributor Author

Has someone tested SMS forms?

Not really, are you concerned because of the security changes ?

@snopoke
Copy link
Contributor

snopoke commented Nov 13, 2024

Has someone tested SMS forms?

Not really, are you concerned because of the security changes ?

yes, that's one place where auth differs from webapps

@shubham1g5
Copy link
Contributor Author

Great to know, I will make sure we get that tested. Thanks.

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.

3 participants