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

feat: consume the new licenses v3 structure. #6341

Merged
merged 38 commits into from
Nov 11, 2024
Merged

Conversation

vikrantgupta25
Copy link
Collaborator

@vikrantgupta25 vikrantgupta25 commented Nov 1, 2024

Summary

  • added two new endpoints for applying the license from zeus and refreshing the license from zeus post any update to the plan of the license or validity etc.
  • integrate the new license v3 structure in sync with zeus license entity.
  • deprecate the activation step from the apply license process as it was not required
  • added a new table for the new license v3 in the sqlite db
  • added the new endpoint for frontend to request list of licenses from query service.
  • updated the existing list licenses call to be backwards compatible
  • added a new flag to toggle the licenses structure
  • added detailed test cases for the factory function for licenses

Related Issues / PR's

contributes to - https://github.com/SigNoz/platform-pod/issues/304

Screenshots

NA

Affected Areas and Manually Tested Areas


Important

Introduces a new license v3 structure with endpoints, database changes, and feature toggles, ensuring backward compatibility and adding comprehensive tests.

  • Endpoints:
    • Added /api/v3/licenses endpoints in api.go for listing, applying, and refreshing licenses.
  • Database:
    • Added licenses_v3 table in sqlite/init.go for storing new license structure.
  • License Management:
    • Introduced LicenseV3 model in model/license.go.
    • Updated Manager in license/manager.go to handle LicenseV3.
    • Added GetLicensesV3, InsertLicenseV3, and UpdateLicenseV3 in license/db.go.
  • Feature Toggle:
    • Added UseLicensesV3 flag in api.go and main.go to toggle between license structures.
  • Testing:
    • Added test cases for LicenseV3 in model/license_test.go.

This description was created by Ellipsis for e6fa8c6. It will automatically update as commits are pushed.

Copy link

github-actions bot commented Nov 1, 2024

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

@github-actions github-actions bot added the enhancement New feature or request label Nov 1, 2024
@vikrantgupta25
Copy link
Collaborator Author

@vikrantgupta25 vikrantgupta25 changed the title feat: setup for licenses v3 integration feat: consume the licenses v3 structure. Nov 1, 2024
Copy link

github-actions bot commented Nov 1, 2024

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Copy link

github-actions bot commented Nov 1, 2024

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

@vikrantgupta25
Copy link
Collaborator Author

contributes to - https://github.com/SigNoz/platform-pod/issues/326 ( v3 deprecation of activations from query service )

Copy link

github-actions bot commented Nov 3, 2024

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

@vikrantgupta25 vikrantgupta25 marked this pull request as ready for review November 4, 2024 08:02
Copy link

github-actions bot commented Nov 4, 2024

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Reviewed everything up to 7882010 in 1 minute and 13 seconds

More details
  • Looked at 661 lines of code in 10 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 drafted comments based on config settings.
1. ee/query-service/integrations/signozio/signozio.go:134
  • Draft comment:
    Move defer response.Body.Close() immediately after checking for errors to ensure the body is closed in all cases.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The defer response.Body.Close() should be placed immediately after checking for errors to ensure the body is closed in all cases.
2. ee/query-service/license/db.go:285
  • Draft comment:
    The error message should be updated to reflect the correct operation:
		return fmt.Errorf("update license failed: license marshal error")
  • Reason this comment was not posted:
    Marked as duplicate.
3. ee/query-service/app/api/api.go:173
  • Draft comment:
    Avoid using the component/index.tsx file structure approach, as it makes it difficult to debug and find components using global search tools like VS Code.
  • Reason this comment was not posted:
    Comment was on unchanged code.
4. ee/query-service/app/api/license.go:95
  • Draft comment:
    applyLicenseV3 is a duplicate of applyLicense. Consider refactoring to handle both versions in a single function.

  • function applyLicense (license.go)

  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The functions are similar in structure but handle different types and methods, which suggests they are not duplicates. The comment may not be valid as the functions serve different purposes despite their structural similarity.
    The functions could potentially be refactored to share common logic, but the comment's suggestion of duplication might be misleading due to the different types and methods involved.
    While the functions are not duplicates, there might be room for refactoring shared logic. However, the comment's suggestion of duplication is not accurate.
    The comment should be deleted as it incorrectly identifies the functions as duplicates. They handle different types and methods, indicating distinct purposes.

Workflow ID: wflow_4mGfkKPlUAG29pra


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

ee/query-service/app/api/license.go Outdated Show resolved Hide resolved
ee/query-service/license/db.go Outdated Show resolved Hide resolved
Copy link

github-actions bot commented Nov 4, 2024

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 15d10a0 in 36 seconds

More details
  • Looked at 98 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. ee/query-service/license/manager.go:345
  • Draft comment:
    Do not add non-ClickHouse related functions to the ClickHouseReader interface. Use the DAO in the telemetry instance to access such information instead.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_pOrMMV4C438f5iCV


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

github-actions bot commented Nov 4, 2024

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 4535e15 in 31 seconds

More details
  • Looked at 15 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. ee/query-service/license/db.go:298
  • Draft comment:
    The error message should reflect the update operation:
		zap.L().Error("error in updating license data: ", zap.Error(err))
  • Reason this comment was not posted:
    Comment looked like it was already resolved.
2. ee/query-service/license/db.go:298
  • Draft comment:
    The error message should be consistent with the operation being performed. Consider changing it to reflect the update operation.
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_gNGa4hb60xifQxml


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

github-actions bot commented Nov 6, 2024

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Copy link

github-actions bot commented Nov 6, 2024

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Incremental review on a745c72 in 1 minute and 9 seconds

More details
  • Looked at 143 lines of code in 5 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. ee/query-service/integrations/signozio/signozio.go:154
  • Draft comment:
    The error message should use 'unmarshal' instead of 'marshal' to accurately describe the operation being performed.
  • Reason this comment was not posted:
    Comment was on unchanged code.
2. ee/query-service/integrations/signozio/signozio.go:139
  • Draft comment:
    Avoid using inline styles in React components. Use external stylesheets, CSS classes, or styled components instead. This is applicable in other parts of the code as well.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_T1TDedx2tPs2KXbd


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

github-actions bot commented Nov 6, 2024

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on d171861 in 51 seconds

More details
  • Looked at 116 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. ee/query-service/model/license.go:189
  • Draft comment:
    Ensure consistent handling of validFrom and validUntil by checking the type and defaulting correctly. Consider using a helper function to avoid repetition.
  • Reason this comment was not posted:
    Comment did not seem useful.
2. ee/query-service/model/license.go:253
  • Draft comment:
    Ensure consistent handling of validFrom and validUntil by checking the type and defaulting correctly. Consider using a helper function to avoid repetition.
  • Reason this comment was not posted:
    Marked as duplicate.
3. ee/query-service/app/api/license.go:72
  • Draft comment:
    Avoid using the component/index.tsx file structure approach, as it makes it difficult to debug and find components using global search tools like VS Code.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_Yr99eeBRxvETzkvc


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on e6cacce in 1 minute and 4 seconds

More details
  • Looked at 346 lines of code in 6 files
  • Skipped 0 files when reviewing.
  • Skipped posting 5 drafted comments based on config settings.
1. ee/query-service/model/license_test.go:25
  • Draft comment:
    The error message for invalid plan data should match the one in NewLicenseV3 function. Ensure consistency in error messages.
  • Reason this comment was not posted:
    Comment did not seem useful.
2. ee/query-service/model/license_test.go:83
  • Draft comment:
    The error message for missing license id should match the one in NewLicenseV3 function. Ensure consistency in error messages.
  • Reason this comment was not posted:
    Comment did not seem useful.
3. ee/query-service/model/license_test.go:89
  • Draft comment:
    The error message for missing license key should match the one in NewLicenseV3 function. Ensure consistency in error messages.
  • Reason this comment was not posted:
    Marked as duplicate.
4. ee/query-service/model/license_test.go:95
  • Draft comment:
    The error message for invalid string license key should match the one in NewLicenseV3 function. Ensure consistency in error messages.
  • Reason this comment was not posted:
    Marked as duplicate.
5. ee/query-service/app/api/api.go:40
  • Draft comment:
    Avoid using the component/index.tsx file structure approach, as it makes it difficult to debug and find components using global search tools like VS Code. This is applicable in other files as well.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_Qmck6yFEnafX7OKa


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on b3365e8 in 50 seconds

More details
  • Looked at 177 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 6 drafted comments based on config settings.
1. ee/query-service/app/api/license.go:73
  • Draft comment:
    Ensure that license.Data contains all necessary fields for the response, as the conversion now directly uses license.Data. This change should be verified against the expected API response structure.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The change in the convertLicenseV3ToListLicenseResponse function simplifies the conversion by directly using license.Data. This is a valid change as it aligns with the new structure of LicenseV3. However, it is important to ensure that license.Data contains all necessary fields for the response. This change should be verified against the expected API response structure.
2. ee/query-service/app/api/license.go:138
  • Draft comment:
    Ensure that render.Success is correctly implemented to handle the response as expected, as it replaces ah.Respond.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The applyLicenseV3 function now uses render.Success instead of ah.Respond. This change is consistent with the new approach to response handling. However, it is important to ensure that the render.Success function is correctly implemented to handle the response as expected.
3. ee/query-service/app/api/license.go:149
  • Draft comment:
    Ensure that render.Success is correctly implemented to handle the response as expected, as it replaces ah.Respond.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The refreshLicensesV3 function now uses render.Success instead of ah.Respond. This change is consistent with the new approach to response handling. However, it is important to ensure that the render.Success function is correctly implemented to handle the response as expected.
4. ee/query-service/model/license.go:187
  • Draft comment:
    Ensure that the JSON structure for plan and features matches the expected format, and that error handling is comprehensive in NewLicenseV3.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The NewLicenseV3 function has been updated to handle plan and features data using JSON marshaling and unmarshaling. This change improves the robustness of data handling. However, it is important to ensure that the JSON structure matches the expected format and that error handling is comprehensive.
5. ee/query-service/model/license_test.go:25
  • Draft comment:
    Verify that all edge cases are covered in the test cases for NewLicenseV3, and that the test data accurately represents possible inputs.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The test case for NewLicenseV3 has been updated to reflect changes in error messages and expected behavior. This is necessary to ensure that the tests align with the new implementation. However, it is important to verify that all edge cases are covered and that the test data accurately represents possible inputs.
6. ee/query-service/app/api/license.go:138
  • Draft comment:
    Avoid using inline styles in React components. Use external stylesheets, CSS classes, or styled components instead.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_hw8BaMqwHS56g60i


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on aad8fe1 in 48 seconds

More details
  • Looked at 219 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. ee/query-service/model/license_test.go:160
  • Draft comment:
    The expected values for ValidFrom and ValidUntil should be 0 and -1 respectively, as per the logic in NewLicenseV3 function.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.
2. ee/query-service/model/license.go:194
  • Draft comment:
    Avoid using inline styles in React components. Use external stylesheets or styled components instead.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_jbOwMuswZJHvtbcP


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

1 similar comment
Copy link

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

ee/query-service/app/api/api.go Outdated Show resolved Hide resolved
ee/query-service/app/api/license.go Outdated Show resolved Hide resolved
ee/query-service/app/api/license.go Outdated Show resolved Hide resolved
ee/query-service/app/api/license.go Outdated Show resolved Hide resolved
ee/query-service/integrations/signozio/signozio.go Outdated Show resolved Hide resolved
ee/query-service/model/license.go Outdated Show resolved Hide resolved
ee/query-service/model/license.go Outdated Show resolved Hide resolved
ee/query-service/model/license.go Show resolved Hide resolved
ee/query-service/model/plans.go Outdated Show resolved Hide resolved
ee/query-service/model/plans.go Outdated Show resolved Hide resolved
Copy link

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Incremental review on 8e3509d in 1 minute and 14 seconds

More details
  • Looked at 292 lines of code in 9 files
  • Skipped 0 files when reviewing.
  • Skipped posting 5 drafted comments based on config settings.
1. ee/query-service/app/api/api.go:193
  • Draft comment:
    The HTTP method for the /api/v3/licenses endpoint should be updated to PUT to match the refreshLicensesV3 function.
		Methods(http.MethodPut)
  • Reason this comment was not posted:
    Comment was on unchanged code.
2. ee/query-service/app/api/license.go:218
  • Draft comment:
    The function convertLicenseV3ToLicenseV2 should accept a slice directly instead of a pointer to a slice for clarity and to avoid unnecessary complexity.
func convertLicenseV3ToLicenseV2(licenses []*model.LicenseV3) []model.License {
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment is no longer relevant because the suggested change has already been implemented in the diff. The function now correctly accepts a slice directly, aligning with the comment's suggestion.
    I might be missing some context about why the comment was made, but based on the diff, the change has already been applied.
    The diff clearly shows the change was made, so the comment is outdated and should be removed.
    The comment is outdated because the suggested change has already been implemented in the diff. It should be removed.
3. ee/query-service/integrations/signozio/signozio.go:164
  • Draft comment:
    Avoid redundant error wrapping with fmt.Errorf when the error message is already a string.
		return nil, model.BadRequest(errors.New(string(body)))
  • Reason this comment was not posted:
    Comment was on unchanged code.
4. ee/query-service/license/db.go:52
  • Draft comment:
    Return a slice of model.LicenseV3 instead of a pointer to a slice for consistency and clarity.
func (r *Repo) GetLicensesV3(ctx context.Context) ([]model.LicenseV3, error) {
  • Reason this comment was not posted:
    Marked as duplicate.
5. ee/query-service/model/errors.go:49
  • Draft comment:
    The Unauthorized function is correctly implemented and aligns with existing patterns. No changes needed.
  • Reason this comment was not posted:
    Confidence changes required: 0%
    The Unauthorized function in errors.go is correctly implemented and aligns with the existing error handling patterns. No changes are needed here.

Workflow ID: wflow_FXQe2kCgyyeH4rEw


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

ee/query-service/app/api/license.go Show resolved Hide resolved
Copy link

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on e6fa8c6 in 1 minute and 0 seconds

More details
  • Looked at 338 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 9 drafted comments based on config settings.
1. ee/query-service/model/license_test.go:25
  • Draft comment:
    The error message here should match the format used in extractKeyFromMapStringInterface.
			error: errors.New("id key is missing"),
  • Reason this comment was not posted:
    Comment looked like it was already resolved.
2. ee/query-service/model/license_test.go:31
  • Draft comment:
    The error message here should match the format used in extractKeyFromMapStringInterface.
			error: errors.New("id key is not a valid string"),
  • Reason this comment was not posted:
    Marked as duplicate.
3. ee/query-service/model/license_test.go:37
  • Draft comment:
    The error message here should match the format used in extractKeyFromMapStringInterface.
			error: errors.New("key key is missing"),
  • Reason this comment was not posted:
    Marked as duplicate.
4. ee/query-service/model/license_test.go:43
  • Draft comment:
    The error message here should match the format used in extractKeyFromMapStringInterface.
			error: errors.New("key key is not a valid string"),
  • Reason this comment was not posted:
    Marked as duplicate.
5. ee/query-service/model/license_test.go:49
  • Draft comment:
    The error message here should match the format used in extractKeyFromMapStringInterface.
			error: errors.New("status key is missing"),
  • Reason this comment was not posted:
    Marked as duplicate.
6. ee/query-service/model/license_test.go:55
  • Draft comment:
    The error message here should match the format used in extractKeyFromMapStringInterface.
			error: errors.New("status key is not a valid string"),
  • Reason this comment was not posted:
    Marked as duplicate.
7. ee/query-service/model/license_test.go:61
  • Draft comment:
    The error message here should match the format used in extractKeyFromMapStringInterface.
			error: errors.New("plan key is missing"),
  • Reason this comment was not posted:
    Marked as duplicate.
8. ee/query-service/model/license_test.go:67
  • Draft comment:
    The error message here should match the format used in extractKeyFromMapStringInterface.
			error: errors.New("plan key is not a valid map[string]interface {}"),
  • Reason this comment was not posted:
    Marked as duplicate.
9. ee/query-service/app/api/license.go:221
  • Draft comment:
    Avoid using inline styles in React components. Use external stylesheets, CSS classes, or styled components instead. This is also applicable at line 115 and 73.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_8di9XEc8XtvOzH3f


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@vikrantgupta25 vikrantgupta25 merged commit e974e9d into develop Nov 11, 2024
14 of 15 checks passed
@vikrantgupta25 vikrantgupta25 deleted the licenses-v3 branch November 11, 2024 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs not required enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants