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

Write deployment context in init container #2871

Merged
merged 11 commits into from
Dec 11, 2024
Merged

Conversation

kate-osborn
Copy link
Contributor

@kate-osborn kate-osborn commented Dec 6, 2024

Proposed changes

Problems:

  • When running with N+, the first usage report does not contain the deployment context. The deployment context is needed in order to associate the instance with NGF.
  • When collecting the info for the deployment context, it is possible to fail. In this case we send a report to N1 without the deployment context.
  • The installation ID is the deployment ID, but it should be the Pod ID.

Solutions:

  • When running with N+, write the deployment context to the shared volume mount in the init container.
  • Use the Pod UID instead of the deployment UID as the installation ID
  • Always set the static values of the deployment context in the nginx config. Static values include the integration and installation IDs.

Testing: Verified that all usage reports contain the deployment context.

Closes #2863

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation
  • I have rebased my branch onto main
  • I will ensure my PR is targeting the main branch and pulling from my branch from my own fork

Release notes

If this PR introduces a change that affects users and needs to be mentioned in the release notes,
please add a brief note that summarizes the change.

None

@kate-osborn kate-osborn requested a review from a team as a code owner December 6, 2024 00:07
@github-actions github-actions bot added bug Something isn't working helm-chart Relates to helm chart labels Dec 6, 2024
Copy link

codecov bot commented Dec 6, 2024

Codecov Report

Attention: Patch coverage is 60.39604% with 80 lines in your changes missing coverage. Please review.

Project coverage is 89.71%. Comparing base (58801be) to head (a8d01cf).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cmd/gateway/commands.go 50.57% 43 Missing ⚠️
internal/mode/static/manager.go 0.00% 19 Missing ⚠️
cmd/gateway/initialize.go 86.66% 4 Missing and 2 partials ⚠️
internal/mode/static/handler.go 50.00% 2 Missing and 2 partials ⚠️
internal/mode/static/nginx/file/os_filemanager.go 0.00% 4 Missing ⚠️
internal/mode/static/nginx/config/generator.go 75.00% 2 Missing and 1 partial ⚠️
cmd/gateway/main.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2871      +/-   ##
==========================================
- Coverage   89.86%   89.71%   -0.16%     
==========================================
  Files         107      109       +2     
  Lines       10997    11091      +94     
  Branches       50       50              
==========================================
+ Hits         9883     9950      +67     
- Misses       1054     1082      +28     
+ Partials       60       59       -1     

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

@kate-osborn kate-osborn marked this pull request as draft December 6, 2024 00:16
@kate-osborn
Copy link
Contributor Author

Marking as draft cause I need to add some more unit tests to initialize.go and commands.go. But please feel free to review

cmd/gateway/commands.go Outdated Show resolved Hide resolved
cmd/gateway/commands.go Outdated Show resolved Hide resolved
@kate-osborn kate-osborn marked this pull request as ready for review December 6, 2024 16:10
@kate-osborn kate-osborn marked this pull request as draft December 6, 2024 17:41
@kate-osborn
Copy link
Contributor Author

Marking as a draft again to make the following changes:

  • create a default deployment context with just the integration field set
  • change the installation ID to the pod ID

cmd/gateway/initialize.go Outdated Show resolved Hide resolved
internal/mode/static/handler.go Show resolved Hide resolved
internal/mode/static/handler.go Show resolved Hide resolved
internal/mode/static/licensing/collector.go Show resolved Hide resolved
internal/mode/static/licensing/collector.go Show resolved Hide resolved
internal/mode/static/licensing/collector_test.go Outdated Show resolved Hide resolved
@kate-osborn kate-osborn marked this pull request as ready for review December 6, 2024 21:58
cmd/gateway/initialize.go Show resolved Hide resolved
internal/mode/static/licensing/collector.go Outdated Show resolved Hide resolved
cmd/gateway/commands_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@bjee19 bjee19 left a comment

Choose a reason for hiding this comment

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

lgtm after that above comment change! thanks for handling this! 🚀 🌔

@kate-osborn kate-osborn force-pushed the fix/set-deploy-ctx-on-init branch from e51b2dc to 00e8a48 Compare December 11, 2024 17:33
@kate-osborn kate-osborn requested a review from sjberman December 11, 2024 18:45
@kate-osborn
Copy link
Contributor Author

@sjberman re-requested your review since I made a small change: a8d01cf

I realized we no longer need to pod nsname in the init container

@kate-osborn kate-osborn merged commit 245b516 into main Dec 11, 2024
46 of 47 checks passed
@kate-osborn kate-osborn deleted the fix/set-deploy-ctx-on-init branch December 11, 2024 19:57
kate-osborn added a commit to kate-osborn/nginx-gateway-fabric that referenced this pull request Dec 13, 2024
Problems:
* When running with N+, the first usage report does not contain the deployment context.
The deployment context is needed in order to associate the instance with NGF.
* When collecting the info for the deployment context, it is possible to fail.
In this case we send a report to N1 without the deployment context.
* The installation ID is the deployment ID, but it should be the Pod ID.

Solutions:
* When running with N+, write the deployment context to the shared volume mount in the init container.
* Use the Pod UID instead of the deployment UID as the installation ID
* Always set the static values of the deployment context in the nginx config.
Static values include the integration and installation IDs.
kate-osborn added a commit that referenced this pull request Dec 13, 2024
Write deployment context in init container (#2871)

Problems:
* When running with N+, the first usage report does not contain the deployment context.
The deployment context is needed in order to associate the instance with NGF.
* When collecting the info for the deployment context, it is possible to fail.
In this case we send a report to N1 without the deployment context.
* The installation ID is the deployment ID, but it should be the Pod ID.

Solutions:
* When running with N+, write the deployment context to the shared volume mount in the init container.
* Use the Pod UID instead of the deployment UID as the installation ID
* Always set the static values of the deployment context in the nginx config.
Static values include the integration and installation IDs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working helm-chart Relates to helm chart
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix N+ Reporting
3 participants