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

Universal Command-line only Plugin Installation Action & Workflow #2271

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
949a635
Rebase
stephen-crawford Nov 10, 2022
e92d0cd
Undo bad file changes
stephen-crawford Nov 10, 2022
30c8adb
reset accidental changes
stephen-crawford Nov 10, 2022
705f9d9
Swap the version number
stephen-crawford Nov 10, 2022
282a500
final changes
stephen-crawford Nov 11, 2022
8e6fdc6
Fix typos
stephen-crawford Nov 11, 2022
858068c
Remove linux name
stephen-crawford Nov 11, 2022
c477372
fix rename
stephen-crawford Nov 11, 2022
710a8a2
Make sure passes without jdk 11
stephen-crawford Nov 14, 2022
aa59db2
Fully working once JDK 11 is fixed
stephen-crawford Nov 14, 2022
15c4005
Reset to working version and add fail fast
stephen-crawford Nov 15, 2022
3258eb9
Remove docker
stephen-crawford Nov 16, 2022
b531417
Test Without Docker
stephen-crawford Nov 16, 2022
a6b8113
Test Without Docker
stephen-crawford Nov 16, 2022
3f8e05a
Hard coded OSs since casing breaks download
stephen-crawford Nov 16, 2022
24e967d
Hard coded OSs since casing breaks download
stephen-crawford Nov 16, 2022
85d7d35
Swap file paths in download to their actual path
stephen-crawford Nov 16, 2022
a8b9fbd
Fix bracket position
stephen-crawford Nov 16, 2022
0faf6e9
try to fix the file suffixes
stephen-crawford Nov 16, 2022
3d0a1fa
Remove -f from del
stephen-crawford Nov 16, 2022
0f14071
LS directories
stephen-crawford Nov 16, 2022
cb6bf84
Fix name paths
stephen-crawford Nov 16, 2022
9bf4fb2
Remove SNAPSHOT mention from Linux
stephen-crawford Nov 16, 2022
2ec2a27
Fix missing bracket
stephen-crawford Nov 16, 2022
8044b7f
Path changes
stephen-crawford Nov 16, 2022
9d62afe
Remove doubled directory name
stephen-crawford Nov 16, 2022
e8ef729
Remove doubled directory name
stephen-crawford Nov 16, 2022
cf8a512
Check plugin install path names
stephen-crawford Nov 16, 2022
1b23eb7
Change plugin file name
stephen-crawford Nov 16, 2022
562d45b
Change plugin file name
stephen-crawford Nov 16, 2022
5c34160
Add echos
stephen-crawford Nov 17, 2022
e9971bd
Edit file names for mv and del
stephen-crawford Nov 17, 2022
f0d8cbd
Add extra 0 to OS sec version
stephen-crawford Nov 17, 2022
fa6cc22
removed echos
stephen-crawford Nov 17, 2022
7e29565
Fix wildcard in windows extraction and change pipe in linux run
stephen-crawford Nov 17, 2022
6b45e15
Add echoes every step
stephen-crawford Nov 17, 2022
bc6960c
Add echoes every step
stephen-crawford Nov 17, 2022
0c38049
Cd back and then installl
stephen-crawford Nov 17, 2022
3e97659
Use min builds instead of distributions
stephen-crawford Nov 17, 2022
99cb135
Add SNAPSHOT suffix
stephen-crawford Nov 17, 2022
fa406a2
add .sh
stephen-crawford Nov 17, 2022
b2cf121
Test linux, fixed path name
stephen-crawford Nov 17, 2022
bb7f5f3
Fix pipe format
stephen-crawford Nov 17, 2022
c1a3977
Add echo for steps
stephen-crawford Nov 17, 2022
6a7dd18
Add echo for steps
stephen-crawford Nov 17, 2022
2b09732
use arrows instead of bars
stephen-crawford Nov 17, 2022
f1aabcb
Add echo to front of install
stephen-crawford Nov 17, 2022
83e81dc
Try process again
stephen-crawford Nov 17, 2022
3d2c12e
Try to make sure file path is correct for plugin file install
stephen-crawford Nov 17, 2022
7ff3310
Use pwd in linux install
stephen-crawford Nov 17, 2022
a17cc0a
Use pwd in linux install
stephen-crawford Nov 17, 2022
fe030ba
remove echo for pipe
stephen-crawford Nov 17, 2022
c8146a6
Try with quotes
stephen-crawford Nov 17, 2022
2d35d95
Try printf '%s\n' y n n y y n
stephen-crawford Nov 17, 2022
ff5ff60
Try no pipinh
stephen-crawford Nov 17, 2022
b3d3f57
Bin/bash -c
stephen-crawford Nov 17, 2022
c330eb6
Bin/bash -c
stephen-crawford Nov 17, 2022
51eac85
Add ls for os dir paths
stephen-crawford Nov 17, 2022
e8b18ee
Add ls for os dir paths
stephen-crawford Nov 17, 2022
49a27b2
Fix permissions
stephen-crawford Nov 17, 2022
0639752
Work?
stephen-crawford Nov 17, 2022
62d62bd
Ls OS bin:
stephen-crawford Nov 17, 2022
03fb2de
Remove suffix
stephen-crawford Nov 17, 2022
771c205
Test Linux and JDK 17
stephen-crawford Nov 17, 2022
639f217
specify bin/bash for run
stephen-crawford Nov 17, 2022
009bcf7
Craig's suggestion
stephen-crawford Nov 17, 2022
318e6c6
Test on windows and linux fully without docker
stephen-crawford Nov 17, 2022
cc6e627
Re enable workflows
stephen-crawford Nov 17, 2022
39dac1a
Try setup script
stephen-crawford Nov 17, 2022
73437ca
diasble extra workflows
stephen-crawford Nov 17, 2022
457a7be
fix pathes in workflow
stephen-crawford Nov 17, 2022
32ec5c0
Different cat pattern for Windows
stephen-crawford Nov 18, 2022
2828bf8
Remove config settings
stephen-crawford Nov 18, 2022
99d5df1
Swap to && from &
stephen-crawford Nov 18, 2022
f31f9d1
Fix linux
stephen-crawford Nov 18, 2022
d2cb0df
Fix linux
stephen-crawford Nov 18, 2022
f773d4e
Fix ands in ifs
stephen-crawford Nov 18, 2022
399c012
remove quotes from true
stephen-crawford Nov 18, 2022
6ab899d
remove quotes from true
stephen-crawford Nov 18, 2022
6698382
Readd quotes to true
stephen-crawford Nov 18, 2022
5ed4e99
Fix permission mistake
stephen-crawford Nov 18, 2022
a2b5940
Add note for when running windows setup script
stephen-crawford Nov 18, 2022
812ac69
Try to fix how command added to windows script
stephen-crawford Nov 18, 2022
caa4784
Try to fix how command added to windows script
stephen-crawford Nov 18, 2022
e7be66c
Call windows command
stephen-crawford Nov 18, 2022
39b6eb2
Remove arguments
stephen-crawford Nov 18, 2022
d8f70e3
Try with bash in powershell
stephen-crawford Nov 18, 2022
9daa340
Retry windows
stephen-crawford Nov 18, 2022
1f429a5
Try redirection
stephen-crawford Nov 18, 2022
eaed816
Print out bat script
stephen-crawford Nov 18, 2022
fb31b63
Assign args variable before
stephen-crawford Nov 18, 2022
7e69404
Escape Args
stephen-crawford Nov 18, 2022
54e1839
Reddit solution
stephen-crawford Nov 18, 2022
05a01ef
swap shell type
stephen-crawford Nov 18, 2022
0f5f910
swap shell type
stephen-crawford Nov 18, 2022
5a3835f
Add call and get content to the script
stephen-crawford Nov 18, 2022
860e4ef
Add echos and @
stephen-crawford Nov 18, 2022
865d6c2
Swap to action version of assemble
stephen-crawford Nov 18, 2022
5c61919
Cat the windows script
stephen-crawford Nov 18, 2022
327ed3e
Start the bat file
stephen-crawford Nov 18, 2022
7bfe168
Try slash bat file
stephen-crawford Nov 18, 2022
6f8af46
Flip slash
stephen-crawford Nov 18, 2022
0d0ae7d
Echo then call?
stephen-crawford Nov 18, 2022
f734caf
YYN Call?
stephen-crawford Nov 18, 2022
2a3ae75
YYN No call
stephen-crawford Nov 18, 2022
1cff85a
Escape pipe
stephen-crawford Nov 18, 2022
6943562
Escape pipe with echo and call
stephen-crawford Nov 18, 2022
bbff221
Escape pipe with echo and call
stephen-crawford Nov 18, 2022
2c945df
Escape pipe with echo and call
stephen-crawford Nov 18, 2022
92d7812
Put echo afterwards
stephen-crawford Nov 18, 2022
edf13b7
Confirm false
stephen-crawford Nov 18, 2022
72bc233
>> then start in pwsh
stephen-crawford Nov 18, 2022
f8076de
invoke expression the setup bat
stephen-crawford Nov 18, 2022
eb19fc3
different echo format
stephen-crawford Nov 18, 2022
bc748c8
different echo format
stephen-crawford Nov 18, 2022
bbf8924
Try not call for setup.bat
stephen-crawford Nov 18, 2022
5c80f70
Try not call for setup.bat
stephen-crawford Nov 18, 2022
ab63241
Try cmd.exe
stephen-crawford Nov 18, 2022
04b2457
Try with specifying powershell
stephen-crawford Nov 21, 2022
4651ff4
Try with specifying powershell and using set-content
stephen-crawford Nov 21, 2022
e325a2d
Try with specifying powershell and using set-content
stephen-crawford Nov 21, 2022
5e04677
Test window and linux with setup script using jdk 11 and 17
stephen-crawford Nov 21, 2022
73eed5a
Re-enable other workflows
stephen-crawford Nov 21, 2022
57a6ae4
Merge branch 'main' into SetupForPluginInstall
stephen-crawford Nov 21, 2022
fa44b6c
Readd sanity test
stephen-crawford Nov 21, 2022
741f9ca
Correct changes from merge conflicts
stephen-crawford Nov 21, 2022
4a5af66
Add missing new line
stephen-crawford Nov 21, 2022
d5ebffa
Add missing new line
stephen-crawford Nov 21, 2022
86b85e7
Use environment variables
stephen-crawford Nov 21, 2022
0301e1a
Use environment variables
stephen-crawford Nov 21, 2022
e25d2d8
Retry env variable formatting and passing
stephen-crawford Nov 21, 2022
37d8c14
Fixed description for setup-script
stephen-crawford Nov 22, 2022
73aa65d
Fixed description for setup-script and rename job steps
stephen-crawford Nov 22, 2022
c30d2be
Swapped to not required
stephen-crawford Nov 23, 2022
e287b17
Swap setup parameter to script name
stephen-crawford Nov 28, 2022
94fad5b
Add .sh file extension
stephen-crawford Nov 28, 2022
c9f3587
Try /c
stephen-crawford Nov 28, 2022
7b814b4
Retry without /c
stephen-crawford Nov 28, 2022
13dfcfc
Readd CI
stephen-crawford Nov 28, 2022
396e087
Retry flaky test
stephen-crawford Nov 28, 2022
2487fe3
Retry flaky test
stephen-crawford Nov 28, 2022
0be4a79
Retry flaky test
stephen-crawford Nov 28, 2022
962677d
Rename fields
stephen-crawford Nov 28, 2022
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
73 changes: 36 additions & 37 deletions .github/actions/start-opensearch-with-one-plugin/action.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Start OpenSearch with One Plugin'
name: 'Launch OpenSearch with a single plugin installed'
description: 'Downloads latest build of OpenSearch, installs a plugin, executes a script and then starts OpenSearch on localhost:9200'

inputs:
Expand All @@ -10,14 +10,10 @@ inputs:
description: 'The name of the plugin to use, such as opensearch-security'
required: true

plugin-start-script:
description: 'The file name for the configuration script for the plugin such as install_demo_configurations -- may not be needed for every plugin'
setup-script-name:
description: 'The name of the setup script you want to run i.e. "setup" (do not include file extension). Leave empty to indicate one should not be run.'
required: false

docker-host-plugin-zip:
description: 'The name of the zip file for the plugin hosted on docker-host i.e. security-plugin.zip '
required: true

runs:
using: "composite"
steps:
Expand All @@ -29,25 +25,28 @@ runs:
shell: pwsh

# Download OpenSearch
- uses: peternied/download-file@v1
- name: Download OpenSearch for Windows
uses: peternied/download-file@v1
if: ${{ runner.os == 'Windows' }}
with:
url: https://artifacts.opensearch.org/snapshots/core/opensearch/${{ inputs.opensearch-version }}-SNAPSHOT/opensearch-min-${{ inputs.opensearch-version }}-SNAPSHOT-windows-x64-latest.zip

- uses: peternied/download-file@v1

- name: Download OpenSearch for Linux
uses: peternied/download-file@v1
if: ${{ runner.os == 'Linux' }}
with:
url: https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/${{ inputs.opensearch-version }}/latest/linux/x64/tar/builds/opensearch/dist/opensearch-min-${{ inputs.opensearch-version }}-linux-x64.tar.gz
url: https://artifacts.opensearch.org/snapshots/core/opensearch/${{ inputs.opensearch-version }}-SNAPSHOT/opensearch-min-${{ inputs.opensearch-version }}-SNAPSHOT-linux-x64-latest.tar.gz

# Extract downloaded zip
- name: Extract downloaded zip for Linux
- name: Extract downloaded tar
if: ${{ runner.os == 'Linux' }}
run: |
tar -xzf opensearch-*.tar.gz
rm -f opensearch-*.tar.gz
shell: bash

- name: Extract downloaded zip for Windows
- name: Extract downloaded zip
if: ${{ runner.os == 'Windows' }}
run: |
tar -xzf opensearch-min-${{ inputs.opensearch-version }}-SNAPSHOT-windows-x64-latest.zip
Expand All @@ -59,41 +58,38 @@ runs:
run: mv ./build/distributions/${{ inputs.plugin-name }}-*.zip ${{ inputs.plugin-name }}.zip
shell: bash

# Install the plugin, runs its start-script, and start the OpenSearch server
# Install the plugin
- name: Install Plugin into OpenSearch for Linux
if: ${{ runner.os == 'Linux'}}
run: |
cat > os-ep.sh <<EOF
yes | opensearch-plugin install file:///docker-host/${{ inputs.docker-host-plugin-zip }}.zip
chmod +x plugins/${{ inputs.plugin-name }}/tools/${{ inputs.plugin-start-script }}.sh
yes | plugins/${{ inputs.plugin-name }}/tools/${{ inputs.plugin-start-script }}.sh
chown 1001:1001 -R /opensearch
su -c "/opensearch/bin/opensearch" -s /bin/bash opensearch
EOF
docker build -t opensearch-test -f- . <<EOF
FROM ubuntu:latest
COPY --chown=1001:1001 os-ep.sh /docker-host/
COPY --chown=1001:1001 ${{ inputs.plugin-name }}.zip /docker-host/${{ inputs.docker-host-plugin-zip }}.zip
COPY --chown=1001:1001 opensearch* /opensearch/
RUN chmod +x /docker-host/os-ep.sh
RUN useradd -u 1001 -s /sbin/nologin opensearch
ENV PATH="/opensearch/bin:${PATH}"
WORKDIR /opensearch/
ENTRYPOINT /docker-host/os-ep.sh
EOF
chmod +x ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/bin/opensearch-plugin
/bin/bash -c "yes | ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/bin/opensearch-plugin install file:$(pwd)/opensearch-security.zip"
shell: bash

- name: Install Plugin into OpenSearch for Windows
if: ${{ runner.os == 'Windows'}}
run: |
'y' | .\opensearch-${{ inputs.opensearch-version }}-SNAPSHOT\bin\opensearch-plugin.bat install file:$pwd\${{ inputs.plugin-name }}.zip
'y', 'y', 'N' | .\opensearch-${{ inputs.opensearch-version }}-SNAPSHOT\plugins\${{ inputs.plugin-name }}\tools\${{ inputs.plugin-start-script }}.bat
'y' | .\opensearch-${{ inputs.opensearch-version }}-SNAPSHOT\bin\opensearch-plugin.bat install file:$(pwd)\${{ inputs.plugin-name }}.zip
shell: pwsh

# Run any configuration scripts
- name: Run Setup Script for Linux
if: ${{ runner.os == 'Linux' && inputs.setup-script-name != '' }}
run: |
echo "running linux setup"
chmod +x ./${{ inputs.setup-script-name }}.sh
./${{ inputs.setup-script-name }}.sh
shell: bash

- name: Run Setup Script for Windows
if: ${{ runner.os == 'Windows' && inputs.setup-script-name != '' }}
run: .\${{ inputs.setup-script-name }}.bat
shell: pwsh

# Run OpenSearch
- name: Run OpenSearch with plugin on Linux
if: ${{ runner.os == 'Linux'}}
run: docker run --name ops -d -p 9200:9200 -p 9600:9600 -i opensearch-test:latest
run: /bin/bash -c "./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/bin/opensearch &"
Copy link
Member

Choose a reason for hiding this comment

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

This command is set to run in background here with &. Any specific reason why background and not normally?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because you want it to be a background so that it is able run detached outside of docker.

Copy link
Member

Choose a reason for hiding this comment

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

okie...in my understanding... everything runs outside docker now..so I'm still not sure how this would help (not saying it shouldn't be as it is)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Basically, the process fails if you do not detach the call. So by making it a background process everything works because then you can have it operate in the background and then go make a curl to it. Otherwise you cannot/would need to open a new terminal during the execution to curl to it. This is my understanding at least--it fails without the & so I added it at Craig's suggestion.

Copy link
Member

Choose a reason for hiding this comment

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

@DarshitChanpura This call is blocking if it is not detached and the rest of the action does not execute.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@scrawfor99 So is there any difference between running it in this way and running it with docker run?

shell: bash

- name: Run OpenSearch with plugin on Windows
Expand All @@ -110,9 +106,7 @@ runs:
# Verify that the server is operational
- name: Check OpenSearch Running on Linux
if: ${{ runner.os != 'Windows'}}
run: |
docker logs ops
curl https://localhost:9200/_cat/plugins -u 'admin:admin' -k -v
run: curl https://localhost:9200/_cat/plugins -u 'admin:admin' -k -v
shell: bash

- name: Check OpenSearch Running on Windows
Expand All @@ -124,3 +118,8 @@ runs:
$Headers = @{ Authorization = $baseCredentials }
Invoke-WebRequest -SkipCertificateCheck -Uri 'https://localhost:9200/_cat/plugins' -Headers $Headers;
shell: pwsh

- name: Run sanity tests
uses: gradle/gradle-build-action@v2
with:
arguments: integTestRemote -Dtests.rest.cluster=localhost:9200 -Dtests.cluster=localhost:9200 -Dtests.clustername="opensearch" -Dhttps=true -Duser=admin -Dpassword=admin
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Bulk Integration Test

on: [ workflow_dispatch ]
on: [workflow_dispatch]

env:
GRADLE_OPTS: -Dhttp.keepAlive=false
Expand Down
33 changes: 27 additions & 6 deletions .github/workflows/plugin_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@ name: Plugin Install

on: [push, pull_request, workflow_dispatch]

env:
OPENSEARCH_VERSION: 3.0.0
PLUGIN_NAME: opensearch-security

jobs:
plugin-install:
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
os: [ubuntu-latest, windows-latest]
jdk: [11, 17]
runs-on: ${{ matrix.os }}

steps:
- name: Set up JDK
uses: actions/setup-java@v1
Expand All @@ -20,15 +25,31 @@ jobs:
uses: actions/checkout@v2

- name: Assemble target plugin
run: ./gradlew assemble
uses: gradle/gradle-build-action@v2
with:
arguments: assemble

- name: Create Setup Script
if: ${{ runner.os == 'Linux' }}
run: |
cat > setup.sh <<'EOF'
chmod +x ./opensearch-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT/plugins/${{ env.PLUGIN_NAME }}/tools/install_demo_configuration.sh
/bin/bash -c "yes | ./opensearch-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT/plugins/${{ env.PLUGIN_NAME }}/tools/install_demo_configuration.sh"
EOF

- name: Create Setup Script
if: ${{ runner.os == 'Windows' }}
run: |
New-Item .\setup.bat -type file
Set-Content .\setup.bat -Value "powershell.exe -noexit -command `"echo 'y' | .\opensearch-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT\plugins\${{ env.PLUGIN_NAME }}\tools\install_demo_configuration.bat`""
Get-Content .\setup.bat

- name: Run Opensearch with A Single Plugin
uses: ./.github/actions/start-opensearch-with-one-plugin
with:
opensearch-version: 3.0.0
plugin-name: opensearch-security
plugin-start-script: install_demo_configuration
docker-host-plugin-zip: security-plugin.zip
opensearch-version: ${{ env.OPENSEARCH_VERSION }}
plugin-name: ${{ env.PLUGIN_NAME }}
setup-script-name: setup

- name: Run sanity tests
Copy link
Member

Choose a reason for hiding this comment

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

Why did we remove the sanity test step?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So I realized that during the conflict resolution it messed up some of the files so I think that is why things looked so weird to you before. I readded this and fixed the copying over of the action to the workflow.

uses: gradle/gradle-build-action@v2
Expand Down