Fix userdata/metadata fetch on Packet
This commit is contained in:
parent
6ab21c400a
commit
e279304633
@ -73,12 +73,16 @@
|
||||
|
||||
Name: ignition
|
||||
Version: 2.2.1
|
||||
Release: 1.git%{shortcommit}%{?dist}
|
||||
Release: 2.git%{shortcommit}%{?dist}
|
||||
Summary: First boot installer and configuration tool
|
||||
License: ASL 2.0 and BSD
|
||||
URL: https://%{provider_prefix}
|
||||
Source0: https://%{provider_prefix}/archive/%{commit}/%{repo}-%{shortcommit}.tar.gz
|
||||
Source1: https://%{dracutprovider_prefix}/archive/%{dracutcommit}/%{dracutrepo}-%{dracutshortcommit}.tar.gz
|
||||
# Upstream 73cbfa847e4319a202c360bd8cd447712d2067bc
|
||||
Patch0: packet-fix-userdata-fetch.patch
|
||||
# Upstream 4c2dcd547b01b2f13ced8d35263ded5fd67fa645
|
||||
Patch1: packet-fix-metadata-fetch.patch
|
||||
|
||||
%define gopath %{_datadir}/gocode
|
||||
ExcludeArch: ppc64
|
||||
@ -376,6 +380,8 @@ Ignition project's Github releases page.
|
||||
# setup command reference: http://ftp.rpm.org/max-rpm/s1-rpm-inside-macros.html
|
||||
# unpack source0 and apply patches
|
||||
%setup -T -b 0 -q -n %{repo}-%{commit}
|
||||
%patch0 -p1
|
||||
%patch1 -p1
|
||||
|
||||
# unpack source1 (dracut modules)
|
||||
%setup -T -D -a 1 -q -n %{repo}-%{commit}
|
||||
@ -540,6 +546,9 @@ export GOPATH=%{buildroot}/%{gopath}:$(pwd)/vendor:%{gopath}
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Sat Mar 28 2020 Benjamin Gilbert <bgilbert@redhat.com> - 2.2.1-2.git2d3ff58
|
||||
- Fix userdata/metadata fetch on Packet
|
||||
|
||||
* Tue Mar 24 2020 Benjamin Gilbert <bgilbert@redhat.com> - 2.2.1-1.git2d3ff58
|
||||
- New release
|
||||
- Bump ignition-dracut for initramfs network teardown
|
||||
|
33
packet-fix-metadata-fetch.patch
Normal file
33
packet-fix-metadata-fetch.patch
Normal file
@ -0,0 +1,33 @@
|
||||
From 4c2dcd547b01b2f13ced8d35263ded5fd67fa645 Mon Sep 17 00:00:00 2001
|
||||
From: Benjamin Gilbert <bgilbert@redhat.com>
|
||||
Date: Sat, 28 Mar 2020 01:15:32 -0400
|
||||
Subject: [PATCH 2/2] providers/packet: override Accept header fetching
|
||||
instance metadata
|
||||
|
||||
Passing nil Headers is no longer sufficient to avoid the default Accept
|
||||
header; we need to override it. Fixes 406 Not Acceptable error.
|
||||
|
||||
Fixes: 75d3e2da74ae ("Rework fetch/resource to automatically append required headers")
|
||||
---
|
||||
internal/providers/packet/packet.go | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/internal/providers/packet/packet.go b/internal/providers/packet/packet.go
|
||||
index 8771734..613a6ba 100644
|
||||
--- a/internal/providers/packet/packet.go
|
||||
+++ b/internal/providers/packet/packet.go
|
||||
@@ -71,8 +71,10 @@ func FetchConfig(f *resource.Fetcher) (types.Config, report.Report, error) {
|
||||
func PostStatus(stageName string, f resource.Fetcher, errMsg error) error {
|
||||
f.Logger.Info("POST message to Packet Timeline")
|
||||
// fetch JSON from https://metadata.packet.net/metadata
|
||||
+ headers := make(http.Header)
|
||||
+ headers.Set("Accept", "*/*")
|
||||
data, err := f.FetchToBuffer(metadataUrl, resource.FetchOptions{
|
||||
- Headers: nil,
|
||||
+ Headers: headers,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
--
|
||||
2.24.1
|
||||
|
41
packet-fix-userdata-fetch.patch
Normal file
41
packet-fix-userdata-fetch.patch
Normal file
@ -0,0 +1,41 @@
|
||||
From 73cbfa847e4319a202c360bd8cd447712d2067bc Mon Sep 17 00:00:00 2001
|
||||
From: Benjamin Gilbert <bgilbert@redhat.com>
|
||||
Date: Sat, 28 Mar 2020 01:07:54 -0400
|
||||
Subject: [PATCH 1/2] resource/url: allow caller-specified headers to override
|
||||
defaults
|
||||
|
||||
Set defaults first, then override them with caller-specified headers.
|
||||
Fixes default Accept header causing 406 Not Acceptable when fetching
|
||||
userdata on Packet.
|
||||
|
||||
Fixes: 75d3e2da74ae ("Rework fetch/resource to automatically append required headers")
|
||||
---
|
||||
internal/resource/url.go | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/internal/resource/url.go b/internal/resource/url.go
|
||||
index c304758..d08964a 100644
|
||||
--- a/internal/resource/url.go
|
||||
+++ b/internal/resource/url.go
|
||||
@@ -257,14 +257,14 @@ func (f *Fetcher) fetchFromHTTP(u url.URL, dest io.Writer, opts FetchOptions) er
|
||||
// TODO use .Clone() when we have a new enough golang
|
||||
// (With Rust, we'd have immutability and wouldn't need to defensively clone)
|
||||
headers := make(http.Header)
|
||||
- for k, va := range opts.Headers {
|
||||
+ for k, va := range configHeaders {
|
||||
for _, v := range va {
|
||||
- headers.Add(k, v)
|
||||
+ headers.Set(k, v)
|
||||
}
|
||||
}
|
||||
- for k, va := range configHeaders {
|
||||
+ for k, va := range opts.Headers {
|
||||
for _, v := range va {
|
||||
- headers.Add(k, v)
|
||||
+ headers.Set(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
2.24.1
|
||||
|
Loading…
Reference in New Issue
Block a user