Repository: osbuild/osbuild-composer
Pull request #3413 (2023-04-27 10:50:47)

internal/manifest: remove redundant insights-client call
RHC automatically connects to insights already.

---
Done with 1 rhc connect call:
![image](https://user-images.githubusercontent.com/11140201/234841082-c9071559-df57-4156-b96a-8604f8385972.png)

---

marking as draft, as it does seem like it's doing *something*, I asked some other people for help.
![image](https://user-images.githubusercontent.com/11140201/234842862-cc2b568c-14e3-4a17-ad52-95c533e5f26f.png)

---

edit2: clarified the above with the insights devs, rhc already does this. So it's not needed.


Patch:
diff --git a/internal/manifest/os.go b/internal/manifest/os.go
index 89c7b3539..66c06207c 100644
--- a/internal/manifest/os.go
+++ b/internal/manifest/os.go
@@ -499,9 +499,6 @@ func (p *OS) serialize() osbuild.Pipeline {
 		if p.Subscription.Rhc {
 			// Use rhc for registration instead of subscription manager
 			commands = []string{fmt.Sprintf("/usr/bin/rhc connect -o=%s -a=%s --server %s", p.Subscription.Organization, p.Subscription.ActivationKey, p.Subscription.ServerUrl)}
-
-			// Always enable Insights when using rhc
-			commands = append(commands, "/usr/bin/insights-client --register")
 		} else {
 			commands = []string{fmt.Sprintf("/usr/sbin/subscription-manager register --org=%s --activationkey=%s --serverurl %s --baseurl %s", p.Subscription.Organization, p.Subscription.ActivationKey, p.Subscription.ServerUrl, p.Subscription.BaseUrl)}
 


Test patch:
diff --git a/internal/manifest/os_test.go b/internal/manifest/os_test.go
index 83bbcacd4..f2843c795 100644
--- a/internal/manifest/os_test.go
+++ b/internal/manifest/os_test.go
@@ -110,7 +110,6 @@ func TestRhcInsightsCommands(t *testing.T) {
 	pipeline := os.serialize()
 	CheckFirstBootStageOptions(t, pipeline.Stages, []string{
 		"/usr/bin/rhc connect -o=2040324 -a=my-secret-key --server subscription.rhsm.redhat.com",
-		"/usr/bin/insights-client --register",
 	})
 }
 
diff --git a/test/cases/ostree-ng.sh b/test/cases/ostree-ng.sh
index edcf687cb..fe0475dad 100755
--- a/test/cases/ostree-ng.sh
+++ b/test/cases/ostree-ng.sh
@@ -85,6 +85,8 @@ BLUEPRINT_FILE=${TEMPDIR}/blueprint.toml
 QUAY_CONFIG=${TEMPDIR}/quay_config.toml
 COMPOSE_START=${TEMPDIR}/compose-start-${IMAGE_KEY}.json
 COMPOSE_INFO=${TEMPDIR}/compose-info-${IMAGE_KEY}.json
+FEDORA_IMAGE_DIGEST="sha256:4d76a7480ce1861c95975945633dc9d03807ffb45c64b664ef22e673798d414b"
+FEDORA_LOCAL_NAME="localhost/fedora-minimal:v1"
 
 # SSH setup.
 SSH_OPTIONS=(-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=5)
@@ -406,6 +408,10 @@ if [[ "${EMBEDED_CONTAINER}" == "true" ]]; then
     tee -a "$BLUEPRINT_FILE" > /dev/null << EOF
 [[containers]]
 source = "quay.io/fedora/fedora:latest"
+
+[[containers]]
+source = "registry.gitlab.com/redhat/services/products/image-builder/ci/osbuild-composer/fedora-minimal@${FEDORA_IMAGE_DIGEST}"
+name = "${FEDORA_LOCAL_NAME}"
 EOF
 fi
 
@@ -763,6 +769,10 @@ if [[ "${EMBEDED_CONTAINER}" == "true" ]]; then
     tee -a "$BLUEPRINT_FILE" > /dev/null << EOF
 [[containers]]
 source = "quay.io/fedora/fedora:latest"
+
+[[containers]]
+source = "registry.gitlab.com/redhat/services/products/image-builder/ci/osbuild-composer/fedora-minimal@${FEDORA_IMAGE_DIGEST}"
+name = "${FEDORA_LOCAL_NAME}"
 EOF
 fi
 
diff --git a/test/cases/ostree.sh b/test/cases/ostree.sh
index cdb01f772..5661e7220 100755
--- a/test/cases/ostree.sh
+++ b/test/cases/ostree.sh
@@ -188,6 +188,8 @@ BLUEPRINT_FILE=${TEMPDIR}/blueprint.toml
 KS_FILE=${TEMPDIR}/ks.cfg
 COMPOSE_START=${TEMPDIR}/compose-start-${IMAGE_KEY}.json
 COMPOSE_INFO=${TEMPDIR}/compose-info-${IMAGE_KEY}.json
+FEDORA_IMAGE_DIGEST="sha256:4d76a7480ce1861c95975945633dc9d03807ffb45c64b664ef22e673798d414b"
+FEDORA_LOCAL_NAME="localhost/fedora-minimal:v1"
 
 # SSH setup.
 SSH_OPTIONS=(-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=5)
@@ -362,6 +364,10 @@ if [[ "${EMBEDED_CONTAINER}" == "true" ]]; then
     tee -a "$BLUEPRINT_FILE" > /dev/null << EOF
 [[containers]]
 source = "quay.io/fedora/fedora:latest"
+
+[[containers]]
+source = "registry.gitlab.com/redhat/services/products/image-builder/ci/osbuild-composer/fedora-minimal@${FEDORA_IMAGE_DIGEST}"
+name = "${FEDORA_LOCAL_NAME}"
 EOF
 fi
 
@@ -597,6 +603,10 @@ if [[ "${EMBEDED_CONTAINER}" == "true" ]]; then
     tee -a "$BLUEPRINT_FILE" > /dev/null << EOF
 [[containers]]
 source = "quay.io/fedora/fedora:latest"
+
+[[containers]]
+source = "registry.gitlab.com/redhat/services/products/image-builder/ci/osbuild-composer/fedora-minimal@${FEDORA_IMAGE_DIGEST}"
+name = "${FEDORA_LOCAL_NAME}"
 EOF
 fi
 
diff --git a/test/data/ansible/check_ostree.yaml b/test/data/ansible/check_ostree.yaml
index 0dbae3b48..b451f5f2a 100644
--- a/test/data/ansible/check_ostree.yaml
+++ b/test/data/ansible/check_ostree.yaml
@@ -485,6 +485,22 @@
             failed_counter: "{{ failed_counter | int + 1 }}"
       when: embeded_container == "true"
 
+    - name: embedded fedora-minimal container image should be listed by podman images
+      block:
+        - assert:
+            that:
+              - "'localhost/fedora-minimal' in result_podman_images.stdout"
+            fail_msg: "fedora-minimal image is not built in image"
+            success_msg: "fedora-minimal image is built in image"
+      always:
+        - set_fact:
+            total_counter: "{{ total_counter | int + 1 }}"
+      rescue:
+        - name: failed count + 1
+          set_fact:
+            failed_counter: "{{ failed_counter | int + 1 }}"
+      when: embeded_container == "true"
+
     # case: check running container with podman
     - name: run ubi8 image
       command: podman run registry.access.redhat.com/ubi8/ubi-minimal:latest cat /etc/redhat-release
@@ -536,6 +552,35 @@
           set_fact:
             failed_counter: "{{ failed_counter | int + 1 }}"
 
+    # case: check fedora-minimal container with podman
+    - name: run fedora-minimal image
+      command: podman run localhost/fedora-minimal@sha256:4d76a7480ce1861c95975945633dc9d03807ffb45c64b664ef22e673798d414b cat /etc/os-release
+      register: fminimal_container_result
+      become: yes
+      retries: 30  # due to https://github.com/osbuild/osbuild-composer/issues/2492
+      delay: 2
+      until: fminimal_container_result is success
+      ignore_errors: yes  # due to https://bugzilla.redhat.com/show_bug.cgi?id=1903983
+      when: embeded_container == "true"
+
+    - name: run fedora-minimal container test
+      block:
+        - assert:
+            that:
+              - fminimal_container_result is succeeded
+              - "'Fedora Linux 36 (Container Image)' in fminimal_container_result.stdout"
+              - "'Trying to pull' not in fminimal_container_result.stdout"
+            fail_msg: "failed run fedora-minimal container with podman"
+            success_msg: "running fedora-minimal container with podman successed"
+      always:
+        - set_fact:
+            total_counter: "{{ total_counter | int + 1 }}"
+      rescue:
+        - name: failed count + 1
+          set_fact:
+            failed_counter: "{{ failed_counter | int + 1 }}"
+      when: embeded_container == "true"
+
     # case: check dnf package and it should not be installed
     # https://github.com/osbuild/osbuild-composer/blob/master/internal/distro/rhel8/distro.go#L642
     - name: dnf should not be installed