Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ tmp/
bin/
dist/
ocp-cluster/
*.pyc

# IDE folders
.vscode/
Expand Down
1 change: 1 addition & 0 deletions ansible_pip_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ rsa==4.9.1 --hash=sha256:68635866661c6836b8d39430f97a996acbd61bfa49406748ea24353
oauthlib==3.2.2 --hash=sha256:8139f29aac13e25d502680e9e19963e83f16838d48a0d71c287fe40e7067fbca
jsonschema==4.26.0 --hash=sha256:d489f15263b8d200f8387e64b4c3a75f06629559fb73deb8fdfb525f2dab50ce
rpds-py==0.30.0 --hash=sha256:47f236970bccb2233267d89173d3ad2703cd36a0e2a6e92d0560d333871a3d23
click==8.3.3 --hash=sha256:398329ad4837b2ff7cbe1dd166a4c0f8900c3ca3a218de04466f38f6497f18a2
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,16 @@
script: |
#!/bin/bash
cat <<EOF > approve_installplans.py
{{ lookup('ansible.builtin.file', '../helpers/operator-update/approve_installplans.py') }}
cat <<EOF > reconcile_operator_versions.py
{{ lookup('ansible.builtin.file', '../reconcile/operator_versions.py') }}
EOF
- name: operator-update
image: "{{ oc_cli_image }}"
workingDir: $(workspaces.shared-data.path)
script: |
#!/bin/bash
python ./approve_installplans.py "{{ (_core_plugin_operators | default([])) + operators }}" "$(params.dry-run)" > "$(results.status-report.path)"
python ./reconcile_operator_versions.py "{{ (_core_plugin_operators | default([])) + operators }}" "$(params.dry-run)" > "$(results.status-report.path)"
rc=$?
echo -n "${rc}" > "$(results.exit-code.path)"
exit "${rc}"
Expand Down
2 changes: 1 addition & 1 deletion playbooks/tasks/configure_operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
- r_sub_check.resources | length == 0
- operator.namespace != "openshift-operators"
ansible.builtin.shell: |
python ../helpers/operator-update/approve_installplans.py "{{ [operator] }}" "False"
python ../reconcile/cli.py operator-versions --operators "{{ [operator] }}" --no-dry-run
register: operator_update_result

- name: Print the output
Expand Down
28 changes: 28 additions & 0 deletions reconcile/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import click
import sys

from operator_versions import reconcile as operator_versions_reconcile


@click.group()
def cli():
pass


@cli.command()
@click.option("--operators", default="[]")
@click.option("--dry-run/--no-dry-run", default=False)
def operator_versions(operators, dry_run):
# rebuild sys.argv for the standalone script
sys.argv = ["operator_versions.py", operators, str(dry_run)]

operator_versions_reconcile()


@cli.command()
def mgmt_cluster_version():
raise click.ClickException("mgmt-cluster-version is not implemented yet")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Happy to implement this once this is merged.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yes! ref: #123



if __name__ == "__main__":
cli()
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def init_ns_op_version_map(
return ns_op_version_map


def main():
def reconcile():
try:
operators = ast.literal_eval(sys.argv[1])
except (IndexError, ValueError, SyntaxError) as e:
Expand Down Expand Up @@ -180,4 +180,4 @@ def main():


if __name__ == "__main__":
main()
reconcile()
Loading