Cosmic ray hazards The Pierre Auger Observatory site mentions the detection of a 3E20 eV (48 J) cosmic ray whose energy, well above the GZK cutoff, was based on an analysis of its atmospheric shower. This was equivalent to the kinetic energy of a baseball with a speed of 79.5 m/s or 177 mph. Of course, cosmic rays with such ulta-high energies are extremely rare.
What kind of damage would occur if an astronaut or a space vehicle encountered such a cosmic ray? How would the damage differ from that from the hypothetical 79.5 m/s baseball?
 A: Ultra-high energy cosmic rays all come from a very, very long way away (anything with the power to create them nearby would constitute a danger to life as we know it). I think the preferred mechanism these days is dynamic acceleration in the jets formed by active galactic nuclei, but don't quote me.
Anyway, ultra-relativistic though they are, that means they are stable particles. Mostly protons, in fact.
When a ultra-high energy proton passes though a modest amount of matter, like an astronaut, we can model its energy loss very simply. The graph in the Particle Physics Data Book, doesn't actually go high enough, but we can extrapolate and say the energy loss is still less than $10\text{ MeV/g/cm}^2$. Our astronaut has a density pretty near $1\text{ g/cm}^3$ and a average thickness (allowing for all aspect ratios) of around 50 cm. So the total energy to be expected is only 500 MeV.
It is ionizing radiation, of course, but not qualitatively different from the rest of the cosmic background.
If the space craft is a smallish, thin-walled can with a little air in it the situation is only a little worse. There is more chance of showering. But it's just a higher dose, rather than being a spectacular death.
A: These are rare, on the order of one per square mile per century. See Ultra-high-energy cosmic ray (Wikipedia). So a human, with a cross sectional area less than 1 square meter might get hit about once per each 100 million years. I think that the risk of life due to spacecraft malfunction is significantly greater than this.
And when they do hit the Earth's atmosphere, they expend their energy over the whole depth of the atmosphere. No one single region gets plastered. (Otherwise they'd have been detected long before, by the sound of the air getting overheated.) The thickness of the atmosphere, in terms of equivalent mass of water, is around 10 meters of water. This is much thicker than the equivalent weight distribution of a spacecraft. So my back of the envelope conclusion is that if a spacecraft did get hit by one, most of the energy will exit the far side of the spacecraft.
On the other hand, cosmic rays of all sorts can damage electronics. It can switch ones to zeroes or vice versa, and I would think that such a high energy ray as this could actually hurt a component.

To realistically examine spacecraft in terms of how cosmic rays act in them, it's useful to use numbers for a real spacecraft. In addition to a thin metal shell, a spacecraft also has gas storage, fuel storage, and a place to go to the bathroom. And a spacecraft must be built sturdily even if it doesn't have to land on the earth. They are big, heavy, objects.
For example, the International Space Station (ISS) weighs 375,000 kg and has a pressurized volume of 907m^3:    
Thus its density is 375,000/907 = 413 kg/m^3 almost half that of water, and it has a distance between inelastic collisions of about 3.7 cm.
Most of the spacecraft consists of the solar panels. However, like any other nuclear matter, these will generate cascades when they are hit by a cosmic ray. The length of the vessel (along its crew compartment) is 51 meters. With the pressurized volume, if this were a cylinder its diameter would be about 4.8 meters.
With a distance of 51 meters and a density of 0.41 that of water, the long dimension on the ISS is equivalent to 20 m of water. This is twice the depth of the Earth's atmosphere. The short distance is around 2 m of water or 1/5th the Earth's atmosphere. This is enough to get a shower going.
These calculations are worst case in that they've imputed all the weight of the spacecraft to the pressurized volume. A more accurate calculation would involve a spacecraft which does not have the solar panels. An example of this would be the US space shuttle orbiter. With payload, it's 93,000 kg (max landing weight 104,000 kg). The length is 37 m with a wingspan of 24 m. The diameter of the main crew compartment appears to be about 7 m.
Under the assumption that the spacecraft is a cylinder of length 37 m and diameter 7 m, its volume is around 1400 cubic meters, and its density is around 74 kg/m^3. Thus a particle traveling the length of the craft will encounter about 37 m x 74 kg/m^3 = 2.7 meters of water equivalent. At 1/4 the thickness of the earth's atmosphere, this is enough to get a good cascade going.

Anna v notes that the (inelastic) cross-sectional area for an extremely high energy proton-proton collision is only around 1 barn or 1.0E-28 m^2. Actually, her (1984) article gives 530 mb, but at very high energies, the cross section is unknown and might exceed a barn, see figure (4):
Nucl.Phys.Proc.Suppl.196:335-340 (2009), Ralf Ulrich, Ralph Engel, Steffen Müller, Fabian Schüssler, Michael Unger Proton-Air Cross Section and Extensive Air Showers
http://arxiv.org/abs/0906.3075
The mass of the proton is about 1.6E-27 kg, and a cubic meter of water weighs 1000 kg (almost entirely nucleons, that is, protons and neutrons). Thus there are 1000/1.6E-27 = 6.25E+29 nucleons per cubic meter of water. Multiplying by the cross-sectional area gives a total cross sectional area/m^3 of 62.5 m^2. Thus the distance at which such a proton begins a cascade, in water, is about 1/62.5 m = 1.6 cm, and by the time the particle has exited the human body 50 cm later, it has had about 31 such collisions. Thus the size of the human body is sufficient to begin a cosmic ray cascade.
In a practical long-distance spaceship, it's important to shield the crew from cosmic rays and solar flares. One of the suggestions for doing this is with shields composed of 7 kg of aluminum per square meter, which is about 0.7 cm water equivalent thickness: http://arxiv.org/abs/astro-ph/0701314 Thus there's about a 50% probability for a high energy cosmic ray starting off a cascade on going through this thickness.
A: One must keep  in mind also that it is the particle, not the shower that goes through the astronaut in  dmckee's estimate above,  where he treats the relativistic particle going through matter. 
The shower in your question which gave the energy estimate of the parent particle is generated by cascade/sequential  collisions of deep angle scattering over a long path. The energy is not released in one go unless the astronaut is very unlucky.
The deep inelastic scattering crossection at those energies is still not up to barn values ( a barn is about the size of a uranium nucleus) so the astronaut would have to be very unlucky even to get one energetic scatter let alone to start a shower.
