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

Documentation/faq java ammendment #314

Merged
merged 14 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 14 additions & 24 deletions docs/troubleshooting_and_faq/build.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,21 @@
# mp-build


### mp-build returns 'Unable to build pak file'

In most cases, this error indicates issues with building the container image. The most probable causes are:

1. Unknown Instruction :

```
mp-build
Building adapter [Finished]
Unable to build pak file
ERROR: Unable to build Docker file at /Users/user/code/aria_ops/management-packs/test:
{'message': 'dockerfile parse error line 7: unknown instruction: COP'}

```
2. A command inside the Dockerfile failed:

```
mp-build
Building adapter [Finished]
Unable to build pak file
ERROR: Unable to build Docker file at /Users/user/code/management-packs/test:
The command '/bin/sh -c pip3 install -r adapter_requirements.txt --upgrade' returned a non-zero code: 1
```
The solution for case 1 to fix the typo/command by editing the Dockerfile. For case 2, however, the solution might not be evident at first sight. Since the error
comes from building the image itself, we can run `docker build .` in the project's root directory and look at the stack trace for clues.
In most cases, this error indicates issues with building the container image. The most probable cause is:

kjrokos marked this conversation as resolved.
Show resolved Hide resolved
```
mp-build
Building adapter [Finished]
Unable to build pak file
ERROR: Unable to build Docker file at /Users/user/code/aria_ops/management-packs/test:
{'message': 'dockerfile parse error line 7: unknown instruction: COP'}

```

In cases where build is unable to complete the building process due to a docker error,
the best approach is to look at the stack trace from docker by directly running `docker build .`
command.

???+ info

Expand Down
74 changes: 50 additions & 24 deletions docs/troubleshooting_and_faq/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,56 @@ Internal server errors can happen for various reasons; however, the most common
the adapter's code. Check the server logs for clues about the issue. Sometimes, the problem may be detected using `mp-test` and
going over the terminal output.

---
### Collection returns 'No collection result was found'

`mp-test` runs a series of validations test after collection; if the collection has no results, then each validation step will report the result as missing.
When a collection result is missing, it usually means an error occurred during collection, but the Adapter handled the error. When the Adapter handles an error,
the response contains an error message; The console displays the error message. For example:

```python
def collect(adapter_instance: AdapterInstance) -> CollectResult:
result = CollectResult()
try:
raise Exception("oops")

#...
except Exception as e:
logger.error("Unexpected collection error")
logger.exception(e)
result.with_error("Unexpected collection error: " + repr(e))
return result
```

This code will output

```
`mp-test` runs a series of validations test after a collection; if the collection has no results, then each validation
step will report the result as missing.
When a collection result is missing, it usually means an error occurred during a collection,
but the Adapter handled the error.
When the Adapter handles an error, the response contains an error message; The console displays the error message.
For example:

=== "Python Adapter Library"

```python linenums="1"
def collect(adapter_instance: AdapterInstance) -> CollectResult:
result = CollectResult()
try:
raise Exception("oops!")

#...
except Exception as e:
logger.error("Unexpected collection error")
logger.exception(e)
result.with_error(f"Unexpected collection error: '{e}'")
return result
```

=== "Java Adapter Library"

```python linenums="1"
public CollectRestuls collect(AdapterInstance adapterInstance) {
CollectResult result = new CollectResult();
try{
throw new Exception("oops!");

//...
} catch ( Exception e) {
result.with_error("Unexpected collection error: " + "'" + e.getMessage() + "'");
}

return result
}
```

will output

``` hl_lines="4"
Building adapter [Finished]
Waiting for adapter to start [Finished]
Running Collect [Finished]
Collection Failed: Unexpected collection error: Exception('oops')
Collection Failed: Unexpected collection error: 'oops!'

Avg CPU % | Avg Memory Usage % | Memory Limit | Network I/O | Block I/O
------------------------------+----------------------------+--------------+---------------------+--------------
Expand All @@ -45,18 +68,21 @@ This code will output
No collection result was found.
All validation logs written to '/Users/user/management-pack/test-management-pack/logs/validation.log'
```
As seen above, the Exception is mentioned as the reason for the collection error, and the `No collection result was found` message is also shown.

As seen above, the Exception is mentioned as the reason for the collection error, and
the `No collection result was found` message is also shown.
Using the collection error message along with the `adapter.log` can help trace the cause of the issue.

---
### Is there a way to cache data for subsequent collections?

The containerized adapter does not support caching data between collections.

---
### Can I implement on-demand collections?

The containerized adapter does not support on-demand collections.

???+ info

For issues regarding mp-test and docker, see [Docker's](docker.md) page.

14 changes: 8 additions & 6 deletions docs/troubleshooting_and_faq/docker.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# Docker


### When starting Docker, I get 'Permission denied while trying to connect to the Docker daemon'
### When starting Docker, I get a 'Permission denied while trying to connect to the Docker daemon' message

If you're having trouble getting Docker to run on your system, you can refer to the Docker documentation for instructions
on how to start Docker on [macOS](https://docs.docker.com/docker-for-mac/install/), [Linux](https://docs.docker.com/desktop/install/debian/#launch-docker-desktop), and [Windows 10 and 11](https://docs.docker.com/desktop/install/windows-install/#start-docker-desktop).

### When starting Docker on Windows, I get 'Cannot connect to Docker daemon'
---
### When starting Docker on Windows, I get a 'Cannot connect to Docker daemon' message

If you're having trouble with permissions on a Windows system, you can refer to the Docker documentation for instructions
on how to [Understand permission requirements for Windows](https://docs.docker.com/desktop/windows/permission-requirements/).

### When using mp-test and mp-build, I get a "Cannot connect to the Docker daemon" error
---
### When using mp-test and mp-build, I get a 'Cannot connect to the Docker daemon' message

There are multiple causes for this error; the most common causes and solutions are:

Expand All @@ -21,9 +23,9 @@ There are multiple causes for this error; the most common causes and solutions a
- See Docker's documentation for [troubleshooting the Docker daemon](https://docs.docker.com/config/daemon/troubleshoot/)

2. The Docker daemon is running, but the socket is not open or accessible. Possible solutions are:
- Open Docker Desktop application → navigate to Settings on the top right corner (Cog icon) → Advanced (Cogs icon) → make sure "Allow the default Docker socket to be used" is enabled.
- Open Docker Desktop application → navigate to Settings in the top right corner
(Cog icon) → Advanced (Cogs icon) → make sure "Allow the default Docker socket to be used" is enabled.
- Ensure permissions to access the Docker daemon socket are enabled:
- For [MacOs](https://docs.docker.com/desktop/mac/permission-requirements/)
- For [Windows](https://docs.docker.com/desktop/windows/permission-requirements/)
- FOR [Linux](https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user)

- For [Linux](https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user)
135 changes: 95 additions & 40 deletions docs/troubleshooting_and_faq/logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,42 @@

### Where are the adapter logs stored locally?

Logs generated by `mp-test` or `mp-build` are stored in the `logs` sub-directory of the
Logs generated by `mp-test` or `mp-build` are stored in the `logs` subdirectory of the
project.

---
### Where are the adapter logs stored in VMware Aria Operations?

Logs are generated and stored on the cloud proxy where the adapter is running at `$ALIVE_BASE/user/log/adapter/<ADAPTERKEY>/<ADAPTER_INTERNAL_INSTANCE_ID>`.
Logs are generated and stored on the cloud proxy where the adapter is running at
`$ALIVE_BASE/user/log/adapter/<ADAPTERKEY>/<ADAPTER_INTERNAL_INSTANCE_ID>`.

`ADAPTERKEY` should match the adapter key used in the `manifest.txt`, and the `ADAPTER_INTERNAL_INSTANCE_ID` should match the Internal ID
found in VMware Aria Operations at **Environment &rarr; Inventory &rarr; Adapter Instances &rarr; &lt;ADAPTER_DISPLAY_NAME&gt; &rarr; &lt;ADAPTER_INSTANCE&gt;** in the rightmost column.
The `Internal ID` column is not displayed by default. To display the Internal ID, enable the `Internal ID` column by clicking the lower left 'column' icon and then checking the `Internal ID` box.
`ADAPTERKEY` should match the adapter key used in the `manifest.txt`, and the `ADAPTER_INTERNAL_INSTANCE_ID` should
match the Internal ID
found in VMware Aria Operations at **Environment &rarr; Inventory &rarr; Adapter Instances &rarr;
&lt;ADAPTER_DISPLAY_NAME&gt; &rarr; &lt;ADAPTER_INSTANCE&gt;** in the rightmost column.
The `Internal ID` column is not displayed by default. To display the Internal ID, enable the `Internal ID` column by
clicking the lower left 'column' icon and then checking the `Internal ID` box.

![highlight of the checkbox where internal id can be enabled](../images/enable_internal_id_column.png)

![highlight of the internal id](../images/highlight_internal_id_column.png)

---
### What are the different log files used for?

There are five types of log files: adapter, server, build, test, and validation logs. Each log file is prepended with the type of
log file followed by a number that represents rollover.
There are five types of log files: adapter, server, build, test, and validation logs.
Each log file is prepended with the type of log file followed by a number that represents rollover.

- `server.log`:
Contains all logs related to the HTTP server inside the container. Server logs can't be modified since the server code comes packaged
inside the [base-adapter](https://projects.registry.vmware.com/harbor/projects/46752/repositories/base-adapter/artifacts-tab) Python image.
Contains all logs related to the HTTP server inside the container. Server logs can't be modified since the server code
comes packaged
inside
the [base-adapter](https://projects.registry.vmware.com/harbor/projects/46752/repositories/base-adapter/artifacts-tab)
Python image.

- `adapter.log`
Contains all logs related to the adapter. Adapter logs are all the logs generated by adapter code (e.g., the test() method or the collect() methods inside
Contains all logs related to the adapter. Adapter logs are all the logs generated by adapter code (e.g., the test()
method or the collect() methods inside
`app/adapter.py`).

- `test.log`
Expand All @@ -40,55 +50,100 @@ log file followed by a number that represents rollover.
- `validation.log`
Contains a log of the validations performed by `mp-test` on the collection results. Validation logs are only generated locally.

---
### How do I add logs to my adapter?

=== "Python Adapter Library"

The template adapter defines a logger variable in the `adapter.py` file that configures all adapter logging using [adapter_logging](https://github.com/vmware/vmware-aria-operations-integration-sdk/blob/299ce55ac0b1e53dde9c1b4b3e217ab41df57299/lib/python/src/aria/ops/adapter_logging.py) from the Python SDK.
The logger only needs to be configured once; to generate logs in other files, simply import the Python [logging](https://docs.python.org/3/library/logging.html) module. Eg.
The template adapter defines a logger variable in the `adapter.py` file that configures all adapter logging using
[adapter_logging](https://github.com/vmware/vmware-aria-operations-integration-sdk/blob/299ce55ac0b1e53dde9c1b4b3e217ab41df57299/lib/python/src/aria/ops/adapter_logging.py) from the Python SDK.
The logger only needs to be configured once; to generate logs in other files, simply import the Python [logging](https://docs.python.org/3/library/logging.html) module. Eg.

```python
import logging
```python linenums="1" hl_lines="3"
import logging

logger = logging.getLogger(__name__)
logger = logging.getLogger(__name__)

def my_method():
logger.info("info log")
logger.warning("warning log")
logger.error("error log")
logger.debug("debug log")
...
```
def my_method():
logger.info("info log")
logger.warning("warning log")
logger.error("error log")
logger.debug("debug log")
...
```

=== "Java Adapter Library"

Adapter logging is setup bia the [Get Logger](../references/java_project/java_lib/-integration-s-d-k-adapter-library/com.vmware.aria.operations/get-logger.html) method
quirogas marked this conversation as resolved.
Show resolved Hide resolved
available through the `AdapterLogger` class of the Java Integrations SDK. The **Get Logger** method returns a Log4j Logger:

```java linenums="1" hl_lines="3"
import org.apache.logging.log4j.Logger;
import com.vmware.aria.operations.AdapterLogger;

public void myMethod() {
Logger logger = AdapterLogger.getLogger();
logger.info("info log");
logger.warning("warning log");
logger.error("error log");
logger.debug("debug log");
}

public void myOtherMethod() {
Logger logger = AdapterLogger.getLogger();
logger.info("other info log");
logger.warning("other warning log");
logger.error("other error log");
logger.debug("other debug log");
}
```

---
### How do I change the server and/or adapter log level?

You can set the log levels for the server and adapter inside the `loglevels.cfg` file, which is located in `logs/loglevels.cfg` locally and on the cloud proxy at `$ALIVE_BASE/user/log/adapters/<ADAPTERKEY>/<ADAPTER_INTERNAL_INSTANCE_ID>/loglevels.cfg`.
You can set the log levels for the server and adapter inside the `loglevels.cfg` file,
which is located in `logs/loglevels.cfg` locally and on the cloud proxy
at `$ALIVE_BASE/user/log/adapters/<ADAPTERKEY>/<ADAPTER_INTERNAL_INSTANCE_ID>/loglevels.cfg`.
If the file does not exist, the system generates it after a collection/test.

`ADAPTERKEY` should match the name of the adapter used in the `manifest.txt`, and the `ADAPTER_INTERNAL_INSTANCE_ID` should match the Internal ID
found in VMware Aria Operations at **Environment &rarr; Inventory &rarr; Adapter Instances &rarr; &lt;ADAPTER_DISPLAY_NAME&gt; &rarr; &lt;ADAPTER_INSTANCE&gt;** in the rightmost column.
The `Internal ID` column is not displayed by default. To display the Internal ID, enable the `Internal ID` column by clicking the lower left 'column' icon and then checking the `Internal ID` box.
`ADAPTERKEY` should match the name of the adapter used in the `manifest.txt`, and the `ADAPTER_INTERNAL_INSTANCE_ID`
should match the Internal ID
found in VMware Aria Operations at **Environment &rarr; Inventory &rarr; Adapter Instances &rarr;
&lt;ADAPTER_DISPLAY_NAME&gt; &rarr; &lt;ADAPTER_INSTANCE&gt;** in the rightmost column.
The `Internal ID` column is not displayed by default. To display the Internal ID, enable the `Internal ID` column by
clicking the lower left 'column' icon and then checking the `Internal ID` box.

![highlight of the checkbox where internal id can be enabled](../images/enable_internal_id_column.png)

![highlight of the internal id](../images/highlight_internal_id_column.png)


---
### How do I change the log level of mp-init, mp-test, or mp-build?

All SDK tools read the LOG_LEVEL environment variable to set the log level of their console output. For example, to set log level
to debug to see a verbose output of the any of the CLI tools we can set the LOG_LEVEL variable:
All SDK tools read the LOG_LEVEL environment variable to set the log level of their console output.
For example,
to set the log level of any of the CLI tools, we can set the LOG_LEVEL variable to the desired log level:

For Linux and macOS
```shell
LOG_LEVEL=debug mp-build
```
For Windows
```
set LOG_LEVEL=debug
mp-build
```
For Windows, set the log level back to `info` after debugging.
=== "Linux"

The SDK CLI tools support `debug`, `warn`, `info`, and `error` levels.
```shell
LOG_LEVEL=debug mp-build
```

=== "macOS"

```shell
LOG_LEVEL=debug mp-build
```
=== "Windows"

```
set LOG_LEVEL=debug
mp-build
```

!!! information

Set the log level back to `info` after debugging.

The SDK CLI tools support `debug`, `warn`, `info`, and `error` levels.
7 changes: 4 additions & 3 deletions docs/troubleshooting_and_faq/other.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

Policy and capacity models can only be specified by writing a `describe.xml` file in the `conf` directory.


---
### Are there replacements for `onConfigure`, `onStopCollection`, and `onDiscard` methods?

The `onConfigure`, `onStopCollection`, and `onDiscard` methods have no replacement in the new integration SDK.


### VMware Aria Operations returns 'Unknown adapter type' when setting up new adapter instance
---
### VMware Aria Operations returns 'Unknown adapter type' message when setting up a new adapter instance

![Example of an 'Unknown Adapter Type' error message for an adapter with type/key 'Testserver'](../images/unknown_adapter_type.png)
> Example of an 'Unknown Adapter Type' error message for an adapter with type/key 'Testserver'.
Expand All @@ -21,6 +21,7 @@ If the pak file installs successfully but errors when creating an account (adapt
- Check that the Cloud Proxy supports containerized adapters. Containerized adapter
support is supported in VMware Aria Operations version 8.10.0 and later.

---
### How do I migrate connection-related elements from config.json to connections.json?

As of version 1.0.0,
Expand Down
Loading