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

NC | S3 internal APIs gaps | Add versions CLI command | S3 internal API refactoring #8800

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

romayalon
Copy link
Contributor

@romayalon romayalon commented Feb 16, 2025

Explain the changes

  1. Added a new CLI command called versions that returns the following versions status -
> noobaa-cli versions
{
  "response": {
    "code": "VersionsStatus",
    "message": "Versions status retrieved successfully",
    "reply": {
      "rpm_source_code_versions": {
        "package_version": "5.19.0",
        "config_fs_version": "1.0.0"
      },
      "host_running_service_versions": {
        "package_version": "5.19.0",
        "config_fs_version": "1.0.0"
      },
      "config_dir_version": "1.0.0"
    }
  }
}
  • rpm_source_code_versions consists of the package_version and the config_fs version.
  • host_running_service_versions consists of the running service package_version and config_fs version.
  • config_dir_version is the current config_dir_version registered in system.json.
  1. added endpoint_fork_id and total_fork_count to be under the internal endpoint apis prefix - /_/ and did some refactoring there.
  2. Added unit tests to the new CLI command.

Issues: Fixed #xxx / Gap #xxx

  1. Fixed gaps mentioned in Add http://{endpoint_address}:{s3_port}/_/version api to the endpoint #8786
  2. Open question - is rpm_source_code_versions fetched correctly.

Testing Instructions:

  1. sudo jest --testRegex=jest_tests/test_cli_versions
  2. Manual -

Service is up -
a. Tab 1 - start noobaa service - sudo node noobaa-core/src/cmd/nsfs.js --debug
b. Tab 2 - run noobaa-cli versions command - noobaa-cli versions

Service is down -
a. Tab 1 - start noobaa service - sudo node noobaa-core/src/cmd/nsfs.js --debug, stop noobaa service - Ctrl + C
b. Tab 1 - run noobaa-cli versions command - noobaa-cli versions

system.json was never created -
a. Tab 1 - run noobaa-cli versions command - noobaa-cli versions

  • Doc added/updated
  • Tests added

@romayalon romayalon force-pushed the romy-s3-internal-apis branch 3 times, most recently from ff1877a to cb95c81 Compare February 17, 2025 12:25
Copy link
Contributor

@shirady shirady left a comment

Choose a reason for hiding this comment

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

LGTM
I added minor comments and questions

Comment on lines +641 to +644
The `versions` command is used to print the status of the rpm_source_code_versions, host_running_service_versions and config_dir_version.
- rpm_source_code_versions consists of the package_version and the config_fs version.
- host_running_service_versions consists of the running service package_version and config_fs version.
- config_dir_version is the current config_dir_version registered in system.json.
Copy link
Contributor

Choose a reason for hiding this comment

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

I would add the var name style for easier reading, for example:

Suggested change
The `versions` command is used to print the status of the rpm_source_code_versions, host_running_service_versions and config_dir_version.
- rpm_source_code_versions consists of the package_version and the config_fs version.
- host_running_service_versions consists of the running service package_version and config_fs version.
- config_dir_version is the current config_dir_version registered in system.json.
The `versions` command is used to print the status of the `rpm_source_code_versions`, `host_running_service_versions`, and `config_dir_version`.
- `rpm_source_code_versions` consists of the `package_version` and the `config_fs` version.
- `host_running_service_versions` consists of the running service `package_version` and `config_fs` version.
- `config_dir_version` is the current `config_dir_version` registered in `system.json`.

@@ -60,6 +61,13 @@ const SERVICES_TYPES_ENUM = Object.freeze({
METRICS: 'METRICS'
});

const INTERNAL_APIS_OBJ = Object.freeze({
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a comment about this object?
It is only used in NC deployment, and this file is mutual for all deployments.

/**
* get_version_api_response runs a GET request to the given api and returns the response
* @param {string} api
* @returns
Copy link
Contributor

Choose a reason for hiding this comment

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

missing parameter?

@@ -0,0 +1,143 @@
/* Copyright (C) 2016 NooBaa */
Copy link
Contributor

Choose a reason for hiding this comment

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

You can update the year

Suggested change
/* Copyright (C) 2016 NooBaa */
/* Copyright (C) 2025 NooBaa */

package_version: pkg.version,
config_fs_version: CONFIG_DIR_VERSION
},
expected_config_dir_version: 'unknown'
Copy link
Contributor

Choose a reason for hiding this comment

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

To help others understand the flow better - in this case, I would add a comment that we see the 'unknown' because there is no system.json file, and in the other cases I would just point to the reason (I understand that it is written in the test title, but I think it can help).


#### Usage
```sh
noobaa-cli versions
Copy link
Contributor

Choose a reason for hiding this comment

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

I want to make sure - that there will be no additional actions (we could noobaa-cli versions status, but choose this way). Could you share your thoughts on this decision?

@shirady
Copy link
Contributor

shirady commented Feb 17, 2025

@romayalon if you can attach or add in the manual testing the expected result I think it can be easier to understand parts of the cases.

config_dir_version: system_json?.config_directory.config_dir_version || 'unknown'
};

const response = { code: ManageCLIResponse.VersionsStatus, detail: versions };
Copy link
Contributor

Choose a reason for hiding this comment

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

@romayalon
suggestion: will it help if the rpm and host versions are different and the version status returns an error message mentioning that conflict?

@romayalon romayalon force-pushed the romy-s3-internal-apis branch from 07a7878 to a165994 Compare February 18, 2025 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants