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

KNOX-2955 - Knox Readiness Awareness and Notification #792

Merged
merged 6 commits into from
Sep 11, 2023

Conversation

zeroflag
Copy link
Contributor

@zeroflag zeroflag commented Sep 6, 2023

What changes were proposed in this pull request?

Adding a new endpoint to the health service for checking knox gateway status (weather all topologies which were available at startup are deployed)

How was this patch tested?

Create discovery password:

$ bin/knoxcli.sh create-alias admin --value admin

Adding this to gateway-site.xml

<property>
    <name>gateway.cloudera.manager.descriptors.monitor.interval</name>
    <value>60000</value>
</property>

Dedicated topology for checking gateway status:

$ cat conf/topologies/health.xml

<topology>
    <gateway>
        <provider>
            <role>authentication</role>
            <name>Anonymous</name>
            <enabled>true</enabled>
        </provider>
    </gateway>
    <service>
        <role>HEALTH</role>
    </service>
</topology>

Hadoop xml resource file:

$ cat  conf/descriptors/test.hxr 
<configuration>
    <property>
        <name>custom-desc</name>
        <value>
            discoveryType=ClouderaManager#
            discoveryAddress=http://CM_HOST:7180/#
            discoveryUser=admin#
            discoveryPasswordAlias=admin#
            cluster=Cluster 1#
            providerConfigRef=default-providers#
            app:knoxauth:param1.name=param1.value#
            app:admin-ui#
            WEBHDFS#
            HIVE:url=http://localhost:456#
            HIVE:version=1.0#
            HIVE:httpclient.connectionTimeout=5m#
            HIVE:httpclient.socketTimeout=100m
        </value>
    </property>
</configuration>

Starting gw:

$ bin/gateway.sh restart

Log:

2023-09-06 13:06:14,053  INFO  knox.gateway (AbstractGatewayServices.java:start(60)) - Starting service: org.apache.knox.gateway.services.topology.impl.GatewayStatusChecker
2023-09-06 13:06:15,787  INFO  knox.gateway (GatewayStatusChecker.java:collectTopologies(73)) - Collected topologies for health check: [metadata, manager, knoxsso, sandbox, custom-desc, health, admin, tokenexchange, homepage]
2023-09-06 13:06:15,787  INFO  knox.gateway (GatewayStatusChecker.java:initTopologiesToCheck(66)) - Starting gateway status monitor service. Topologies to check: [metadata, manager, knoxsso, sandbox, custom-desc, health, admin, tokenexchange, homepage]
2023-09-06 13:08:05,770 e10b22f5-c655-450f-a807-1b8b623a9082 INFO  knox.gateway (GatewayStatusChecker.java:status(49)) - Checking gateway status. Deployed topologies: [metadata, manager, knoxsso, custom-desc, sandbox, admin, health, tokenexchange, homepage]. Waiting for: []
2023-09-06 13:12:26,420  INFO  knox.gateway (AbstractGatewayServices.java:stop(72)) - Stopping service: org.apache.knox.gateway.services.topology.impl.GatewayStatusChecker
2023-09-06 13:12:30,403  INFO  knox.gateway (AbstractGatewayServices.java:start(60)) - Starting service: org.apache.knox.gateway.services.topology.impl.GatewayStatusChecker
2023-09-06 13:12:31,770  INFO  knox.gateway (GatewayStatusChecker.java:collectTopologies(73)) - Collected topologies for health check: [metadata, manager, knoxsso, sandbox, custom-desc, health, admin, tokenexchange, homepage]
2023-09-06 13:12:31,770  INFO  knox.gateway (GatewayStatusChecker.java:initTopologiesToCheck(66)) - Starting gateway status monitor service. Topologies to check: [metadata, manager, knoxsso, sandbox, custom-desc, health, admin, tokenexchange, homepage]
2023-09-06 13:12:34,729 50d7c781-826d-4125-8e7e-98cd3a3790b8 INFO  knox.gateway (GatewayStatusChecker.java:status(49)) - Checking gateway status. Deployed topologies: [metadata, manager, knoxsso, sandbox, admin, health, homepage]. Waiting for: [custom-desc, tokenexchange]
...
2023-09-06 13:13:59,917 daa64c86-def1-4144-9932-ac8a26d8b8f7 INFO  knox.gateway (GatewayStatusChecker.java:status(49)) - Checking gateway status. Deployed topologies: [metadata, manager, knoxsso, sandbox, admin, health, tokenexchange, homepage]. Waiting for: [custom-desc]
...
2023-09-06 13:13:59,967 2c08b6d1-f8c0-4505-800f-18b98eec2649 INFO  knox.gateway (GatewayStatusChecker.java:status(49)) - Checking gateway status. Deployed topologies: [metadata, manager, knoxsso, sandbox, custom-desc, admin, health, tokenexchange, homepage]. Waiting for: []

Script for polling health endpoint

#!/bin/bash
while true
do
  echo -n "$(date) Accessing knox.. "
  response=$(curl -k -s "https://localhost:8443/gateway/health/v1/gateway-status")
  echo $response
  if [[ "$response" == "OK" ]] ; then
    curl -vu admin:admin-password -k "https://localhost:8443/gateway/custom-desc/webhdfs/v1?op=LISTSTATUS"
    exit 0
  fi
done

Script Output

...
Wed Sep  6 13:13:59 CEST 2023 Accessing knox.. PENDING
Wed Sep  6 13:13:59 CEST 2023 Accessing knox.. PENDING
Wed Sep  6 13:13:59 CEST 2023 Accessing knox.. OK

@zeroflag zeroflag self-assigned this Sep 6, 2023
Copy link
Contributor

@pzampino pzampino left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@smolnar82 smolnar82 left a comment

Choose a reason for hiding this comment

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

LGTM

@zeroflag zeroflag merged commit 3f3a65b into apache:master Sep 11, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants