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

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from

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

Related Issues / PR's

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

Screenshots

NA

Affected Areas and Manually Tested Areas


Important

Introduce and integrate a new license v3 structure with new endpoints, database schema, and management logic.

  • Endpoints:
    • Add /api/v3/licenses and /api/v3/licenses/refresh endpoints in api.go for applying and refreshing licenses.
  • License Management:
    • Implement applyLicenseV3, refreshLicensesV3, and listLicensesV3 in license.go.
    • Add ActivateV3, RefreshLicense, and ValidateV3 methods in manager.go.
    • Modify StartManager in manager.go to support useLicensesV3 flag.
  • Database:
    • Add licenses_v3 table in sqlite/init.go.
    • Implement InsertLicenseV3 and UpdateLicenseV3 in db.go.
  • Models:
    • Add LicenseV3 struct in license.go.
    • Add ParseFeaturesV3 method in license.go.
  • Misc:
    • Update ServerOptions in server.go to include UseLicensesV3 flag.
    • Add ValidateLicenseV3 function in signozio.go.

This description was created by Ellipsis for cc645c5. 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/engineering-pod/issues/1961 ( 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 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. Incremental review on ee510e6 in 44 seconds

More details
  • Looked at 105 lines of code in 4 files
  • Skipped 0 files when reviewing.
  • Skipped posting 5 drafted comments based on config settings.
1. ee/query-service/license/db.go:67
  • Draft comment:
    Consider adding error handling for the json.Unmarshal call to prevent potential panics due to malformed JSON.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The code already includes error handling for json.Unmarshal by returning an error if unmarshalling fails. The comment seems to suggest something that is already implemented, making it redundant.
    I might be missing a more nuanced form of error handling that the comment is suggesting, but the current implementation does handle errors by returning them.
    The existing error handling seems sufficient for the context, as it prevents further execution with malformed data.
    The comment is redundant because the code already handles errors from json.Unmarshal.
2. ee/query-service/app/api/license.go:95
  • Draft comment:
    Consider logging the error before calling RespondError to aid in debugging.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The listLicensesV3 function in api/license.go does not log the error when RespondError is called. Logging the error would help in debugging issues.
3. ee/query-service/app/api/license.go:91
  • Draft comment:
    Avoid using inline styles in React components. Instead, use external stylesheets, CSS classes, or styled components. This is applicable in other parts of the code as well.
  • Reason this comment was not posted:
    Comment was on unchanged code.
4. ee/query-service/license/db.go:52
  • Draft comment:
    Avoid using inline styles in React components. Instead, use external stylesheets, CSS classes, or styled components. This is applicable in other parts of the code as well.
  • Reason this comment was not posted:
    Marked as duplicate.
5. ee/query-service/license/manager.go:222
  • Draft comment:
    Avoid using inline styles in React components. Instead, use external stylesheets, CSS classes, or styled components. This is applicable in other parts of the code as well.
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_jqCsBEXJzrHzHMe7


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/license/manager.go Outdated Show resolved Hide resolved
@vikrantgupta25 vikrantgupta25 changed the title feat: consume the licenses v3 structure. feat: consume the new licenses v3 structure. Nov 4, 2024
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>

1 similar comment
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>

ee/query-service/app/api/license.go Show resolved Hide resolved
ah.Respond(w, l)
}

func (ah *APIHandler) refreshLicensesV3(w http.ResponseWriter, r *http.Request) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

In the refreshLicenses call, you will only get the license key. Nothing else will be given.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

do we need a license key here ? what if the key here doesn't correspond to the active license key currently ? then do set that as active? Since by design each deployment will have only once license and query service is aware of the active license we do not specifically need the license key here

ee/query-service/model/license.go Outdated Show resolved Hide resolved
@grandwizard28
Copy link
Collaborator

The important thing to keep in mind is:

  • You care only about the id, key and a json blob. That json blob can be anything.
  • If something specific is required from the json blob, we will try to see whether the key exists. If it does not, we will fallback to a default set of features.

Copy link

github-actions bot commented Nov 5, 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 508c8a5 in 1 minute and 12 seconds

More details
  • Looked at 429 lines of code in 5 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. ee/query-service/license/db.go:295
  • Draft comment:
    The UpdateLicenseV3 function should marshal only the Data field of the license, not the entire license object. This issue is also present in the UpdateLicenseV3 function.
  • Reason this comment was not posted:
    Comment was on unchanged code.
2. ee/query-service/integrations/signozio/signozio.go:121
  • Draft comment:
    Consider returning the map directly instead of a pointer to a map in ValidateLicenseV3. This simplifies the function signature and usage.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The ValidateLicenseV3 function returns a pointer to a map, which is unconventional and can lead to unnecessary complexity. It would be better to return the map directly.
3. ee/query-service/model/license.go:123
  • Draft comment:
    Use type assertions with a check to avoid runtime panics in ParseFeaturesV3. This issue is also present in the ParseFeaturesV3 method.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.

Workflow ID: wflow_1F0uPK0mjj5XZtRA


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/license/db.go Outdated Show resolved Hide resolved
Copy link

github-actions bot commented Nov 5, 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 9214f7c in 37 seconds

More details
  • Looked at 19 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. ee/query-service/license/db.go:120
  • Draft comment:
    Do not add non-ClickHouse related functions like CreateFeature to the ClickHouseReader interface. Use the DAO in the telemetry instance instead. This also applies to GetFeature, GetAllFeatures, UpdateFeature, and InitFeatures.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_zNXXb8z2KP1iQWAE


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

Copy link

github-actions bot commented Nov 5, 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 cc645c5 in 51 seconds

More details
  • Looked at 89 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 drafted comments based on config settings.
1. ee/query-service/license/db.go:324
  • Draft comment:
    Error message should mention 'update' instead of 'insert'.
  • Reason this comment was not posted:
    Comment was on unchanged code.
2. ee/query-service/license/manager.go:360
  • Draft comment:
    Consider implementing a comparison between old and new licenses as suggested by the comment.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The comment in the RefreshLicense function suggests a comparison check is needed between old and new licenses. This is a potential area for improvement or a reminder for future work.
3. ee/query-service/license/db.go:322
  • Draft comment:
    Avoid using inline styles in React components. Use external stylesheets, CSS classes, or styled components instead. This is also applicable in other parts of the code where inline styles are used.
  • Reason this comment was not posted:
    Comment was on unchanged code.
4. ee/query-service/license/manager.go:362
  • Draft comment:
    Avoid using inline styles in React components. Use external stylesheets, CSS classes, or styled components instead. This is also applicable in other parts of the code where inline styles are used.
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_O4MYn7bTc146pBt5


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/license/manager.go Show resolved Hide resolved
ee/query-service/model/license.go Show resolved Hide resolved
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