Skip to content

Commit

Permalink
Setup SG3 CI system (#107)
Browse files Browse the repository at this point in the history
* Enhance CI automation (#106)

* Add ServiceTelemetry overrides

Allows ServiceTelemetry overrides to be expressed via Ansible extra-vars. Adds the four
main overrides you would expect in a ServiceTelemetry object, with appropriate defaults
set.

Will also allow passing in the service_telemetry_manifest as a whole object like what we
do with the Service Telemetry Operator.

* Allow for per-repo branch overrides

Allow for per-repo branch overrides for the Smart Gateway Operator and Smart Gateway
repositories via sgo_branch and sg_branch (respectively).

* Add functionality around quickstart.sh

Add some functionality that was replaced when I dropped the quickstart.sh. Adds
some of this functionality back in and also adds some new stuff.

* Fix syntax error

* Add back quickstart.sh

Adds back a quickstart.sh that simulates the same result as the old
quickstart.sh

* Better CSV modification support

Also adds some tags to make skipping over builds for testing much
easier.

* Debugging ci.yml firing

* Make sure namespace is set before using it

* Fix syntax and documentation

* Test locally first kids

* Drop CI debug lines

* Clean up working repo clones

* Copy CSV into working directory

On subsequent runs the in-place modification of the CSV can cause issues either
in the development environment, or re-runs of the CI system. Copying the CSV out
of the in-place repo into a working location, and then modifying in-place results
in a cleaner setup.

By doing the copy of the CSV files, we can drop the need to force clone the supporting
repositories.

Also cleans up some shell commands that were commented out now that they are being
dealt with via the replace module. Removes the extra commands added to ci.yml.

* Changes to infrared-openstack.sh for OSP13 (#102)

* Migrate OSP16 script to OSP13 directory

Uses a multi-cloud stf-connectors.yaml style configuration which directly loads
the resource lists rather than a list of environment files. Uses the same script
as used in OSP16 but subs out the network configuration for a vlan type setup and the
latest paths for async puddle.

* Working deployment of OSP13

* Migrate changes to align to existing docs

Update PR to align to existing documentation and testing the group has been working on.
Adjust the stf-connectors.yaml.template to better reflect what we've been testing.

Deployment by default will result in presettle: true which is bad for reliability of
message delivery.

* Get closer alignment to OSP16 setup

* Enable deployment of metric SG for Ceilometer data (#93)

* Enable deployment of metric SG for Ceilometer data

Depends-On: infrawatch/smart-gateway#83
Depends-On: infrawatch/smart-gateway-operator#48

* Add smoketest for Ceilometer data

* Listen on correct channel

* Ceilometer smoketest tuning

Makes smoketest_ceilometer_entrypoint.sh being executed during smoketest job.

* Use data source setting for metrics too
	# Please enter the commit message for your changes. Lines starting
	# with '#' will be ignored, and an empty message aborts the commit.
	#
	# On branch mmagr-amqp10connections
	# Changes to be committed:
	#	modified:   roles/servicetelemetry/templates/manifest_smartgateway_metrics.j2
	#

* Finish ceilometer events smoke test

* Do not use hardcoded timestamps

* Finish ceilometer metrics smoketests

* Increase timeout

* Add container names

* Validate also Ceilometer metrics SG

* Update tests/smoketest/smoketest_ceilometer_entrypoint.sh

* Update tests/smoketest/smoketest_collectd_entrypoint.sh

Co-authored-by: Martin Magr <[email protected]>
Co-authored-by: Leif Madsen <[email protected]>

* Implement CI updates for SG3

* Correct value for SG bridge image path

* Lock operator-courier to 2.1.7

Lock operator-courier to 2.1.7 until we can figure out what is wrong with our CSV/CRD setup
or until the operator-courier issue noted in the related issue is resolved.

Related: #108

* Update build/stf-run-ci/tasks/main.yml

Co-authored-by: Chris Sibbitt <[email protected]>

* Adjust README to match run-ci.yaml methods

Co-authored-by: Martin Mágr <[email protected]>
Co-authored-by: Martin Magr <[email protected]>
Co-authored-by: Chris Sibbitt <[email protected]>
  • Loading branch information
4 people authored Jul 13, 2020
1 parent 3970678 commit 89cba07
Show file tree
Hide file tree
Showing 23 changed files with 898 additions and 326 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ language: python
git:
depth: 1
install:
- pip install operator-courier
- pip install operator-courier==2.1.7
- pip install ansible-lint
script:
- operator-courier verify --ui_validate_io deploy/olm-catalog/service-telemetry-operator
Expand Down
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,19 @@ run the `quickstart.sh` script located in the `deploy/` directory after starting
up a [CodeReady Containers](https://github.com/code-ready/crc) environment.

To deploy a local build of the Service Telemetry Operator itself, start by
running `build/build_ci.sh`. Once that's done, you can test new builds of the
core operator code like this:
running `ansible-playbook build/run-ci.yaml`. If you have code to coordinate
across the supporting InfraWatch repositories, you can pass the
`working_branch` paramater to the `--extra-vars` flag like so:

```shell
./build/build.sh &&\
./build/push_container2ocp.sh &&\
oc delete po -l name=service-telemetry-operator
ansible-playbook \
--extra-vars working_branch="username-new_feature" \
build/run-ci.yaml
```

Additional flags for overriding various branch and path names is documented in
`build/stf-run-ci/README.md`.

## CI

### Travis
Expand Down
1 change: 0 additions & 1 deletion build/metadata.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ OCP_REGISTRY=${OCP_REGISTRY:-$(oc registry info)}
OCP_REGISTRY_INTERNAL=${OCP_REGISTRY_INTERNAL:-$(oc registry info --internal=true)}
OCP_TAG=${OCP_TAG:-latest}
OCP_USER=${OCP_USER:-openshift}
QUICKSTART_CONFIG=${QUICKSTART_CONFIG:-configs/default.bash}
62 changes: 60 additions & 2 deletions build/stf-run-ci/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
stf-run-ci
=========
==========

Run the Service Telemetry Framework CI system. This role is intended to be
called from a playbook running locally on a preconfigured test system.
Expand All @@ -9,9 +9,67 @@ Requirements
------------

- CodeReady Containers
- Ansible
- Ansible 2.9 (tested)
- `oc` command line tool

Variables
---------

Not all variables are listed here, but these are the most common ones you might
choose to override:

| Parameter name | Values | Default | Description |
| ------------------------------ | ------------ | --------- | ------------------------------------ |
| `__deploy_stf` | {true,false} | true | Whether to deploy an instance of STF |
| `__local_build_enabled` | {true,false} | true | Whether to deploySTF from local built artifacts. Also see `working_branch`, `sg_branch`, `sgo_branch` |
| `sgo_branch` | <git_branch> | master | Which Smart Gateway Operator git branch to checkout |
| `sg_branch` | <git_branch> | master | Which Smart Gateway git branch to checkout |
| `sg_core_branch` | <git_branch> | master | Which Smart Gateway Core git branch to checkout |
| `sg_bridge_branch` | <git_branch> | master | Which Smart Gateway Bridge git branch to checkout |
| `__service_telemetry_events_enabled` | {true,false} | true | Whether to enable events support in ServiceTelemetry |
| `__service_telemetry_high_availability_enabled` | {true,false} | false | Whether to enable high availability support in ServiceTelemetry |
| `__service_telemetry_metrics_enabled` | {true,false} | true | Whether to enable metrics support in ServiceTelemetry |
| `__service_telemetry_storage_ephemeral_enabled` | {true,false} | false | Whether to enable ephemeral storage support in ServiceTelemetry |


Example Playbook
----------------

```yaml
---
# run STF CI setup in CRC (already provisioned)
- hosts: localhost
connection: local
tasks:
- name: Run the STF CI system
import_role:
name: stf-run-ci
```
Usage
-----
You can deploy Service Telemetry Framework using this role in a few
configuration methods:
* local build artifacts from Git repository cloned locally
* standard deployment using Subscription and OLM
* supporting components but no instance of Service Telemetry Operator
You can deploy using the sample `run-ci.yaml` from the _Example Playbook_
section:

```
ansible-playbook run-ci.yaml
```

If you want to do a standard deployment (existing remote artifacts) you can use
the following command:

```
ansible-playbook --extra-vars __local_build_enabled=false run-ci.yaml
```

License
-------

Expand Down
8 changes: 8 additions & 0 deletions build/stf-run-ci/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,11 @@ list_of_stf_objects:
- service-telemetry-operator
- smart-gateway-operator
- smart-gateway

__local_build_enabled: true
__deploy_stf: true

__service_telemetry_events_enabled: true
__service_telemetry_high_availability_enabled: false
__service_telemetry_metrics_enabled: true
__service_telemetry_storage_ephemeral_enabled: false
40 changes: 35 additions & 5 deletions build/stf-run-ci/tasks/clone_repos.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,60 @@
---
# clone our other repositories into this repo
# NOTE: since you can't loop against blocks (and we're using them for failure #
# recovery when the request branch doesn't exist) we have to define each
# of these separately rather than using a loop.
- name: Get Smart Gateway Operator
block:
- name: Try cloning same-named branch
- name: Try cloning same-named branch or override branch
git:
repo: https://github.com/infrawatch/smart-gateway-operator
dest: working/smart-gateway-operator
version: "{{ branch }}"
version: "{{ sgo_branch | default(branch, true) }}"
rescue:
- name: Get master branch because same-named doesn't exist
git:
repo: https://github.com/infrawatch/smart-gateway-operator
dest: working/smart-gateway-operator
version: master

- name: Get Smart Gateway
- name: Get Smart Gateway (legacy)
block:
- name: Try cloning same-named branch
- name: Try cloning same-named branch or override branch
git:
repo: https://github.com/infrawatch/smart-gateway
dest: working/smart-gateway
version: "{{ branch }}"
version: "{{ sg_branch | default(branch, true) }}"
rescue:
- name: Get master branch because same-named doesn't exist
git:
repo: https://github.com/infrawatch/smart-gateway
dest: working/smart-gateway
version: master

- name: Get sg-core
block:
- name: Try cloning same-named branch or override branch
git:
repo: https://github.com/infrawatch/sg-core
dest: working/sg-core
version: "{{ sg_core_branch | default(branch, true) }}"
rescue:
- name: Get master branch because same-named doesn't exist
git:
repo: https://github.com/infrawatch/sg-core
dest: working/sg-core
version: master

- name: Get sg-bridge
block:
- name: Try cloning same-named branch or override branch
git:
repo: https://github.com/infrawatch/sg-bridge
dest: working/sg-bridge
version: "{{ sg_bridge_branch | default(branch, true) }}"
rescue:
- name: Get master branch because same-named doesn't exist
git:
repo: https://github.com/infrawatch/sg-bridge
dest: working/sg-bridge
version: master
63 changes: 13 additions & 50 deletions build/stf-run-ci/tasks/deploy_stf.yml
Original file line number Diff line number Diff line change
@@ -1,58 +1,21 @@
---
# TODO: not super pretty but it seems to work for now. Would be a bit cleaner
# perhaps if we imported a semver function of some sort.
- name: Get latest CSV for Smart Gateway Operator
shell: |
ls -1v --hide=*.yaml working/smart-gateway-operator/deploy/olm-catalog/smart-gateway-operator/ | tail -1
register: sgo_current_csv

- name: Get latest CSV for Service Telemetry Operator
shell: |
ls -1v --hide=*.yaml ../deploy/olm-catalog/service-telemetry-operator/ | tail -1
register: sto_current_csv

- name: Load Smart Gateway Operator RBAC
command: oc apply -f working/smart-gateway-operator/deploy/{{ item }}
loop:
- service_account.yaml
- role.yaml
- role_binding.yaml
- olm-catalog/smart-gateway-operator/{{ sgo_current_csv.stdout }}/smartgateway.infra.watch_smartgateways_crd.yaml

# TODO: I'm sorry this is pretty messy. There is probably an Ansible module
# that would make this a bit cleaner to read. Likely start with lineinfile or a
# filter that could parse the contents inline via lookup to the k8s module
- name: Load Smart Gateway Operator CSV
shell: |
sed -e "s#quay.io/infrawatch/smart-gateway:latest#{{ sg_image_path }}#g;s#quay.io/infrawatch/smart-gateway-operator:latest#{{ sgo_image_path }}#g;s#placeholder#{{ namespace }}#g" working/smart-gateway-operator/deploy/olm-catalog/smart-gateway-operator/{{ sgo_current_csv.stdout }}/smart-gateway-operator.v{{ sgo_current_csv.stdout }}.clusterserviceversion.yaml | oc apply -f -
- name: Load Service Telemetry Operator RBAC
command: oc apply -f ../deploy/{{ item }}
loop:
- service_account.yaml
- role.yaml
- role_binding.yaml
- olm-catalog/service-telemetry-operator/{{ sto_current_csv.stdout }}/infra.watch_servicetelemetrys_crd.yaml

- name: Load Service Telemetry Operator CSV
shell: |
sed -e "s#quay.io/infrawatch/service-telemetry-operator:v{{ sto_current_csv.stdout }}#{{ sto_image_path }}#g;s#placeholder#{{ namespace }}#g" ../deploy/olm-catalog/service-telemetry-operator/{{ sto_current_csv.stdout }}/service-telemetry-operator.v{{ sto_current_csv.stdout }}.clusterserviceversion.yaml | oc apply -f -
- name: Wait for Service Telemetry Operator to be Succeeded
shell: |
while ! oc get csv | grep service-telemetry-operator | grep Succeeded; do echo "waiting for Service Telemetry Operator..."; sleep 3; done
# NOTE: be aware that if the API version changes for the ServiceTelemetry
# object that it'll need to be updated here
- name: Create ServiceTelemetry instance
k8s:
definition:
- name: Create default ServiceTelemetry manifest
set_fact:
service_telemetry_manifest: |
apiVersion: infra.watch/v1alpha1
kind: ServiceTelemetry
metadata:
name: stf-default
namespace: "{{ namespace }}"
spec:
eventsEnabled: true
highAvailabilityEnabled: false
metricsEnabled: true
eventsEnabled: {{ __service_telemetry_events_enabled }}
highAvailabilityEnabled: {{ __service_telemetry_high_availability_enabled }}
metricsEnabled: {{ __service_telemetry_metrics_enabled }}
storageEphemeralEnabled: {{ __service_telemetry_storage_ephemeral_enabled }}
when: service_telemetry_manifest is not defined

- name: Create ServiceTelemetry instance
k8s:
definition:
'{{ service_telemetry_manifest }}'
91 changes: 65 additions & 26 deletions build/stf-run-ci/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,68 @@
branch: "{{ working_branch | default('master') }}"
namespace: "{{ working_namespace | default('service-telemetry') }}"

- name: Setup supporting repositories
include_tasks: clone_repos.yml

- name: Setup supporting Operator subscriptions
include_tasks: setup_base.yml

- name: Create builds and artifacts
include_tasks: create_builds.yml
loop:
- { name: service-telemetry-operator, dockerfile_path: build/Dockerfile, image_reference_name: sto_image_path, working_build_dir: ../ }
- { name: smart-gateway-operator, dockerfile_path: build/Dockerfile, image_reference_name: sgo_image_path, working_build_dir: ./working/smart-gateway-operator }
- { name: smart-gateway, dockerfile_path: Dockerfile, image_reference_name: sg_image_path, working_build_dir: ./working/smart-gateway }
loop_control:
loop_var: artifact

- name: Deploy STF using local artifacts
include_tasks: deploy_stf.yml

- name: Validate system is operational
shell: ./validate_deployment.sh
args:
executable: /bin/bash
register: validate_deployment

- debug:
var: validate_deployment.stdout_lines
- name: Set default image paths for local builds
set_fact:
sg_image_path: image-registry.openshift-image-registry.svc:5000/{{ namespace }}/smart-gateway:latest
sgo_image_path: image-registry.openshift-image-registry.svc:5000/{{ namespace }}/smart-gateway-operator:latest
sto_image_path: image-registry.openshift-image-registry.svc:5000/{{ namespace }}/service-telemetry-operator:latest
sg_core_image_path: image-registry.openshift-image-registry.svc:5000/{{ namespace }}/sg-core:latest
sg_bridge_image_path: image-registry.openshift-image-registry.svc:5000/{{ namespace }}/sg-bridge:latest

- block:
- name: Setup supporting repositories
include_tasks: clone_repos.yml
tags:
- clone

- name: Setup supporting Operator subscriptions
include_tasks: setup_base.yml
tags:
- deploy

- name: Create builds and artifacts
include_tasks: create_builds.yml
loop:
- { name: service-telemetry-operator, dockerfile_path: build/Dockerfile, image_reference_name: sto_image_path, working_build_dir: ../ }
- { name: smart-gateway-operator, dockerfile_path: build/Dockerfile, image_reference_name: sgo_image_path, working_build_dir: ./working/smart-gateway-operator }
- { name: smart-gateway, dockerfile_path: Dockerfile, image_reference_name: sg_image_path, working_build_dir: ./working/smart-gateway }
- { name: sg-core, dockerfile_path: build/Dockerfile, image_reference_name: sg_core_image_path, working_build_dir: ./working/sg-core }
- { name: sg-bridge, dockerfile_path: build/Dockerfile, image_reference_name: sg_bridge_image_path, working_build_dir: ./working/sg-bridge }
loop_control:
loop_var: artifact
tags:
- build

- name: Setup STF using local artifacts
include_tasks: setup_stf_local_build.yml
tags:
- deploy

when: __local_build_enabled | bool

- block:
- name: Setup supporting Operator subscriptions
include_tasks: setup_base.yml

- name: Setup Service Telemetry Framework from application registry
include_tasks: setup_stf.yml

when: not __local_build_enabled | bool

- name: Pre-flight checks
include_tasks: preflight_checks.yml

- block:
- name: Deploy an instance of STF
include_tasks: deploy_stf.yml

- name: Validate system is operational
shell: ./validate_deployment.sh
args:
executable: /bin/bash
register: validate_deployment

- debug:
var: validate_deployment.stdout_lines

when: __deploy_stf | bool
4 changes: 4 additions & 0 deletions build/stf-run-ci/tasks/preflight_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
- name: Wait for Service Telemetry Operator to be Succeeded
shell: |
while ! oc get csv | grep service-telemetry-operator | grep Succeeded; do echo "waiting for Service Telemetry Operator..."; sleep 3; done
Loading

0 comments on commit 89cba07

Please sign in to comment.