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

Deprecated inotify-tools on Ansible based-operator images and remove Ansible sidecar container. #2586

Merged
merged 2 commits into from
Feb 21, 2020
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@

### Deprecated

- The additional of the dependency `inotify-tools` on Ansible based-operator images. ([#2586](https://github.com/operator-framework/operator-sdk/pull/2586))

### Removed

- **Breaking Change:** The additional Ansible sidecar container. ([#2586](https://github.com/operator-framework/operator-sdk/pull/2586))

### Bug Fixes

- Fixed issue with Go dependencies caused by removed tag in `openshift/api` repository ([#2466](https://github.com/operator-framework/operator-sdk/issues/2466))
Expand Down
1 change: 1 addition & 0 deletions cmd/operator-sdk/migrate/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ func migrateAnsible() error {
&dockerfile,
&ansible.Entrypoint{},
&ansible.UserSetup{},
// todo(camilamacedo86): It is deprecated and should be removed before 1.0.0
&ansible.AoLogs{},
)
if err != nil {
Expand Down
12 changes: 4 additions & 8 deletions doc/ansible/dev/developer_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,18 +312,14 @@ foo-operator 1 1 1 1 1m

#### Viewing the Ansible logs

The `foo-operator` deployment creates a Pod with two containers, `operator` and `ansible`.
The `ansible` container exists only to expose the standard Ansible stdout logs that most Ansible
users will be familiar with. In order to see the logs from a particular container, you can run
In order to see the logs from a particular you can run:

```sh
kubectl logs deployment/foo-operator -c ansible
kubectl logs deployment/foo-operator -c operator
kubectl logs deployment/foo-operator
```

The `ansible` logs contain all of the information about the Ansible run and will make it much easier to debug issues within your Ansible tasks,
whereas the `operator` logs will contain much more detailed information about the Ansible Operator's internals and interface with Kubernetes.

The logs contain the information about the Ansible run and will make it much easier to debug issues within your Ansible tasks.
Note that the logs will contain much more detailed information about the Ansible Operator's internals and interface with Kubernetes as well.

## Custom Resource Status Management
The operator will automatically update the CR's `status` subresource with
Expand Down
11 changes: 4 additions & 7 deletions doc/ansible/user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,17 +354,14 @@ memcached-operator-7cc7cfdf86-vvjqk 2/2 Running 0 2m

### View the Ansible logs

The `memcached-operator` deployment creates a Pod with two containers, `operator` and `ansible`.
The `ansible` container exists only to expose the standard Ansible stdout logs that most Ansible
users will be familiar with. In order to see the logs from a particular container, you can run
In order to see the logs from a particular you can run:

```sh
kubectl logs deployment/memcached-operator -c ansible
kubectl logs deployment/memcached-operator -c operator
kubectl logs deployment/memcached-operator
```

The `ansible` logs contain all of the information about the Ansible run and will make it much easier to debug issues within your Ansible tasks,
whereas the `operator` logs will contain much more detailed information about the Ansible Operator's internals and interface with Kubernetes.
The logs contain the information about the Ansible run and will make it much easier to debug issues within your Ansible tasks.
Note that the logs will contain much more detailed information about the Ansible Operator's internals and interface with Kubernetes as well.

### Additional Ansible Debug

Expand Down
37 changes: 37 additions & 0 deletions doc/migration/version-upgrade-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,43 @@ This release contains breaking changes in some commands.

See the [CHANGELOG](https://github.com/operator-framework/operator-sdk/blob/master/CHANGELOG.md#v0151) for details of the release.

## Unreleased

### Breaking changes

#### Remove Ansible container sidecar

The additional of the dependency `inotify-tools` on Ansible based-operator images is deprecated and it will be removed in the next versions. In this way, update the `deploy/operator.yaml` file as follows.

Remove:

```
- name: ansible
command:
- /usr/local/bin/ao-logs
- /tmp/ansible-operator/runner
- stdout
# Replace this with the built image name
image: "REPLACE_IMAGE"
imagePullPolicy: "Always"
volumeMounts:
- mountPath: /tmp/ansible-operator/runner
name: runner
readOnly: true
```

Replace:

```yaml
- name: operator
```

With:

```yaml
- name: {{your operator name which is the value of metadata.name in this file}}
```

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@estroz I followed here your suggestion.
I will try to start to do that as well.
Let's see if it can build a good example/case in the order we start to do it for all.

[legacy-kubebuilder-doc-crd]: https://book-v1.book.kubebuilder.io/beyond_basics/generating_crd.html
[v0.8.2-go-mod]: https://github.com/operator-framework/operator-sdk/blob/28bd2b0d4fd25aa68e15d928ae09d3c18c3b51da/internal/pkg/scaffold/go_mod.go#L40-L94
[activating-modules]: https://github.com/golang/go/wiki/Modules#how-to-install-and-activate-module-support
Expand Down
1 change: 1 addition & 0 deletions hack/image/ansible/scaffold-ansible-image.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func main() {
&ansible.DockerfileHybrid{},
&ansible.Entrypoint{},
&ansible.UserSetup{},
// todo(camilamacedo86): It is deprecated and should be removed before 1.0.0
&ansible.AoLogs{},
camilamacedo86 marked this conversation as resolved.
Show resolved Hide resolved
)
if err != nil {
Expand Down
8 changes: 3 additions & 5 deletions hack/tests/e2e-ansible.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ operator_logs() {
header_text "Getting events"
kubectl get events
header_text "Getting operator logs"
kubectl logs deployment/memcached-operator -c operator
header_text "Getting Ansible logs"
kubectl logs deployment/memcached-operator -c ansible
kubectl logs deployment/memcached-operator
}

test_operator() {
Expand Down Expand Up @@ -109,7 +107,7 @@ test_operator() {
fi

header_text "Verify that config map requests skip the cache."
if ! kubectl logs deployment/memcached-operator -c operator | grep -e "Skipping cache lookup\".*"Path\":\"\/api\/v1\/namespaces\/default\/configmaps\/test-blacklist-watches\";
if ! kubectl logs deployment/memcached-operator | grep -e "Skipping cache lookup\".*"Path\":\"\/api\/v1\/namespaces\/default\/configmaps\/test-blacklist-watches\";
then
error_text "FAIL: test-blacklist-watches should not be accessible with the cache."
operator_logs
Expand Down Expand Up @@ -157,7 +155,7 @@ test_operator() {
fi

header_text "Ensure that no errors appear in the log"
if kubectl logs deployment/memcached-operator -c operator | grep -i error;
if kubectl logs deployment/memcached-operator| grep -i error;
then
error_text "FAIL: the operator log includes errors"
operator_logs
Expand Down
6 changes: 4 additions & 2 deletions internal/scaffold/ansible/ao_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"github.com/operator-framework/operator-sdk/internal/scaffold/input"
)

// todo(camilamacedo86): Remove before 1.0.0
// Deprecated : The dep inotify-tools will be removed and then, it will no long be required.
//DockerfileHybrid - Dockerfile for a hybrid operator
type AoLogs struct {
StaticInput
Expand All @@ -35,10 +37,10 @@ func (a *AoLogs) GetInput() (input.Input, error) {
return a.Input, nil
}

//TODO: Change this implementation for no longer use inotifywait.
// More Info: https://github.com/operator-framework/operator-sdk/issues/2007
const aoLogsTmpl = `#!/bin/bash

echo "WARN: This script is deprecated and will soon be removed"

watch_dir=${1:-/tmp/ansible-operator/runner}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2020-02-21 at 20 02 50

c/c @fabianvf

filename=${2:-stdout}
mkdir -p ${watch_dir}
Expand Down
14 changes: 1 addition & 13 deletions internal/scaffold/ansible/deploy_operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,7 @@ spec:
spec:
serviceAccountName: [[.ProjectName]]
containers:
- name: ansible
command:
- /usr/local/bin/ao-logs
- /tmp/ansible-operator/runner
- stdout
# Replace this with the built image name
image: "REPLACE_IMAGE"
imagePullPolicy: "Always"
volumeMounts:
- mountPath: /tmp/ansible-operator/runner
name: runner
readOnly: true
- name: operator
- name: [[.ProjectName]]
# Replace this with the built image name
image: "REPLACE_IMAGE"
imagePullPolicy: "Always"
Expand Down
4 changes: 3 additions & 1 deletion internal/scaffold/ansible/dockerfilehybrid.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ ENV OPERATOR=/usr/local/bin/ansible-operator \
RUN yum clean all && rm -rf /var/cache/yum/* \
&& yum -y update \
&& yum install -y libffi-devel openssl-devel python36-devel gcc python3-pip python3-setuptools \
# todo: remove inotify-tools. More info: See https://github.com/operator-framework/operator-sdk/issues/2007
# todo(camilamacedo) : remove the FEDORA and inotify-tools before 1.0.0
# ---- The usage of inotify-tools here is deprecated
&& FEDORA=$(case $(arch) in ppc64le|s390x) echo -n fedora-secondary ;; *) echo -n fedora/linux ;; esac) \
&& yum install -y https://dl.fedoraproject.org/pub/$FEDORA/releases/30/Everything/$(arch)/os/Packages/i/inotify-tools-3.14-16.fc30.$(arch).rpm \
# ----
&& pip3 install --no-cache-dir --ignore-installed ipaddress \
ansible-runner==1.3.4 \
ansible-runner-http==1.0.0 \
Expand Down
14 changes: 1 addition & 13 deletions internal/scaffold/ansible/molecule_templates_operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,7 @@ spec:
spec:
serviceAccountName: [[.ProjectName]]
containers:
- name: ansible
command:
- /usr/local/bin/ao-logs
- /tmp/ansible-operator/runner
- stdout
# Replace this with the built image name
image: "{{ image }}"
imagePullPolicy: "{{ pull_policy }}"
volumeMounts:
- mountPath: /tmp/ansible-operator/runner
name: runner
readOnly: true
- name: operator
- name: [[.ProjectName]]
# Replace this with the built image name
image: "{{ image }}"
imagePullPolicy: "{{ pull_policy }}"
Expand Down
12 changes: 1 addition & 11 deletions test/ansible-memcached/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,23 +192,13 @@
- name: get operator logs
ignore_errors: yes
failed_when: false
command: kubectl logs deployment/{{ definition.metadata.name }} -n {{ namespace }} -c operator
command: kubectl logs deployment/{{ definition.metadata.name }} -n {{ namespace }}
vars:
definition: "{{ lookup('file', '/'.join([deploy_dir, 'operator.yaml'])) | from_yaml }}"
register: log

- debug: var=log.stdout_lines

- name: get ansible logs
ignore_errors: yes
failed_when: false
command: kubectl logs deployment/{{ definition.metadata.name }} -n {{ namespace }} -c ansible
vars:
definition: "{{ lookup('file', '/'.join([deploy_dir, 'operator.yaml'])) | from_yaml }}"
register: ansible_log

- debug: var=ansible_log.stdout_lines

- fail:
msg: "Failed in verify.yml"

Expand Down
12 changes: 0 additions & 12 deletions test/ansible/deploy/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,6 @@ spec:
serviceAccountName: ansible
containers:
- name: ansible
command:
- /usr/local/bin/ao-logs
- /tmp/ansible-operator/runner
- stdout
# Replace this with the built image name
image: "REPLACE_IMAGE"
imagePullPolicy: "Always"
volumeMounts:
- mountPath: /tmp/ansible-operator/runner
name: runner
readOnly: true
- name: operator
# Replace this with the built image name
image: "REPLACE_IMAGE"
imagePullPolicy: "Always"
Expand Down
12 changes: 0 additions & 12 deletions test/ansible/molecule/templates/operator.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,6 @@ spec:
spec:
serviceAccountName: ansible
containers:
- name: ansible
command:
- /usr/local/bin/ao-logs
- /tmp/ansible-operator/runner
- stdout
# Replace this with the built image name
image: "{{ image }}"
imagePullPolicy: "{{ pull_policy }}"
volumeMounts:
- mountPath: /tmp/ansible-operator/runner
name: runner
readOnly: true
- name: operator
# Replace this with the built image name
image: "{{ image }}"
Expand Down