Merge "Hardcoded version of yq, decreased cloud init script"
diff --git a/de/heat-templates/fragments/SrvInstancesBM.yaml b/de/heat-templates/fragments/SrvInstancesBM.yaml
index c3ffa7d..5599d11 100644
--- a/de/heat-templates/fragments/SrvInstancesBM.yaml
+++ b/de/heat-templates/fragments/SrvInstancesBM.yaml
@@ -98,10 +98,6 @@
             owner: "root:root"
             permissions: "0644"
             content: { get_param: hardware_metadata}
-          - path: /usr/sbin/calico_disable_offloading.sh
-            owner: "root:root"
-            permissions: "0755"
-            content: {get_file: ../scripts/calico_disable_offloading.sh}
 
   install_config_agent:
     type: "OS::Heat::MultipartMime"
diff --git a/de/heat-templates/fragments/SrvInstancesBMCeph.yaml b/de/heat-templates/fragments/SrvInstancesBMCeph.yaml
index c9a337c..7c6a76d 100644
--- a/de/heat-templates/fragments/SrvInstancesBMCeph.yaml
+++ b/de/heat-templates/fragments/SrvInstancesBMCeph.yaml
@@ -122,10 +122,6 @@
             owner: "root:root"
             permissions: "0644"
             content: { get_param: hardware_metadata}
-          - path: /usr/sbin/calico_disable_offloading.sh
-            owner: "root:root"
-            permissions: "0755"
-            content: {get_file: ../scripts/calico_disable_offloading.sh}
 
   install_config_agent:
     type: "OS::Heat::MultipartMime"
diff --git a/de/heat-templates/fragments/SrvInstancesBMCephOSD.yaml b/de/heat-templates/fragments/SrvInstancesBMCephOSD.yaml
index c8bdd4b..4fa2615 100644
--- a/de/heat-templates/fragments/SrvInstancesBMCephOSD.yaml
+++ b/de/heat-templates/fragments/SrvInstancesBMCephOSD.yaml
@@ -148,10 +148,6 @@
             owner: "root:root"
             permissions: "0644"
             content: { get_param: hardware_metadata}
-          - path: /usr/sbin/calico_disable_offloading.sh
-            owner: "root:root"
-            permissions: "0755"
-            content: {get_file: ../scripts/calico_disable_offloading.sh}
 
   install_config_agent:
     type: "OS::Heat::MultipartMime"
diff --git a/de/heat-templates/fragments/SrvInstancesVM.yaml b/de/heat-templates/fragments/SrvInstancesVM.yaml
index d3e0427..67e92e0 100644
--- a/de/heat-templates/fragments/SrvInstancesVM.yaml
+++ b/de/heat-templates/fragments/SrvInstancesVM.yaml
@@ -117,10 +117,6 @@
             owner: "root:root"
             permissions: "0644"
             content: { get_param: hardware_metadata}
-          - path: /usr/sbin/calico_disable_offloading.sh
-            owner: "root:root"
-            permissions: "0755"
-            content: {get_file: ../scripts/calico_disable_offloading.sh}
 
   install_config_agent:
     type: "OS::Heat::MultipartMime"
diff --git a/de/heat-templates/fragments/SrvInstancesVMCeph.yaml b/de/heat-templates/fragments/SrvInstancesVMCeph.yaml
index 3fc96d5..17b2593 100644
--- a/de/heat-templates/fragments/SrvInstancesVMCeph.yaml
+++ b/de/heat-templates/fragments/SrvInstancesVMCeph.yaml
@@ -130,10 +130,6 @@
             owner: "root:root"
             permissions: "0644"
             content: { get_param: hardware_metadata}
-          - path: /usr/sbin/calico_disable_offloading.sh
-            owner: "root:root"
-            permissions: "0755"
-            content: {get_file: ../scripts/calico_disable_offloading.sh}
 
   install_config_agent:
     type: "OS::Heat::MultipartMime"
diff --git a/de/heat-templates/fragments/SrvInstancesVMCephOSD.yaml b/de/heat-templates/fragments/SrvInstancesVMCephOSD.yaml
index d66dae9..f9c2ce9 100644
--- a/de/heat-templates/fragments/SrvInstancesVMCephOSD.yaml
+++ b/de/heat-templates/fragments/SrvInstancesVMCephOSD.yaml
@@ -172,10 +172,6 @@
             owner: "root:root"
             permissions: "0644"
             content: { get_param: hardware_metadata}
-          - path: /usr/sbin/calico_disable_offloading.sh
-            owner: "root:root"
-            permissions: "0755"
-            content: {get_file: ../scripts/calico_disable_offloading.sh}
 
   install_config_agent:
     type: "OS::Heat::MultipartMime"
diff --git a/de/heat-templates/scripts/calico_disable_offloading.sh b/de/heat-templates/scripts/calico_disable_offloading.sh
deleted file mode 100644
index 26ce61b..0000000
--- a/de/heat-templates/scripts/calico_disable_offloading.sh
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/usr/bin/env bash
-
-# script is taken from https://gerrit.mcp.mirantis.com/plugins/gitiles/kubernetes/lcm-ansible/+/refs/heads/master/roles/kubernetes-postinstall/templates/calico_disable_offloading.sh
-# This script apply a workaround for a bug encountered on Kubernetes with vxlan
-# and iptables >= 1.6.2.
-# You can find more details on this bug here:
-# https://github.com/kubernetes/kubernetes/issues/96868
-# https://github.com/projectcalico/calico/issues/3145
-#
-# The workaround is to disable offloading on vxlan interface
-
-nic_name='vxlan.calico'
-if [ -e /etc/system-release ]; then
-    #RHEL
-    ethtool_cmd="/usr/sbin/ethtool"
-    ip_cmd="/usr/sbin/ip"
-else
-    #Ubuntu
-    ethtool_cmd="/sbin/ethtool"
-    ip_cmd="/sbin/ip"
-fi
-
-_ethtool() {
-    $ethtool_cmd "$@"
-}
-
-_ip () {
-    $ip_cmd "$@"
-}
-
-is_nic_available() {
-    _ip a show dev $nic_name > /dev/null 2>&1
-}
-
-deactivate_offloading() {
-    echo "Disabling offloading for ${nic_name}"
-    _ethtool --offload $nic_name rx off tx off > /dev/null
-}
-
-is_offloading_disabled() {
-    # Return an error if at least one offload is enabled (rx or tx)
-    if _ethtool --show-offload $nic_name | grep -E '^.x-checksumming:' | grep -q  ': on'; then
-        return 1
-    else
-        return 0
-    fi
-}
-
-if is_nic_available; then
-    if ! is_offloading_disabled; then
-        deactivate_offloading
-        exit $?
-    fi
-fi
\ No newline at end of file
diff --git a/de/heat-templates/scripts/instance_boot.sh b/de/heat-templates/scripts/instance_boot.sh
index 5950eff..6bfa35b 100644
--- a/de/heat-templates/scripts/instance_boot.sh
+++ b/de/heat-templates/scripts/instance_boot.sh
@@ -217,9 +217,11 @@
         fi
     fi
     function install_retry {
-        add-apt-repository ppa:rmescandon/yq -y
         apt update
-        export DEBIAN_FRONTEND=noninteractive; apt install -y $pkg_list yq
+        export DEBIAN_FRONTEND=noninteractive; apt install -y $pkg_list
+        # Since version 4 yq uses another syntax
+        curl --retry 6 --retry-delay 5 -L https://github.com/mikefarah/yq/releases/download/3.3.2/yq_linux_amd64 -o /usr/bin/yq
+        chmod +x /usr/bin/yq
     }
     retry 10 "Failed to install required packages" install_retry
 }
@@ -988,9 +990,22 @@
 }
 
 function cron_disable_calico_offloading {
-    cat << EOF >> /etc/cron.d/disable_calico_offloading
-* * * * * root /usr/sbin/calico_disable_offloading.sh 2>&1 | /usr/bin/logger -t calico_disable_offloading
+    # The workaround is to disable offloading on vxlan interface
+    if [ -f /etc/cron.d/disable_calico_offloading ]; then
+        echo "Cronjob for disable callico offloading already exists"
+    else
+        script_path="/usr/sbin/calico_disable_offloading.sh"
+        cat << 'EOF' >> $script_path
+#!/usr/bin/env bash
+if /sbin/ethtool --show-offload vxlan.calico | grep -E '^.x-checksumming:' | grep -q  ': on'; then
+    /sbin/ethtool --offload vxlan.calico rx off tx off > /dev/null
+fi
 EOF
+        chmod +x $script_path
+        cat << EOF >> /etc/cron.d/disable_calico_offloading
+* * * * * root $script_path 2>&1 | /usr/bin/logger -t calico_disable_offloading
+EOF
+    fi
 }
 
 function increase_iscsi_timeout {
diff --git a/de/heat-templates/scripts/license.lic b/de/heat-templates/scripts/license.lic
deleted file mode 100644
index 7407f46..0000000
--- a/de/heat-templates/scripts/license.lic
+++ /dev/null
@@ -1 +0,0 @@
-{"key_id":"lhF-hcUDANCs7YmGaTNHQ4N1aTSUfhO-jPhDchNbbmkd","private_key":"g-uMHRNS4BAn9yRMTAyLS2HbuwzKkRl3-Z1yGMaPD2Mn","authorization":"ewogICAicGF5bG9hZCI6ICJleUpsZUhCcGNtRjBhVzl1SWpvaU1qQXlNQzB3TWkweU9GUXhOVG95TXpveU1sb2lMQ0owYjJ0bGJpSTZJbFZUVmsxVFprZE9lVGQyUTE4ME0zQkViazF2ZGxjNFlraDVURGRWUm1GTlMyNW5hM0F5ZUZWSmJtODlJaXdpYldGNFJXNW5hVzVsY3lJNk1UQXNJbk5qWVc1dWFXNW5SVzVoWW14bFpDSTZkSEoxWlN3aWJHbGpaVzV6WlZSNWNHVWlPaUpQYm14cGJtVWlMQ0owYVdWeUlqb2lWSEpwWV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